Skip to content
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

Compiler crash using -coverage-out with polymorphic extension methods #15705

Closed
griggt opened this issue Jul 19, 2022 · 0 comments · Fixed by #15739
Closed

Compiler crash using -coverage-out with polymorphic extension methods #15705

griggt opened this issue Jul 19, 2022 · 0 comments · Fixed by #15739
Assignees
Labels
area:coverage Code coverage, see https://dotty.epfl.ch/docs/internals/coverage.html itype:bug itype:crash
Milestone

Comments

@griggt
Copy link
Contributor

griggt commented Jul 19, 2022

Compiler version

3.2.0-RC2
3.2.1-RC1-bin-20220717-5c43324-NIGHTLY
fa93159 from #15648

Minimized code

extension (r: AnyRef)
  def foo[A](x: String): A = ???
  def bar[A](x: String): A = foo(x)

Output (click arrow to expand)

scalac -coverage-out:. test.scala
exception while typing {
  scala.runtime.coverage.Invoker.invoked(1, ".")
  foo(r)
} of class class dotty.tools.dotc.ast.Trees$Block # -1
exception while typing {
  scala.runtime.coverage.Invoker.invoked(1, ".")
  foo(r)
}[Nothing] of class class dotty.tools.dotc.ast.Trees$TypeApply # -1
exception while typing {
  scala.runtime.coverage.Invoker.invoked(1, ".")
  foo(r)
}[Nothing](x) of class class dotty.tools.dotc.ast.Trees$Apply # -1
exception while typing {
  scala.runtime.coverage.Invoker.invoked(2, ".")
  {
    scala.runtime.coverage.Invoker.invoked(1, ".")
    foo(r)
  }[Nothing](x)
} of class class dotty.tools.dotc.ast.Trees$Block # -1
exception while typing {
  scala.runtime.coverage.Invoker.invoked(3, ".")
  {
    scala.runtime.coverage.Invoker.invoked(2, ".")
    {
      scala.runtime.coverage.Invoker.invoked(1, ".")
      foo(r)
    }[Nothing](x)
  }
} of class class dotty.tools.dotc.ast.Trees$Block # -1
exception while typing extension (r: AnyRef) def bar[A](x: String): A = 
  {
    scala.runtime.coverage.Invoker.invoked(3, ".")
    {
      scala.runtime.coverage.Invoker.invoked(2, ".")
      {
        scala.runtime.coverage.Invoker.invoked(1, ".")
        foo(r)
      }[Nothing](x)
    }
  } of class class dotty.tools.dotc.ast.Trees$DefDef # -1
exception while typing @SourceFile("test.scala") final module class test$package() extends Object() {
  private def writeReplace(): AnyRef = 
    new scala.runtime.ModuleSerializationProxy(classOf[test$package.type])
  extension (r: AnyRef) def foo[A](x: String): A = 
    {
      scala.runtime.coverage.Invoker.invoked(0, ".")
      ???
    }
  extension (r: AnyRef) def bar[A](x: String): A = 
    {
      scala.runtime.coverage.Invoker.invoked(3, ".")
      {
        scala.runtime.coverage.Invoker.invoked(2, ".")
        {
          scala.runtime.coverage.Invoker.invoked(1, ".")
          foo(r)
        }[Nothing](x)
      }
    }
} of class class dotty.tools.dotc.ast.Trees$TypeDef # -1
exception while typing package <empty> {
  final lazy module val test$package: test$package = new test$package()
  @SourceFile("test.scala") final module class test$package() extends Object() {
    private def writeReplace(): AnyRef = 
      new scala.runtime.ModuleSerializationProxy(classOf[test$package.type])
    extension (r: AnyRef) def foo[A](x: String): A = 
      {
        scala.runtime.coverage.Invoker.invoked(0, ".")
        ???
      }
    extension (r: AnyRef) def bar[A](x: String): A = 
      {
        scala.runtime.coverage.Invoker.invoked(3, ".")
        {
          scala.runtime.coverage.Invoker.invoked(2, ".")
          {
            scala.runtime.coverage.Invoker.invoked(1, ".")
            foo(r)
          }[Nothing](x)
        }
      }
  }
} of class class dotty.tools.dotc.ast.Trees$PackageDef # -1
exception occurred while compiling test.scala
java.lang.AssertionError: assertion failed while compiling test.scala
Exception in thread "main" java.lang.AssertionError: assertion failed
	at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:11)
	at dotty.tools.dotc.transform.Erasure$Boxing$.adaptToType(Erasure.scala:388)
	at dotty.tools.dotc.transform.Erasure$Typer.adapt(Erasure.scala:1053)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2987)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2991)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3107)
	at dotty.tools.dotc.typer.Typer.typedBlock(Typer.scala:1062)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2867)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2922)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:126)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2987)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2991)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3107)
	at dotty.tools.dotc.transform.Erasure$Typer.typedTypeApply(Erasure.scala:807)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2878)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2922)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:126)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2987)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2991)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3107)
	at dotty.tools.dotc.transform.Erasure$Typer.typedApply(Erasure.scala:826)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2859)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2922)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:126)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2987)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2991)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3107)
	at dotty.tools.dotc.typer.Typer.typedBlock(Typer.scala:1062)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2867)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2922)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:126)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2987)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2991)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3107)
	at dotty.tools.dotc.typer.Typer.typedBlock(Typer.scala:1062)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2867)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2922)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:126)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2987)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2991)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3107)
	at dotty.tools.dotc.typer.Typer.$anonfun$48(Typer.scala:2295)
	at dotty.tools.dotc.typer.PrepareInlineable$.dropInlineIfError(PrepareInlineable.scala:248)
	at dotty.tools.dotc.typer.Typer.typedDefDef(Typer.scala:2295)
	at dotty.tools.dotc.transform.Erasure$Typer.typedDefDef(Erasure.scala:943)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2835)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2921)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:126)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2987)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2991)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3013)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3063)
	at dotty.tools.dotc.transform.Erasure$Typer.typedStats(Erasure.scala:1041)
	at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:2500)
	at dotty.tools.dotc.transform.Erasure$Typer.typedClassDef(Erasure.scala:1031)
	at dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$1(Typer.scala:2847)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2851)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2921)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:126)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2987)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2991)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3013)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3063)
	at dotty.tools.dotc.transform.Erasure$Typer.typedStats(Erasure.scala:1041)
	at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:2629)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2892)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2922)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:126)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2987)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2991)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3107)
	at dotty.tools.dotc.transform.Erasure.run(Erasure.scala:144)
	at dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:311)
	at scala.collection.immutable.List.map(List.scala:246)
	at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:312)
	at dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:234)
	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:245)
	at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:253)
	at dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:262)
	at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:68)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:262)
	at dotty.tools.dotc.Run.compileSources(Run.scala:186)
	at dotty.tools.dotc.Run.compile(Run.scala:170)
	at dotty.tools.dotc.Driver.doCompile(Driver.scala:35)
	at dotty.tools.dotc.Driver.process(Driver.scala:195)
	at dotty.tools.dotc.Driver.process(Driver.scala:163)
	at dotty.tools.dotc.Driver.process(Driver.scala:175)
	at dotty.tools.dotc.Driver.main(Driver.scala:205)
	at dotty.tools.dotc.Main.main(Main.scala)

/cc @TheElectronWill

@griggt griggt added itype:bug itype:crash stat:needs triage Every issue needs to have an "area" and "itype" label area:coverage Code coverage, see https://dotty.epfl.ch/docs/internals/coverage.html labels Jul 19, 2022
@TheElectronWill TheElectronWill removed the stat:needs triage Every issue needs to have an "area" and "itype" label label Jul 19, 2022
@TheElectronWill TheElectronWill self-assigned this Jul 19, 2022
bishabosha pushed a commit to dotty-staging/dotty that referenced this issue Oct 18, 2022
@Kordyjan Kordyjan added this to the 3.2.1 milestone Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:coverage Code coverage, see https://dotty.epfl.ch/docs/internals/coverage.html itype:bug itype:crash
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants