Skip to content

Spurious error creating anonymous class with mutable field #13

@lrytz

Description

@lrytz
class E {
  val c = new { var x = 0 }
}

gives

T.scala:47: error: type mismatch;
 found   : AnyRef{def x: Int @scala.annotation.effects.mod @scala.annotation.effects.throws[Nothing] @scala.annotation.effects.noIo; def x_=(x$1: Int): Unit @scala.annotation.effects.mod($anon.this) @scala.annotation.effects.throws[Nothing] @scala.annotation.effects.noIo; var x: Int}
 required: AnyRef{def x: Int @scala.annotation.effects.mod @scala.annotation.effects.throws[Nothing] @scala.annotation.effects.noIo; def x_=(x$1: Int): Unit @scala.annotation.effects.mod($anon.this) @scala.annotation.effects.throws[Nothing] @scala.annotation.effects.noIo}
Type error occured while type checking a tree for effect inference.
  val c = new { var x = 0 }
          ^

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions