Skip to content

Export statement + ambiguous overload crash compiler #21071

Closed
@kubukoz

Description

@kubukoz

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions