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

Export statement + ambiguous overload crash compiler #21071

Closed
kubukoz opened this issue Jul 5, 2024 · 0 comments · Fixed by #21518
Closed

Export statement + ambiguous overload crash compiler #21071

kubukoz opened this issue Jul 5, 2024 · 0 comments · Fixed by #21518

Comments

@kubukoz
Copy link
Contributor

kubukoz commented Jul 5, 2024

Compiler version

3.5.0-RC2, 3.4.2

Minimized code

//> using scala 3.5.0-RC2

trait Service {
  def method: String
}

object MySuite {
  def foo(a: List[String]) = ???
  def foo(a: String) = ???

  foo {

    new Service {
      private val underlying: Service = ???

      export underlying.*
    }

    ???
  }
}

Output (click arrow to expand)

  exception occurred while typechecking /Users/kubukoz/projects/demos/demo.scala

  An unhandled exception was thrown in the compiler.
  Please file a crash report here:
  https://github.com/scala/scala3/issues/new/choose
  For non-enriched exceptions, compile with -Xno-enrich-error-messages.

     while compiling: /Users/kubukoz/projects/demos/demo.scala
        during phase: typer
                mode: Mode(ImplicitsEnabled)
     library version: version 2.13.12
    compiler version: version 3.5.0-RC2
            settings: -classpath /Users/kubukoz/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala3-library_3/3.5.0-RC2/scala3-library_3-3.5.0-RC2.jar:/Users/kubukoz/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.12/scala-library-2.13.12.jar -d /Users/kubukoz/projects/demos/.scala-build/demos_38596ea22f/classes/main -java-output-version 17 -sourceroot /Users/kubukoz/projects/demos

Exception in thread "main" java.lang.AssertionError: assertion failed: duplicate attachment for key dotty.tools.dotc.util.Property$Key@48a2db72
	at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
	at dotty.tools.dotc.util.Attachment$Container.pushAttachment(Attachment.scala:121)
	at dotty.tools.dotc.util.Attachment$Container.pushAttachment$(Attachment.scala:102)
	at dotty.tools.dotc.ast.Trees$Tree.pushAttachment(Trees.scala:52)
	at dotty.tools.dotc.typer.Namer$ClassCompleter.exportForwarders(Namer.scala:1437)
	at dotty.tools.dotc.typer.Namer$ClassCompleter.processExport$1(Namer.scala:1445)
	at dotty.tools.dotc.typer.Namer$ClassCompleter.process$1(Namer.scala:1467)
	at dotty.tools.dotc.typer.Namer$ClassCompleter.processExports(Namer.scala:1488)
	at dotty.tools.dotc.typer.Namer$ClassCompleter.completeInCreationContext(Namer.scala:1712)
	at dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:850)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:175)
	at dotty.tools.dotc.core.Denotations$Denotation.completeInfo$1(Denotations.scala:190)
	at dotty.tools.dotc.core.Denotations$Denotation.info(Denotations.scala:192)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:393)
	at dotty.tools.dotc.typer.Typer.retrieveSym(Typer.scala:3346)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3371)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3483)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3561)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3565)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3587)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3633)
	at dotty.tools.dotc.typer.Typer.typedBlockStats(Typer.scala:1377)
	at dotty.tools.dotc.typer.Typer.typedBlock(Typer.scala:1381)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3407)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3484)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3561)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3565)
	at dotty.tools.dotc.typer.Typer.typedNew(Typer.scala:1099)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3403)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3484)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3561)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3565)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3614)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3633)
	at dotty.tools.dotc.typer.Typer.typedBlockStats(Typer.scala:1377)
	at dotty.tools.dotc.typer.Typer.typedBlock(Typer.scala:1381)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3407)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3484)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3561)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3565)
	at dotty.tools.dotc.typer.ProtoTypes$FunProto.$anonfun$3$$anonfun$1(ProtoTypes.scala:466)
	at dotty.tools.dotc.typer.ProtoTypes$FunProto.cacheTypedArg(ProtoTypes.scala:435)
	at dotty.tools.dotc.typer.ProtoTypes$FunProto.$anonfun$3(ProtoTypes.scala:466)
	at dotty.tools.dotc.typer.ProtoTypes$FunProto.$anonfun$adapted$1(ProtoTypes.scala:465)
	at dotty.tools.dotc.core.Decorators$.loop$3(Decorators.scala:186)
	at dotty.tools.dotc.core.Decorators$.mapWithIndexConserve(Decorators.scala:193)
	at dotty.tools.dotc.typer.ProtoTypes$FunProto.typedArgs(ProtoTypes.scala:465)
	at dotty.tools.dotc.typer.Applications.resolveOverloaded1(Applications.scala:2262)
	at dotty.tools.dotc.typer.Applications.resolve$1(Applications.scala:2092)
	at dotty.tools.dotc.typer.Applications.resolveOverloaded(Applications.scala:2133)
	at dotty.tools.dotc.typer.Applications.resolveOverloaded$(Applications.scala:434)
	at dotty.tools.dotc.typer.Typer.resolveOverloaded(Typer.scala:145)
	at dotty.tools.dotc.typer.Typer.adaptOverloaded$1(Typer.scala:3980)
	at dotty.tools.dotc.typer.Typer.adapt1(Typer.scala:4639)
	at dotty.tools.dotc.typer.Typer.adapt(Typer.scala:3939)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3561)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3565)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3676)
	at dotty.tools.dotc.typer.Applications.realApply$1(Applications.scala:1040)
	at dotty.tools.dotc.typer.Applications.typedApply(Applications.scala:1231)
	at dotty.tools.dotc.typer.Applications.typedApply$(Applications.scala:434)
	at dotty.tools.dotc.typer.Typer.typedApply(Typer.scala:145)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3399)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3484)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3561)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3565)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3614)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3633)
	at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:3081)
	at dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$1(Typer.scala:3387)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3391)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3483)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3561)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3565)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3587)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3633)
	at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:3214)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3433)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3484)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3561)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3565)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3676)
	at dotty.tools.dotc.typer.TyperPhase.typeCheck$$anonfun$1(TyperPhase.scala:47)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at dotty.tools.dotc.core.Phases$Phase.monitor(Phases.scala:503)
	at dotty.tools.dotc.typer.TyperPhase.typeCheck(TyperPhase.scala:53)
	at dotty.tools.dotc.typer.TyperPhase.$anonfun$4(TyperPhase.scala:99)
	at scala.collection.Iterator$$anon$6.hasNext(Iterator.scala:479)
	at scala.collection.Iterator$$anon$9.hasNext(Iterator.scala:583)
	at scala.collection.immutable.List.prependedAll(List.scala:152)
	at scala.collection.immutable.List$.from(List.scala:684)
	at scala.collection.immutable.List$.from(List.scala:681)
	at scala.collection.IterableOps$WithFilter.map(Iterable.scala:898)
	at dotty.tools.dotc.typer.TyperPhase.runOn(TyperPhase.scala:98)
	at dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:343)
	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:1323)
	at dotty.tools.dotc.Run.runPhases$1(Run.scala:336)
	at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:384)
	at dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:396)
	at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:69)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:396)
	at dotty.tools.dotc.Run.compileSources(Run.scala:282)
	at dotty.tools.dotc.Run.compile(Run.scala:267)
	at dotty.tools.dotc.Driver.doCompile(Driver.scala:37)
	at dotty.tools.dotc.Driver.process(Driver.scala:201)
	at dotty.tools.dotc.Driver.process(Driver.scala:169)
	at dotty.tools.dotc.Driver.process(Driver.scala:181)
	at dotty.tools.dotc.Driver.main(Driver.scala:211)
	at dotty.tools.dotc.Main.main(Main.scala)
Compilation failed
@kubukoz kubukoz added itype:bug itype:crash stat:needs triage Every issue needs to have an "area" and "itype" label labels Jul 5, 2024
@Gedochao Gedochao added area:typer area:export and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Jul 8, 2024
wjoel added a commit to wjoel/scala3 that referenced this issue Aug 30, 2024
exportForwarders can be called more than once for the same expression
if there are ambiguous overloads.

Closes scala#21071
wjoel added a commit to wjoel/scala3 that referenced this issue Sep 3, 2024
exportForwarders can be called more than once for the same expression
if there are ambiguous overloads.

Closes scala#21071
wjoel added a commit to wjoel/scala3 that referenced this issue Sep 3, 2024
exportForwarders can be called more than once for the same expression
if there are ambiguous overloads.

Closes scala#21071
@sjrd sjrd closed this as completed in 634fcd1 Sep 3, 2024
sjrd added a commit that referenced this issue Sep 3, 2024
…21518)

exportForwarders can be called more than once for the same expression if
there are ambiguous overloads.

Closes #21071
@kubukoz kubukoz changed the title Export statement + ambiguous workload crash compiler Export statement + ambiguous overload crash compiler Sep 4, 2024
@WojciechMazur WojciechMazur added this to the 3.6.0 milestone Oct 8, 2024
WojciechMazur pushed a commit that referenced this issue Dec 3, 2024
exportForwarders can be called more than once for the same expression
if there are ambiguous overloads.

Just return the already computed ExportForwarders if that happens.

Closes #21071

[Cherry-picked 634fcd1]
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