Skip to content

Compiler crashes with "assertion failed: invalid prefix HKTypeLambda(...)" #23504

Open
@unarist

Description

@unarist

Compiler version

  • 3.0.0
  • 3.5.0
  • 3.7.0
  • 3.7.2-RC1

Minimized code

Seq.empty[[T] =>> () => ?].head()

Output (click arrow to expand)

$ scala-cli --server=false
Welcome to Scala 3.7.0 (11.0.27, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.

scala> Seq.empty[[T] =>> () => ?].head()
Exception in thread "main" java.lang.AssertionError: assertion failed: invalid prefix HKTypeLambda(List(T), List(TypeBounds(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Any))), AppliedType(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),trait Function0),List(TypeBounds(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Any)))))
        at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
        at dotty.tools.dotc.core.Types$NamedType.<init>(Types.scala:2301)
        at dotty.tools.dotc.core.Types$TypeRef.<init>(Types.scala:2938)
        at dotty.tools.dotc.core.Types$CachedTypeRef.<init>(Types.scala:2995)
        at dotty.tools.dotc.core.Uniques$NamedTypeUniques.newType$1(Uniques.scala:45)
        at dotty.tools.dotc.core.Uniques$NamedTypeUniques.linkedListLoop$1(Uniques.scala:56)
        at dotty.tools.dotc.core.Uniques$NamedTypeUniques.enterIfNew(Uniques.scala:62)
        at dotty.tools.dotc.core.Types$TypeRef$.apply(Types.scala:3057)
        at dotty.tools.dotc.core.Types$NamedType.argForParam(Types.scala:2735)
        at dotty.tools.dotc.core.Types$NamedType.derivedSelect(Types.scala:2777)
        at dotty.tools.dotc.core.Types$TypeMap.derivedSelect(Types.scala:6102)
        at dotty.tools.dotc.core.Types$ApproximatingTypeMap.derivedSelect(Types.scala:6455)
        at dotty.tools.dotc.core.TypeOps$AsSeenFromMap.apply(TypeOps.scala:103)
        at dotty.tools.dotc.core.Types$TypeMap.mapOverLambda(Types.scala:6160)
        at dotty.tools.dotc.core.TypeOps$AsSeenFromMap.apply(TypeOps.scala:105)
        at dotty.tools.dotc.core.TypeOps$.asSeenFrom(TypeOps.scala:55)
        at dotty.tools.dotc.core.Types$Type.asSeenFrom(Types.scala:1113)
        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:2194)
        at dotty.tools.dotc.core.Types$Type.go$1(Types.scala:778)
        at dotty.tools.dotc.core.Types$Type.findMember(Types.scala:959)
        at dotty.tools.dotc.core.Types$Type.memberBasedOnFlags(Types.scala:751)
        at dotty.tools.dotc.core.Types$Type.member(Types.scala:735)
        at dotty.tools.dotc.typer.ProtoTypes$SelectionProto.isMatchedBy(ProtoTypes.scala:245)
        at dotty.tools.dotc.core.TypeComparer.isMatchedByProto(TypeComparer.scala:2237)
        at dotty.tools.dotc.core.TypeComparer.firstTry$1(TypeComparer.scala:359)
        at dotty.tools.dotc.core.TypeComparer.recur(TypeComparer.scala:1599)
        at dotty.tools.dotc.core.TypeComparer.isSubType(TypeComparer.scala:229)
        at dotty.tools.dotc.core.TypeComparer.isSubType(TypeComparer.scala:239)
        at dotty.tools.dotc.core.TypeComparer.topLevelSubType(TypeComparer.scala:147)
        at dotty.tools.dotc.core.TypeComparer.testSubType(TypeComparer.scala:164)
        at dotty.tools.dotc.core.TypeComparer$.testSubType(TypeComparer.scala:3406)
        at dotty.tools.dotc.typer.Typer.adaptNoArgsOther$1(Typer.scala:4526)
        at dotty.tools.dotc.typer.Typer.adaptNoArgs$1(Typer.scala:4613)
        at dotty.tools.dotc.typer.Typer.adapt1(Typer.scala:4875)
        at dotty.tools.dotc.typer.Typer.adapt(Typer.scala:4105)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3725)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3730)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3841)
        at dotty.tools.dotc.typer.Typer.typeSelectOnTerm$1(Typer.scala:1046)
        at dotty.tools.dotc.typer.Typer.typedSelect(Typer.scala:1088)
        at dotty.tools.dotc.typer.Typer.tryApply$1(Typer.scala:3904)
        at dotty.tools.dotc.typer.Typer.tryInsertApplyOrImplicit$$anonfun$2(Typer.scala:3935)
        at dotty.tools.dotc.typer.Typer$.tryEither(Typer.scala:127)
        at dotty.tools.dotc.typer.Typer.tryInsertApplyOrImplicit(Typer.scala:3942)
        at dotty.tools.dotc.typer.Typer.adaptToArgs$1(Typer.scala:4213)
        at dotty.tools.dotc.typer.Typer.adapt1(Typer.scala:4870)
        at dotty.tools.dotc.typer.Typer.adapt(Typer.scala:4105)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3725)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3730)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3841)
        at dotty.tools.dotc.typer.Applications.realApply$1(Applications.scala:1090)
        at dotty.tools.dotc.typer.Applications.typedApply(Applications.scala:1287)
        at dotty.tools.dotc.typer.Applications.typedApply$(Applications.scala:465)
        at dotty.tools.dotc.typer.Typer.typedApply(Typer.scala:154)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3560)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3648)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3725)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3730)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3841)
        at dotty.tools.dotc.typer.Namer.typedAheadExpr$$anonfun$1(Namer.scala:1794)
        at dotty.tools.dotc.typer.Namer.typedAhead(Namer.scala:1784)
        at dotty.tools.dotc.typer.Namer.typedAheadExpr(Namer.scala:1794)
        at dotty.tools.dotc.typer.Namer.typedAheadRhs$1$$anonfun$1(Namer.scala:2210)
        at dotty.tools.dotc.inlines.PrepareInlineable$.dropInlineIfError(PrepareInlineable.scala:256)
        at dotty.tools.dotc.typer.Namer.typedAheadRhs$1(Namer.scala:2210)
        at dotty.tools.dotc.typer.Namer.rhsType$1(Namer.scala:2218)
        at dotty.tools.dotc.typer.Namer.cookedRhsType$1(Namer.scala:2243)
        at dotty.tools.dotc.typer.Namer.lhsType$1(Namer.scala:2244)
        at dotty.tools.dotc.typer.Namer.inferredResultType(Namer.scala:2255)
        at dotty.tools.dotc.typer.Namer.inferredType$1(Namer.scala:1837)
        at dotty.tools.dotc.typer.Namer.valOrDefDefSig(Namer.scala:1843)
        at dotty.tools.dotc.typer.Namer$Completer.typeSig(Namer.scala:836)
        at dotty.tools.dotc.typer.Namer$Completer.completeInCreationContext(Namer.scala:1003)
        at dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:872)
        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:3507)
        at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3532)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3647)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3725)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3730)
        at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3752)
        at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3798)
        at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:3220)
        at dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$1(Typer.scala:3548)
        at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3552)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3647)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3725)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3730)
        at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3752)
        at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3798)
        at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:3353)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3594)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3648)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3725)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3730)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3841)
        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:510)
        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:685)
        at scala.collection.immutable.List$.from(List.scala:682)
        at scala.collection.IterableOps$WithFilter.map(Iterable.scala:900)
        at dotty.tools.dotc.typer.TyperPhase.runOn(TyperPhase.scala:98)
        at dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:367)
        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:360)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$1$$anonfun$2(Run.scala:407)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$1$$anonfun$adapted$1(Run.scala:407)
        at scala.Function0.apply$mcV$sp(Function0.scala:42)
        at dotty.tools.dotc.Run.showProgress(Run.scala:469)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:407)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:419)
        at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:69)
        at dotty.tools.dotc.Run.compileUnits(Run.scala:419)
        at dotty.tools.dotc.Run.compileUnits(Run.scala:312)
        at dotty.tools.repl.ReplCompiler.compile(ReplCompiler.scala:89)
        at dotty.tools.repl.ReplDriver.compile(ReplDriver.scala:341)
        at dotty.tools.repl.ReplDriver.interpret(ReplDriver.scala:303)
        at dotty.tools.repl.ReplDriver.loop$1(ReplDriver.scala:221)
        at dotty.tools.repl.ReplDriver.runUntilQuit$$anonfun$1(ReplDriver.scala:224)
        at dotty.tools.repl.ReplDriver.withRedirectedOutput(ReplDriver.scala:258)
        at dotty.tools.repl.ReplDriver.runBody$$anonfun$1(ReplDriver.scala:232)
        at dotty.tools.runner.ScalaClassLoader$.asContext(ScalaClassLoader.scala:80)
        at dotty.tools.repl.ReplDriver.runBody(ReplDriver.scala:232)
        at dotty.tools.repl.ReplDriver.runUntilQuit(ReplDriver.scala:224)
        at dotty.tools.repl.ReplDriver.tryRunning(ReplDriver.scala:161)
        at dotty.tools.repl.Main$.main(Main.scala:7)
        at dotty.tools.repl.Main.main(Main.scala)
[error]  Failed to run REPL (exit code: 1)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions