Closed
Description
Compiler version
3.4.0-RC1-bin-20231006-b1ccc6a-NIGHTLY
Minimized code
Scastie: https://scastie.scala-lang.org/cYHDxwGgQzm3VBWrIHYQhA
a.scala
import language.experimental.relaxedExtensionImports
class A(var x: String = "a")
object AA:
extension (a: A)
def f = a.x
def f_=(x: String) = a.x = x
b.scala
import language.experimental.relaxedExtensionImports
class B(var x: String = "b")
object BB:
extension (b: B)
def f = b.x
def f_=(x: String) = b.x = x
main.scala
import language.experimental.relaxedExtensionImports
import AA.*
import BB.*
@main def main() =
val a = A()
a.f = "aa"
println(a.f)
Output
sbt:tmp> run
[info] compiling 1 Scala source to /workspaces/tmp/target/scala-3.4.0-RC1-bin-20231006-b1ccc6a-NIGHTLY/classes ...
[error] -- [E052] Type Error: /workspaces/tmp/main.scala:7:8 --------
[error] 6 | a.f = "aa"
[error] | ^^^^^^^^^^
[error] | Reassignment to val f
If I remove def f_=(x: String) = b.x = x
from B
extension, it runs successfully with run
in sbt console.
When I then add it back, it runs successfully with run
in sbt console, but fails again on run
after clean
, which is potentially a partial compilation bug.
Expectation
aa