scala / bug

Scala 2 bug reports only. Please, no questions — proper bug reports only.
https://scala-lang.org
232 stars 21 forks source link

AssertionError in TreeGen.mkAttributedQualifier #4970

Closed scabug closed 13 years ago

scabug commented 13 years ago

The following code causes the compiler to crash with AssertionError.

trait OuterClass[V <: OuterClass[V]#InnerClass] {
  trait InnerClass {self: V =>
    def method = ()
  }
}

trait SubOuterClass[T <: SubOuterClass[T]#SubInnerClass] extends OuterClass[T] {
  class SubInnerClass extends super.InnerClass {self: T =>  }
}
>scalac Crash.scala
error: java.lang.AssertionError: assertion failed: jp.seraphr.scala.hello.HelloScala.generics.SubOuterClass[T]
        at scala.tools.nsc.ast.TreeGen.mkAttributedQualifier(TreeGen.scala:66)
        at scala.tools.nsc.ast.TreeGen.mkAttributedQualifier(TreeGen.scala:44)
        at scala.tools.nsc.transform.ExplicitOuter$ExplicitOuterTransformer.mixinOuterAccessorDef(ExplicitOuter.scala:351)
        at scala.tools.nsc.transform.ExplicitOuter$ExplicitOuterTransformer$$anonfun$transform$1$$anonfun$apply$mcV$sp$1.apply(ExplicitOuter.scala:457)
        at scala.tools.nsc.transform.ExplicitOuter$ExplicitOuterTransformer$$anonfun$transform$1$$anonfun$apply$mcV$sp$1.apply(ExplicitOuter.scala:455)
        at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
...
scabug commented 13 years ago

Imported From: https://issues.scala-lang.org/browse/SI-4970?orig=1 Reporter: seraph (seraphr) Affected Versions: 2.9.0-1, 2.9.1

scabug commented 13 years ago

@paulp said: As a workaround, if you declare SubInnerClass's self-type as "self: InnerClass with T => ", it compiles.

scabug commented 13 years ago

Commit Message Bot (anonymous) said: (extempore in r25912) Fix for crasher in explicitouter.

Closes #4970, review by moors.