File tree 5 files changed +36
-1
lines changed
compiler/src/dotty/tools/backend/jvm
5 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -60,7 +60,7 @@ final class BCodeAsmCommon[I <: DottyBackendInterface](val interface: I) {
60
60
assert(classSym.isClass, classSym)
61
61
def enclosingMethod (sym : Symbol ): Option [Symbol ] = {
62
62
if (sym.isClass || sym == NoSymbol ) None
63
- else if (sym.is(Method )) Some (sym)
63
+ else if (sym.is(Method , butNot = Synthetic )) Some (sym)
64
64
else enclosingMethod(sym.originalOwner)
65
65
}
66
66
enclosingMethod(classSym.originalOwner)
Original file line number Diff line number Diff line change
1
+ public TB A$$anon$1.tb()
Original file line number Diff line number Diff line change
1
+ public TB A$$anon$2.apply()
Original file line number Diff line number Diff line change
1
+ // scalajs: --skip
2
+ // Use of Java reflection (getEnclosingMethod)
3
+ abstract class TA { def tb (): TB }
4
+ abstract class TB { def chk (): Unit }
5
+ class A :
6
+ def a (): TA =
7
+ new TA {
8
+ def tb (): TB =
9
+ val fn : () => TB = new Function0 [TB ]:
10
+ def apply (): TB = new TB {
11
+ def chk () = println(getClass.getEnclosingMethod())
12
+ }
13
+ fn()
14
+ }
15
+
16
+ object Test :
17
+ def main (args : Array [String ]): Unit = new A ().a().tb().chk()
Original file line number Diff line number Diff line change
1
+ // scalajs: --skip
2
+ // Use of Java reflection (getEnclosingMethod)
3
+ abstract class TA { def tb (): TB }
4
+ abstract class TB { def chk (): Unit }
5
+ class A :
6
+ def a (): TA =
7
+ new TA {
8
+ def tb (): TB =
9
+ val fn : () => TB = () => new TB {
10
+ def chk () = println(getClass.getEnclosingMethod())
11
+ }
12
+ fn()
13
+ }
14
+
15
+ object Test :
16
+ def main (args : Array [String ]): Unit = new A ().a().tb().chk()
You can’t perform that action at this time.
0 commit comments