Skip to content

Generated getters are considered update def #24485

@hamzaremmal

Description

@hamzaremmal

Compiler version

9a8746e

Minimized code

//> using options -Xprint:typer,getters
import scala.language.experimental.captureChecking

trait Foo extends caps.Mutable:
  var x: Int

Output

[[syntax trees at end of                     typer]] // test.scala
package <empty> {
  import scala.language.experimental.captureChecking
  trait Foo() extends Object, caps.Mutable {
    var x: Int
    update def x_=(x$1: Int): Unit
  }
}
[[syntax trees at end of MegaPhase{pruneErasedDefs, uninitialized, inlinePatterns, vcInlineMethods, seqLiterals, intercepted, getters, specializeFunctions, specializeTuples, collectNullableFields, elimOuterSelect, resolveSuper, functionXXLForwarders, paramForwarding, genericTuples, letOverApply, arrayConstructors}]] // test.scala
package <empty> {
  import scala.language.experimental.captureChecking
  @SourceFile("test.scala") trait Foo() extends Object, scala.caps.Mutable {
    update def x: Int
    update def x_=(x$1: Int): Unit
  }
}

Expectation

The generated getter should not pass the Mutability.isUpdateMethod since it should not be an update method. This would be a big restriction if the getter is an update def.

Note

This does not affect cc since we generate the getter after all the cc phases. The point of this issue is to prevent in the future from a bad usage of Mutability.isUpdateMethod in the compiler's code base and for correctness.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions