Skip to content

Using an inline method that has a super crashes the compiler #2901

Closed
@nicolasstucki

Description

@nicolasstucki
trait Foo {
  def foo = 4
}
object Bar extends Foo {
  inline def bar = super[Foo].foo
}
object Main {
  Bar.bar
}

crashes with

-- [E081] Syntax Error: Foo.scala:7:19 -----------------------------------------
7 |  inline def bar = super[Foo].foo
  |                   ^^^^^^^^^^
  |                   super call not allowed in inline method bar

Exception in thread "main" java.lang.ClassCastException: dotty.tools.dotc.core.Symbols$Symbol cannot be cast to dotty.tools.dotc.core.Symbols$ClassSymbol
        at dotty.tools.dotc.core.Symbols$Symbol.asClass(Symbols.scala:435)
        at dotty.tools.dotc.transform.SuperAccessors.transformSuperSelect(SuperAccessors.scala:104)
        at dotty.tools.dotc.transform.SuperAccessors.transformSelect(SuperAccessors.scala:386)
        at dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transformSelect(PostTyper.scala:130)
        at dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform(PostTyper.scala:183)
        at dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform(PostTyper.scala:213)
        at dotty.tools.dotc.transform.MacroTransform$Transformer.dotty$tools$dotc$transform$MacroTransform$Transformer$$transformStat$1(MacroTransform.scala:45)
        at dotty.tools.dotc.transform.MacroTransform$Transformer$$anonfun$transformStats$1.apply(MacroTransform.scala:47)
        at dotty.tools.dotc.transform.MacroTransform$Transformer$$anonfun$transformStats$1.apply(MacroTransform.scala:47)
        at dotty.tools.dotc.core.Decorators$ListDecorator$.loop$1(Decorators.scala:62)
        at dotty.tools.dotc.core.Decorators$ListDecorator$.mapconserve$extension(Decorators.scala:78)
        at dotty.tools.dotc.transform.MacroTransform$Transformer.transformStats(MacroTransform.scala:47)
        at dotty.tools.dotc.transform.MacroTransform$Transformer.transform(MacroTransform.scala:61)
        at dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.dotty$tools$dotc$transform$PostTyper$PostTyperTransformer$$super$transform(PostTyper.scala:221)
        at dotty.tools.dotc.transform.PostTyper$PostTyperTransformer$$anonfun$transform$3.apply(PostTyper.scala:221)
        at dotty.tools.dotc.transform.PostTyper$PostTyperTransformer$$anonfun$transform$3.apply(PostTyper.scala:221)
        at dotty.tools.dotc.transform.SuperAccessors.wrapTemplate(SuperAccessors.scala:410)
        at dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform(PostTyper.scala:220)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1195)
        at dotty.tools.dotc.transform.MacroTransform$Transformer.transform(MacroTransform.scala:55)
        at dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform(PostTyper.scala:246)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap$$anonfun$transform$2.apply(Trees.scala:1215)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap$$anonfun$transform$2.apply(Trees.scala:1215)
        at scala.collection.immutable.List.loop$1(List.scala:176)
        at scala.collection.immutable.List.mapConserve(List.scala:200)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1215)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transformStats(Trees.scala:1213)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1201)
        at dotty.tools.dotc.transform.MacroTransform$Transformer.transform(MacroTransform.scala:55)
        at dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform(PostTyper.scala:282)
        at dotty.tools.dotc.transform.MacroTransform.run(MacroTransform.scala:22)
        at dotty.tools.dotc.core.Phases$Phase$$anonfun$runOn$1.apply(Phases.scala:283)
        at dotty.tools.dotc.core.Phases$Phase$$anonfun$runOn$1.apply(Phases.scala:281)
        at scala.collection.immutable.List.map(List.scala:284)
        at dotty.tools.dotc.core.Phases$Phase$class.runOn(Phases.scala:281)
        at dotty.tools.dotc.transform.MacroTransform.runOn(MacroTransform.scala:16)
        at dotty.tools.dotc.Run$$anonfun$compileUnits$1$$anonfun$apply$mcV$sp$1.apply(Run.scala:82)
        at dotty.tools.dotc.Run$$anonfun$compileUnits$1$$anonfun$apply$mcV$sp$1.apply(Run.scala:79)
        at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:33)
        at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:186)
        at dotty.tools.dotc.Run$$anonfun$compileUnits$1.apply$mcV$sp(Run.scala:79)
        at dotty.tools.dotc.Run$$anonfun$compileUnits$1.apply(Run.scala:67)
        at dotty.tools.dotc.Run$$anonfun$compileUnits$1.apply(Run.scala:67)
        at dotty.tools.dotc.util.Stats$.monitorHeartBeat(Stats.scala:76)
        at dotty.tools.dotc.Run.compileUnits(Run.scala:67)
        at dotty.tools.dotc.Run.compileSources(Run.scala:64)
        at dotty.tools.dotc.Run.compile(Run.scala:48)
        at dotty.tools.dotc.Driver.doCompile(Driver.scala:26)
        at dotty.tools.dotc.Driver.process(Driver.scala:124)
        at dotty.tools.dotc.Driver.process(Driver.scala:93)
        at dotty.tools.dotc.Driver.process(Driver.scala:105)
        at dotty.tools.dotc.Driver.main(Driver.scala:132)
        at dotty.tools.dotc.Main.main(Main.scala)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions