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

Regression: Compiler crashes when overriding method returning context function #14999

Closed
abosshard opened this issue Apr 21, 2022 · 3 comments · Fixed by #15092
Closed

Regression: Compiler crashes when overriding method returning context function #14999

abosshard opened this issue Apr 21, 2022 · 3 comments · Fixed by #15092
Assignees
Labels
area:typer itype:crash regression This worked in a previous version but doesn't anymore
Milestone

Comments

@abosshard
Copy link

Compiler version

3.1.2

Minimized code

trait Foo:
   def foo: String ?=> Int =
      0

trait Bar extends Foo:
   override def foo =
      super.foo

class Baz extends Bar

Any of the following changes will avoid the crash:

  • use normal function instead of context function
  • do not override foo
  • return 0 instead of calling super.foo
  • remove class Baz
  • make Baz a trait

Output (click arrow to expand)

exception while typing def Bar$$super$foo: (String) ?=> Int = super[Foo].foo of class class dotty.tools.dotc.ast.Trees$DefDef # -1
exception while typing @SourceFile("Foo.scala") class Baz() extends Object(), Bar {
  def Bar$$super$foo: (String) ?=> Int = super[Foo].foo
} of class class dotty.tools.dotc.ast.Trees$TypeDef # -1
exception while typing package <empty> {
  @SourceFile("Foo.scala") trait Foo() extends Object {
    @ContextResultCount(1) def foo: (String) ?=> Int = 
      {
        def $anonfun(using evidence$1: String): Int = 0
        closure($anonfun)
      }
  }
  @SourceFile("Foo.scala") trait Bar() extends Object, Foo {
    def Bar$$super$foo: (String) ?=> Int
    @ContextResultCount(1) override def foo: (String) ?=> Int = 
      {
        def $anonfun(using evidence$2: String): Int = 
          this.Bar$$super$foo.apply(evidence$2)
        closure($anonfun)
      }
  }
  @SourceFile("Foo.scala") class Baz() extends Object(), Bar {
    def Bar$$super$foo: (String) ?=> Int = super[Foo].foo
  }
} of class class dotty.tools.dotc.ast.Trees$PackageDef # -1
exception occurred while compiling Foo.scala
java.lang.AssertionError: assertion failed while compiling Foo.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:387)
        at dotty.tools.dotc.transform.Erasure$Typer.adapt(Erasure.scala:1042)
        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)
@abosshard abosshard added itype:bug itype:crash stat:needs triage Every issue needs to have an "area" and "itype" label labels Apr 21, 2022
@Kordyjan Kordyjan changed the title Compiler crashes when overriding method returning context function Regression: Compiler crashes when overriding method returning context function Apr 22, 2022
@Kordyjan

This comment was marked as outdated.

@Kordyjan Kordyjan added area:typer regression This worked in a previous version but doesn't anymore and removed itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Apr 22, 2022
@Kordyjan
Copy link
Contributor

After bisecting the nightlies I determined that the change was introduced between 3.1.2-RC1-bin-20211102-82172ed-NIGHTLY and 3.1.2-RC1-bin-20211112-4025951-NIGHTLY (weird that we did not publish nightlies for 10 days).

It may be the fault of #13736.

If that's not it, here is the output of git log 82172ed..4025951 --merges --oneline:

4025951220 Merge pull request #13909 from dotty-staging/scaladoc/too-implicit-classes
9794737c76 Merge pull request #13908 from dotty-staging/scaladoc/root-content-pos
e23f815704 Merge pull request #13911 from dwijnand/fix-leaky-tryImplicits
f836589707 Merge pull request #13736 from dotty-staging/fix-13691-v2
aa25df2523 Merge pull request #13886 from dotty-staging/fix-13838
5ce25fe758 Merge pull request #13782 from etorreborre/master
4ad416fc31 Merge pull request #13872 from dotty-staging/fix-#13871
045c8bddaf Merge pull request #13866 from dotty-staging/fix-13846
ae0f8281b0 Merge pull request #13729 from dotty-staging/wip-expnull-library
7da659ba38 Merge pull request #13898 from danicheg/dead-links
add58e9230 Merge pull request #13894 from dotty-staging/fix-13893
673698d25e Merge pull request #13881 from dotty-staging/fix-13820
e7cbbd6ad9 Merge pull request #13883 from dotty-staging/set-untyped-to-nothing
483bf2cecd Merge pull request #13879 from dotty-staging/fix-13873
83effc3601 Merge pull request #13792 from dwijnand/lint-too-big-constants-pr
fa56a4e068 Merge pull request #13779 from dotty-staging/constrain-finalResultType-2
9153fe5f29 Merge pull request #13742 from dotty-staging/less-constrainResult
8ee672c919 Merge pull request #13791 from michelou/dotty-test-ioexception
0a8520717a Merge pull request #13709 from SethTisue/issue-9880

@griggt
Copy link
Collaborator

griggt commented Apr 23, 2022

Further bisection confirms it regressed in #13736

odersky added a commit to dotty-staging/dotty that referenced this issue May 3, 2022
bishabosha pushed a commit to dotty-staging/dotty that referenced this issue Oct 18, 2022
@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
Labels
area:typer itype:crash regression This worked in a previous version but doesn't anymore
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants