Skip to content

Crash when type alias has extension method with the same name as the underlying type #23666

@kidmeal

Description

@kidmeal

Compiler version

 library version: version 2.13.16
 compiler version: version 3.7.2

Minimized code

type Tuple = scala.Tuple
type Any = scala.Any

infix type =:= [A, B] = A => B

object `=:=` :
   given [A] => A =:= A = a => a

extension [T <: Tuple] (tuple: T)

   def reverse[A, B](using ev: T =:= (A, B)): (B, A) = 
      val ab = ev(tuple)
      (ab._2, ab._1)

Scastie

https://scastie.scala-lang.org/XjhtQpksS9ucWxPcF7ermA

Output (click arrow to expand)

+ scalac test.scala

unhandled exception while running MegaPhase{crossVersionChecks, firstTransform, checkReentrant, elimPackagePrefixes, cookComments, checkLoopingImplicits, betaReduce, inlineVals, expandSAMs, elimRepeated, refchecks, dropForMap} on test.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: test.scala
during phase: MegaPhase{crossVersionChecks, firstTransform, checkReentrant, elimPackagePrefixes, cookComments, checkLoopingImplicits, betaReduce, inlineVals, expandSAMs, elimRepeated, refchecks, dropForMap}
mode: Mode(ImplicitsEnabled)
library version: version 2.13.16
compiler version: version 3.7.2
settings:

Exception in thread "main" java.lang.AssertionError: assertion failed: TypeAlias(TypeRef(TermRef(ThisType(TypeRef(NoPrefix,moduleclass <root>)),object scala),trait Tuple))
at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
at dotty.tools.dotc.core.Types$TypeBounds.<init>(Types.scala:5641)
at dotty.tools.dotc.core.Types$RealTypeBounds.<init>(Types.scala:5718)
at dotty.tools.dotc.core.Types$TypeBounds$.apply(Types.scala:5759)
at dotty.tools.dotc.core.Types$TypeBounds.derivedTypeBounds(Types.scala:5649)
at dotty.tools.dotc.core.Types$ApproximatingTypeMap.derivedTypeBounds(Types.scala:6626)
at dotty.tools.dotc.core.Types$TypeMap.mapOver(Types.scala:6345)
at dotty.tools.dotc.core.TypeOps$AsSeenFromMap.apply(TypeOps.scala:112)
at dotty.tools.dotc.core.TypeOps$AsSeenFromMap.apply(TypeOps.scala:70)
at scala.collection.immutable.List.mapConserve(List.scala:473)
at dotty.tools.dotc.core.Types$TypeMap.mapOverLambda(Types.scala:6250)
at dotty.tools.dotc.core.TypeOps$AsSeenFromMap.apply(TypeOps.scala:106)
at dotty.tools.dotc.core.TypeOps$.asSeenFrom(TypeOps.scala:56)
at dotty.tools.dotc.core.Types$Type.asSeenFrom(Types.scala:1154)
at dotty.tools.dotc.core.Denotations$SingleDenotation.derived$1(Denotations.scala:1107)
at dotty.tools.dotc.core.Denotations$SingleDenotation.computeAsSeenFrom(Denotations.scala:1134)
at dotty.tools.dotc.core.Denotations$SingleDenotation.computeAsSeenFrom(Denotations.scala:1087)
at dotty.tools.dotc.core.Denotations$PreDenotation.asSeenFrom(Denotations.scala:137)
at dotty.tools.dotc.core.SymDenotations$ClassDenotation.findMember(SymDenotations.scala:2216)
at dotty.tools.dotc.core.Types$Type.go$1(Types.scala:811)
at dotty.tools.dotc.core.Types$Type.findMember(Types.scala:1000)
at dotty.tools.dotc.core.Types$Type.memberBasedOnFlags(Types.scala:784)
at dotty.tools.dotc.core.Types$Type.nonPrivateMember(Types.scala:774)
at dotty.tools.dotc.typer.RefChecks$.targetOfHiddenExtension$1(RefChecks.scala:1164)
at dotty.tools.dotc.typer.RefChecks$.checkExtensionMethods(RefChecks.scala:1177)
at dotty.tools.dotc.typer.RefChecks.transformDefDef(RefChecks.scala:1332)
at dotty.tools.dotc.typer.RefChecks.transformDefDef(RefChecks.scala:1327)
at dotty.tools.dotc.transform.MegaPhase.goDefDef(MegaPhase.scala:1041)
at dotty.tools.dotc.transform.MegaPhase.goDefDef(MegaPhase.scala:1042)
at dotty.tools.dotc.transform.MegaPhase.goDefDef(MegaPhase.scala:1042)
at dotty.tools.dotc.transform.MegaPhase.goDefDef(MegaPhase.scala:1042)
at dotty.tools.dotc.transform.MegaPhase.goDefDef(MegaPhase.scala:1042)
at dotty.tools.dotc.transform.MegaPhase.transformNamed$1(MegaPhase.scala:268)
at dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:452)
at dotty.tools.dotc.transform.MegaPhase.loop$1(MegaPhase.scala:465)
at dotty.tools.dotc.transform.MegaPhase.transformStats(MegaPhase.scala:465)
at dotty.tools.dotc.transform.MegaPhase.transformUnnamed$1(MegaPhase.scala:376)
at dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:454)
at dotty.tools.dotc.transform.MegaPhase.transformNamed$1(MegaPhase.scala:272)
at dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:452)
at dotty.tools.dotc.transform.MegaPhase.loop$1(MegaPhase.scala:465)
at dotty.tools.dotc.transform.MegaPhase.transformStats(MegaPhase.scala:465)
at dotty.tools.dotc.transform.MegaPhase.mapPackage$1(MegaPhase.scala:396)
at dotty.tools.dotc.transform.MegaPhase.transformUnnamed$1(MegaPhase.scala:399)
at dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:454)
at dotty.tools.dotc.transform.MegaPhase.transformUnit(MegaPhase.scala:481)
at dotty.tools.dotc.transform.MegaPhase.run(MegaPhase.scala:493)
at dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:383)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
at scala.collection.immutable.List.foreach(List.scala:334)
at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:376)
at dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:368)
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:1324)
at dotty.tools.dotc.Run.runPhases$1(Run.scala:361)
at dotty.tools.dotc.Run.compileUnits$$anonfun$1$$anonfun$2(Run.scala:408)
at dotty.tools.dotc.Run.compileUnits$$anonfun$1$$anonfun$adapted$1(Run.scala:408)
at scala.Function0.apply$mcV$sp(Function0.scala:42)
at dotty.tools.dotc.Run.showProgress(Run.scala:470)
at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:408)
at dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:420)
at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:69)
at dotty.tools.dotc.Run.compileUnits(Run.scala:420)
at dotty.tools.dotc.Run.compileSources(Run.scala:307)
at dotty.tools.dotc.Run.compile(Run.scala:292)
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.MainGenericCompiler$.run$1(MainGenericCompiler.scala:160)
at dotty.tools.MainGenericCompiler$.main(MainGenericCompiler.scala:184)
at dotty.tools.MainGenericCompiler.main(MainGenericCompiler.scala)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions