-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix EnclosingMethod for lifted anonfun (#20558)
The anonfun "() => new TB {.." code is lifted to a static method, in the original class (A), but the GenBCode logic was still returning the TA anon class. Fixes #18701
- Loading branch information
Showing
5 changed files
with
36 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
public TB A$$anon$1.tb() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
public TB A$$anon$2.apply() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// scalajs: --skip | ||
// Use of Java reflection (getEnclosingMethod) | ||
abstract class TA { def tb(): TB } | ||
abstract class TB { def chk(): Unit } | ||
class A: | ||
def a(): TA = | ||
new TA { | ||
def tb(): TB = | ||
val fn: () => TB = new Function0[TB]: | ||
def apply(): TB = new TB { | ||
def chk() = println(getClass.getEnclosingMethod()) | ||
} | ||
fn() | ||
} | ||
|
||
object Test: | ||
def main(args: Array[String]): Unit = new A().a().tb().chk() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// scalajs: --skip | ||
// Use of Java reflection (getEnclosingMethod) | ||
abstract class TA { def tb(): TB } | ||
abstract class TB { def chk(): Unit } | ||
class A: | ||
def a(): TA = | ||
new TA { | ||
def tb(): TB = | ||
val fn: () => TB = () => new TB { | ||
def chk() = println(getClass.getEnclosingMethod()) | ||
} | ||
fn() | ||
} | ||
|
||
object Test: | ||
def main(args: Array[String]): Unit = new A().a().tb().chk() |