forked from scala/scala3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reimplement support for type aliases in SAM types
This was dropped in scala#18201 which restricted SAM types to valid parent types, but it turns out that there is code in the wild that relies on refinements being allowed here. To support this properly, we had to enhance ExpandSAMs to move refinements into type members to pass Ycheck (previous Scala 3 releases would accept the code in tests/run/i18315.scala but fail Ycheck). Fixes scala#18315.
- Loading branch information
1 parent
419cfe6
commit e6cccca
Showing
4 changed files
with
85 additions
and
45 deletions.
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
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,15 @@ | ||
trait Sam1: | ||
type T | ||
def apply(x: T): T | ||
|
||
trait Sam2: | ||
var x: Int = 1 // To force anonymous class generation | ||
type T | ||
def apply(x: T): T | ||
|
||
object Test: | ||
def main(args: Array[String]): Unit = | ||
val s1: Sam1 { type T = String } = x => x.trim | ||
s1.apply("foo") | ||
val s2: Sam2 { type T = Int } = x => x + 1 | ||
s2.apply(1) |