Skip to content

Early definition with private[this] val crashes scalac #6309

Closed
@scabug

Description

@scabug

Sorry in advance if this is disallowed, but the following crashes when the field is object-private:

package eyeshadow

trait A {
  def a: Int
}

object Test {
  def f(a: Int) = new {
    //private val b = a
    private[this] val b = a // crashes, sorry scalac
  } with A {
    def a = b
  }

  def main(args: Array[String]) {
    println(f(7).a)
  }
}

There is a failed assert
at scala.tools.nsc.transform.Constructors$ConstructorTransformer$$anonfun$transformClassTemplate$1.apply(Constructors.scala:160)
or
assert(fields.length == 1)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions