Aladdin - Scala Bugtracking
[#422] project: compiler priority: high category: bug
submitter assigned to status date submitted
Burak Martin fixed 2005-04-22 11:19:45.0
subject wrong type causes crash in ExpandMixin
code
import scala.util.regexp.WordExp;
import scala.util.automata.WordBerrySethi;

object BoolWordExp extends WordExp {
  type _labelT = MyLabels;
  type _regexpT = RegExp;
  abstract class MyLabels extends Label ;
  case class MyLabel(c:Char) extends MyLabels;
}

object MyTranslator extends WordBerrySethi {
  override val lang = BoolWordExp;
  import lang._;
  override protected def seenLabel( r:RegExp, i:Int, label: _labelT ): Unit = {
    super.seenLabel(r,i,label)
  }
}
what happened
I am aware that this is not a small file (the library classes it uses are big), but given that it's not always p\
ossible to decrease sizes and still reproduce these bugs...

Exception in thread "main" scalac.symtab.Type$Malformed: malformed type: WordExp#_labelT
        at scalac.symtab.Type.typeRef(Type.java:215)
        at scalac.symtab.Type$Map.map(Type.java:1184)
        at scalac.symtab.Type$AsSeenFromMap.apply(Type.java:1412)
        at scalac.symtab.Type$Map.map(Type.java:1252)
        at scalac.symtab.Type$Map.map(Type.java:1299)
        at scalac.symtab.Type$Map.map(Type.java:1293)
        at scalac.symtab.Type$Map.map(Type.java:1224)
        at scalac.symtab.Type$AsSeenFromMap.apply(Type.java:1421)
        at scalac.symtab.Type.asSeenFrom(Type.java:1469)
        at scalac.symtab.Type.memberType(Type.java:1487)
        at scalac.symtab.Type$SymbolSearch.getSeenTypeOf(Type.java:1051)
        at scalac.symtab.Type$SymbolSearch.(Type.java:1025)
        at scalac.symtab.Type.lookup(Type.java:879)
        at scalac.symtab.Symbol.overridingSymbol(Symbol.java:1784)
        at scalac.symtab.Symbol.overridingSymbol(Symbol.java:1787)
        at scalac.transformer.ExpandMixinsPhase$ClassTreeExpander.getSuperMember(ExpandMixinsPhase.java:241)
        at scalac.transformer.ExpandMixinsPhase$ClassTreeExpander.transform(ExpandMixinsPhase.java:268)
        at scalac.ast.GenTransformer.transform(Transformer.java:553)
        at scalac.transformer.ExpandMixinsPhase$TreeExpander.transform(ExpandMixinsPhase.java:144)
        at scalac.transformer.ExpandMixinsPhase$ClassTreeExpander.transform(ExpandMixinsPhase.java:274)
        at scalac.ast.GenTransformer.transform(Transformer.java:468)
        at scalac.transformer.ExpandMixinsPhase$TreeExpander.transform(ExpandMixinsPhase.java:144)
        at scalac.transformer.ExpandMixinsPhase$ClassTreeExpander.transform(ExpandMixinsPhase.java:274)
        at scalac.ast.GenTransformer.transform(Transformer.java:596)
        at scalac.transformer.ExpandMixinsPhase.getExpandedBody(ExpandMixinsPhase.java:322)
        at scalac.transformer.ExpandMixinsPhase.access$19(ExpandMixinsPhase.java:53)
        at scalac.transformer.ExpandMixinsPhase$TreeExpander.transform(ExpandMixinsPhase.java:142)
        at scalac.ast.GenTransformer.transform(Transformer.java:596)
        at scalac.ast.GenTransformer.apply(Transformer.java:405)
        at scalac.transformer.ExpandMixinsPhase$TreeExpander.apply(ExpandMixinsPhase.java:134)
        at scalac.transformer.ExpandMixinsPhase.apply(ExpandMixinsPhase.java:97)        at scalac.CompilationLoo\
p.loop(CompilationLoop.java:102)
        at scalac.CompilationLoop.compile(CompilationLoop.java:60)
        at scalac.Global.compile(Global.java:391)
        at scalac.Global.compile(Global.java:366)
        at scala.tools.scalac.Main$.main1(Main.scala:47)
        at scala.tools.scalac.Main$.main(Main.scala:28)
        at scala.tools.scalac.Main.main(Main.scala:28)
what expected This should compile. The problem is somehow caused by the override. I don't see where the type WordExp#_labelT comes from, maybe it's the thing in the superclass WordBerrySethi. It must be possible to write a method seenLabel(.,.,.:_labelT) in an abstract class and then override it with seenLabel(.,.,.:_labelT) where _labelT is now concrete. Am I missing anything here?
[back to overview]
Changes of this bug report
Martin  edited on  2006-05-08 18:42:26.0
No, you did not miss anything. The problem was the supercall which caused a type of the form super.lang.RegExp. The compiler did not realize that this is the same as this.lang.RegExp. This is a bit tricky, because type equality in this case boils down to reasoning when
  this.lang == super.lang
The corrected version assumes this is the case whenever super.lang is either final or abstract. Questions: Do people agree that this is correct? And is it sufficient, or do we need other criteria?