-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Dotty typer crashes with scalajs Lambda SAM error #15785
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I can reproduce this without Scala.js, by defining a SAM type as follows: trait SAMFunction1[-T1, +R] {:
def apply(x1: T1): R and using it instead of In fact, I can minimize it all the way to trait SAMFunction1[-T1, +R]:
def apply(x1: T1): R
def fooSAM[T](foo: SAMFunction1[T, T] = (f: T) => f): Unit = () No need for context bounds or givens, or for a class constructor. Just a parameter of a generic SAM type with a default value which is a lambda. (Replacing |
The default argument is typed with an expected type of trait SAMFunction1[-T1, +R]:
def apply(x1: T1): R
def fooSAM[T](foo: SAMFunction1[T, T] = ((f: T) => f): SAMFunction1[T, T]): Unit = () Since SAM types with wildcards are hard to handle, it'd be simpler to always type them with the more precise expected type |
Compiler version
Scala 3.2.0 RC-2 and RC-1
Minimized code
https://scastie.scala-lang.org/W2mz3ejSTOOIOkuUzHC6Tg
(note that scala3 types compile but scalajs type does not)
Output (click arrow to expand)
Additional discussion on discord:
https://discord.com/channels/632150470000902164/635668814956068864/1002302314889084928
The text was updated successfully, but these errors were encountered: