-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Compiler crash with (f:AnyRef => AnyRef) #19962
Comments
Minimizationdef selfie: Any = (f: Any => Any) => f(f) |
Something goes wrong in [[syntax trees at end of erasure]] // t/Test.scala
package <empty> {
final lazy module val Test$package: Test$package = new Test$package()
@SourceFile("t/Test.scala") final module class Test$package() extends Object()
{
private def writeReplace(): Object =
new scala.runtime.ModuleSerializationProxy(classOf[Test$package])
def fun(): Object =
{
def $anonfun(f: Function1): Object = f.apply(f)
closure($anonfun)
}
}
}
[[syntax trees at end of MegaPhase{elimErasedValueType, pureStats, vcElideAllocations, etaReduce, arrayApply, elimPolyFunction, tailrec, completeJavaEnums, mixin, lazyVals, memoize, nonLocalReturns, capturedVars}]] // t/Test.scala
package <empty> {
final lazy module val Test$package: Test$package = new Test$package()
@SourceFile("t/Test.scala") final module class Test$package() extends Object {
super()
private def writeReplace(): Object =
new scala.runtime.ModuleSerializationProxy(classOf[Test$package])
def fun(): Object = f
}
} |
The issue is in By splitting the mini phases we get[[syntax trees at end of erasure]] // t/Test.scala
package <empty> {
final lazy module val Test$package: Test$package = new Test$package()
@SourceFile("t/Test.scala") final module class Test$package() extends Object()
{
private def writeReplace(): Object =
new scala.runtime.ModuleSerializationProxy(classOf[Test$package])
def fun(): Object =
{
def $anonfun(f: Function1): Object = f.apply(f)
closure($anonfun)
}
}
}
[[syntax trees at end of elimErasedValueType]] // t/Test.scala: unchanged since erasure
[[syntax trees at end of pureStats]] // t/Test.scala: unchanged since erasure
[[syntax trees at end of vcElideAllocations]] // t/Test.scala: unchanged since erasure
[[syntax trees at end of etaReduce]] // t/Test.scala
package <empty> {
final lazy module val Test$package: Test$package = new Test$package()
@SourceFile("t/Test.scala") final module class Test$package() extends Object()
{
private def writeReplace(): Object =
new scala.runtime.ModuleSerializationProxy(classOf[Test$package])
def fun(): Object = f
}
} |
nicolasstucki
added a commit
to dotty-staging/dotty
that referenced
this issue
Mar 18, 2024
nicolasstucki
added a commit
to dotty-staging/dotty
that referenced
this issue
Mar 18, 2024
In general, this fails on any (x1: T1, ..., xi: Ti, ..., xn: Tn) => xi.apply(x1, ..., xn) where Ti =:= (T1, ..., Ti-1, U, Ti+1, ... Tn) => R and Ti <: U This seems to be an unlikely corner case. |
nicolasstucki
added a commit
that referenced
this issue
Mar 18, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Compiler version
3.3.3 and 3.4.0
Works fine in Scala 2.
Minimized code
Output (click arrow to expand)
The text was updated successfully, but these errors were encountered: