Skip to content

PolyMethod in refinement of Selectable #15065

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
prolativ opened this issue Apr 28, 2022 · 0 comments · Fixed by #15090
Closed

PolyMethod in refinement of Selectable #15065

prolativ opened this issue Apr 28, 2022 · 0 comments · Fixed by #15090

Comments

@prolativ
Copy link
Contributor

Compiler version

3.1.2
Crashes for 3.0.0 and 3.2.0-RC1-bin-20220427-b1f00a7-NIGHTLY as well

Minimized code

trait Foo extends Selectable

val foo = new Foo:
  def bar[A](): Int = ???

val x = foo.bar()

Output (click arrow to expand)

exception while typing foo.bar of class class dotty.tools.dotc.ast.Trees$Select # -1
exception while typing foo.bar[Any] of class class dotty.tools.dotc.ast.Trees$TypeApply # -1
exception while typing foo.bar[Any]() of class class dotty.tools.dotc.ast.Trees$Apply # -1
exception while typing def x: Int = foo.bar[Any]() of class class dotty.tools.dotc.ast.Trees$DefDef # -1
exception while typing @SourceFile("/tmp/RefinementCrash.scala") final module class 
  RefinementCrash$package
() extends Object() {
  private def writeReplace(): AnyRef = 
    new scala.runtime.ModuleSerializationProxy(
      classOf[RefinementCrash$package.type]
    )
  def foo: Foo{bar[A](): Int} = 
    {
      final class $anon() extends Object(), Foo {
        def bar[A](): Int = ???
      }
      new Object with Foo {...}():Foo{bar[A](): Int}
    }
  def x: Int = foo.bar[Any]()
} of class class dotty.tools.dotc.ast.Trees$TypeDef # -1
exception while typing package <empty> {
  @SourceFile("/tmp/RefinementCrash.scala") trait Foo() extends Object, 
    Selectable
   {}
  final lazy module val RefinementCrash$package: RefinementCrash$package = 
    new RefinementCrash$package()
  @SourceFile("/tmp/RefinementCrash.scala") final module class 
    RefinementCrash$package
  () extends Object() {
    private def writeReplace(): AnyRef = 
      new scala.runtime.ModuleSerializationProxy(
        classOf[RefinementCrash$package.type]
      )
    def foo: Foo{bar[A](): Int} = 
      {
        final class $anon() extends Object(), Foo {
          def bar[A](): Int = ???
        }
        new Object with Foo {...}():Foo{bar[A](): Int}
      }
    def x: Int = foo.bar[Any]()
  }
} of class class dotty.tools.dotc.ast.Trees$PackageDef # -1
exception occurred while compiling /tmp/RefinementCrash.scala
java.lang.AssertionError: assertion failed: no owner from  <none>/ <none> in foo.bar while compiling /tmp/RefinementCrash.scala
Exception in thread "main" java.lang.AssertionError: assertion failed: no owner from  <none>/ <none> in foo.bar
        at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
        at dotty.tools.dotc.transform.Erasure$Typer.typedSelect(Erasure.scala:698)
        at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2779)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2871)
        at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:121)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2937)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2941)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3057)
        at dotty.tools.dotc.transform.Erasure$Typer.typedTypeApply(Erasure.scala:792)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2828)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2872)
        at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:121)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2937)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2941)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3057)
        at dotty.tools.dotc.transform.Erasure$Typer.typedApply(Erasure.scala:814)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2809)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2872)
        at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:121)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2937)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2941)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3057)
        at dotty.tools.dotc.typer.Typer.$anonfun$47(Typer.scala:2256)
        at dotty.tools.dotc.typer.PrepareInlineable$.dropInlineIfError(PrepareInlineable.scala:238)
        at dotty.tools.dotc.typer.Typer.typedDefDef(Typer.scala:2256)
        at dotty.tools.dotc.transform.Erasure$Typer.typedDefDef(Erasure.scala:932)
        at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2786)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2871)
        at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:121)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2937)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2941)
        at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2963)
        at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3013)
        at dotty.tools.dotc.transform.Erasure$Typer.typedStats(Erasure.scala:1030)
        at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:2454)
        at dotty.tools.dotc.transform.Erasure$Typer.typedClassDef(Erasure.scala:1020)
        at dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$1(Typer.scala:2797)
        at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2801)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2871)
        at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:121)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2937)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2941)
        at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2963)
        at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3013)
        at dotty.tools.dotc.transform.Erasure$Typer.typedStats(Erasure.scala:1030)
        at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:2581)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2842)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2872)
        at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:121)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2937)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2941)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3057)
        at dotty.tools.dotc.transform.Erasure.run(Erasure.scala:144)
        at dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:308)
        at scala.collection.immutable.List.map(List.scala:246)
        at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:309)
        at dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:259)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1328)
        at dotty.tools.dotc.Run.runPhases$1(Run.scala:270)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:278)
        at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
        at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:68)
        at dotty.tools.dotc.Run.compileUnits(Run.scala:287)
        at dotty.tools.dotc.Run.compileSources(Run.scala:220)
        at dotty.tools.dotc.Run.compile(Run.scala:204)
        at dotty.tools.dotc.Driver.doCompile(Driver.scala:39)
        at dotty.tools.dotc.Driver.process(Driver.scala:199)
        at dotty.tools.dotc.Driver.process(Driver.scala:167)
        at dotty.tools.dotc.Driver.process(Driver.scala:179)
        at dotty.tools.dotc.Driver.main(Driver.scala:209)
        at dotty.tools.dotc.Main.main(Main.scala)
odersky added a commit to dotty-staging/dotty that referenced this issue May 3, 2022
Fixes scala#15065

We always intended to reject them, but crashed before we got to that point.
bishabosha pushed a commit to dotty-staging/dotty that referenced this issue Oct 18, 2022
Fixes scala#15065

We always intended to reject them, but crashed before we got to that point.
@Kordyjan Kordyjan added this to the 3.2.0 milestone Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants