forked from scala/scala3
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix SAM conversion involving ()-insertion and overloading
Without overloading, a function literal `() => 3` whose expected type is a Unit-returning SAM gets typed as `() => { 3; () }` as expected, but with overloading we first type the function literal without an expected type and then compare it against the formal parameter type. This commit makes this check succeed by replacing a result type of `Unit` by `WildcardType` so we end up comparing `() => Int <:< () => ?` instead of `() => Int <:< () => Unit`. Fixes scala#13549.
- Loading branch information
Showing
4 changed files
with
23 additions
and
5 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,11 @@ | ||
@FunctionalInterface | ||
trait Executable { | ||
def execute(): Unit | ||
} | ||
|
||
object Test { | ||
def assertThrows(executable: Executable, message: String): Unit = ??? | ||
def assertThrows(executable: Executable, foo: Int): Unit = ??? | ||
|
||
assertThrows(() => 3, "This is a message") | ||
} |