-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Compiler crash with scala.MatchError: trait mixed into object "_setter_" (dotty.tools.dotc.core.Names$DerivedName) - vals from tuple desugaring #10285
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
Minimized further: trait Foo:
val (a, b) = (1, 2)
class FooImpl extends Foo
Looks to have been broken since 0.26.0-RC1 (#8652). |
A val in a trait is iimplemented as a setter that is called in the class that implements the trait. Here there's actually three vals involved because of the val pattern which desugars to: val $1$ = (1, 2)
val a = $1$._1
val b = $1$._2 The problem is linked to this compiler-generated Foo$_setter_$Foo$$_=$1 Semantically this is: Foo[Qualified $_setter_$ Foo$$_=][Unique $ 1] The weird part is that the name doesn't end with Foo[Qualified $$ ][Unique $ 1] to: Foo[Qualified $_setter_$ Foo$$][Unique $ 1] when calling Foo[Qualified $_setter_$ Foo$$_=][Unique $ 1] when calling |
For comparison scalac generates: val x$1 = (1, 2)
val a = $1$._1
val b = $1$._2 and ends up with these three setters in the trait: def x$1_=(x: (Int, Int)): Unit
def Foo$_setter_$a_=(x: Int): Unit
def Foo$_setter_$b_=(x$1: Int): Unit For some reason the setter for the freshly generated |
... looks like this is just a pretty-printing bug in scalac, if I look in the bytecode I do see: void Foo$_setter_$Foo$$x$1_$eq(Tuple2 var1) |
…ived names Adding "_=" to the last part of a name does not work if that name is a unique name or other derived name, since the resulting name would print like `x_=$1` instead of `x$1_=`. Use a new semantic name for synthetic setter suffix instead.
Fix #10285: Fix scheme for handling setter names
Minimized code
Output
The text was updated successfully, but these errors were encountered: