scala3 icon indicating copy to clipboard operation
scala3 copied to clipboard

Crash on type projection

Open Adam-Vandervorst opened this issue 3 months ago • 0 comments

Compiler version

3.4.1

Minimized code

trait Poly
trait -->[X, Y] extends Poly
trait +[X, Y] extends Poly
trait *[X, Y] extends Poly

type Hinze[X <: Fix[_]] = X#unfix match
  case (k1 + k2) --> v => Hinze[(k1 --> v)] * Hinze[(k2 --> v)]
  case (k1 * k2) --> v => k1 --> Hinze[(k2 --> v)]

trait Lambda[V]:
  type Abs[X] = V * X
  type App[X] = X * X
  type L[X] = V + Abs[X] + App[X]

trait Fix[F[X]]:
  type unfix = F[Fix[F]]

@main
def m =
  println(summon[((String --> Unit) * (String --> Unit)) =:= Hinze[(String + String) --> Unit]])
  println(summon[String =:= Hinze[Fix[Lambda[String]#L] --> Unit]])

Output (click arrow to expand)

[info]         during phase: typer
[info]                 mode: Mode(ImplicitsEnabled)
[info]      library version: version 2.13.12
[info]     compiler version: version 3.4.1
[info]             settings: -bootclasspath /home/adam/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala3-library_3/3.4.1/scala3-library_3-3.4.1.jar:/home/adam/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.12/scala-library-2.13.12.jar -classpath /home/adam/Projects/SMORK/target/scala-3.4.1/classes -d /home/adam/Projects/SMORK/target/scala-3.4.1/classes -source 3.3
[error] ## Exception when compiling 1 sources to /home/adam/Projects/SMORK/target/scala-3.4.1/classes
[error] scala.MatchError: NoType (of class dotty.tools.dotc.core.Types$NoType$)
[error] dotty.tools.dotc.core.TypeComparer.disjointnessBoundary$1(TypeComparer.scala:2865)
[error] dotty.tools.dotc.core.TypeComparer.provablyDisjoint(TypeComparer.scala:2868)
[error] dotty.tools.dotc.core.TypeComparer.provablyDisjoint(TypeComparer.scala:2810)
[error] dotty.tools.dotc.core.TrackingTypeComparer.matchLegacyPatMat$1(TypeComparer.scala:3548)
[error] dotty.tools.dotc.core.TrackingTypeComparer.matchCase$1(TypeComparer.scala:3350)
[error] dotty.tools.dotc.core.TrackingTypeComparer.recur$2(TypeComparer.scala:3585)
[error] dotty.tools.dotc.core.TrackingTypeComparer.op$proxy82$1(TypeComparer.scala:3622)
[error] dotty.tools.dotc.core.TrackingTypeComparer.matchCases(TypeComparer.scala:3623)
[error] dotty.tools.dotc.core.Types$MatchType.matchCases$1(Types.scala:5049)
[error] dotty.tools.dotc.core.Types$MatchType.reduced$$anonfun$1(Types.scala:5058)
[error] dotty.tools.dotc.core.TypeComparer.inSubComparer(TypeComparer.scala:3062)
[error] dotty.tools.dotc.core.TypeComparer.tracked(TypeComparer.scala:3072)
[error] dotty.tools.dotc.core.TypeComparer$.tracked(TypeComparer.scala:3240)
[error] dotty.tools.dotc.core.Types$MatchType.reduced(Types.scala:5058)
[error] dotty.tools.dotc.core.Types$MatchType.tryNormalize(Types.scala:5007)
[error] dotty.tools.dotc.core.Types$AppliedType.tryMatchAlias$1$$anonfun$1(Types.scala:4570)
[error] dotty.tools.dotc.core.MatchTypeTrace$.recurseWith(MatchTypeTrace.scala:81)
[error] dotty.tools.dotc.core.Types$AppliedType.tryMatchAlias$1(Types.scala:4571)
[error] dotty.tools.dotc.core.Types$AppliedType.tryNormalize(Types.scala:4576)
[error] dotty.tools.dotc.core.TypeOps$.simplify(TypeOps.scala:149)
[error] dotty.tools.dotc.core.Types$Type.simplified(Types.scala:2042)
[error] dotty.tools.dotc.typer.Typer.simplify(Typer.scala:3216)
[error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3200)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3274)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3278)
[error] dotty.tools.dotc.typer.Typer.typedType(Typer.scala:3392)
[error] dotty.tools.dotc.typer.Typer.typedArg$1(Typer.scala:2298)
[error] dotty.tools.dotc.typer.Typer.$anonfun$51(Typer.scala:2302)
[error] dotty.tools.dotc.core.Decorators$.zipWithConserve(Decorators.scala:160)
[error] dotty.tools.dotc.core.Decorators$.zipWithConserve(Decorators.scala:161)
[error] dotty.tools.dotc.typer.Typer.typedAppliedTypeTree(Typer.scala:2302)
[error] dotty.tools.dotc.typer.Typer.typedInfixOp(Typer.scala:2999)
[error] dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3153)
[error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3197)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3274)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3278)
[error] dotty.tools.dotc.typer.Typer.typedType(Typer.scala:3392)
[error] dotty.tools.dotc.typer.Applications.$anonfun$14(Applications.scala:1167)
[error] dotty.tools.dotc.core.Decorators$.loop$1(Decorators.scala:99)
[error] dotty.tools.dotc.core.Decorators$.mapconserve(Decorators.scala:115)
[error] dotty.tools.dotc.typer.Applications.typedTypeApply(Applications.scala:1167)
[error] dotty.tools.dotc.typer.Applications.typedTypeApply$(Applications.scala:351)
[error] dotty.tools.dotc.typer.Typer.typedTypeApply(Typer.scala:120)
[error] dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3133)
[error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3197)
[error] dotty.tools.dotc.typer.ProtoTypes$FunProto.$anonfun$7(ProtoTypes.scala:509)
[error] dotty.tools.dotc.typer.ProtoTypes$FunProto.cacheTypedArg(ProtoTypes.scala:432)
[error] dotty.tools.dotc.typer.ProtoTypes$FunProto.typedArg(ProtoTypes.scala:510)
[error] dotty.tools.dotc.typer.Applications$ApplyToUntyped.typedArg(Applications.scala:913)
[error] dotty.tools.dotc.typer.Applications$ApplyToUntyped.typedArg(Applications.scala:913)
[error] dotty.tools.dotc.typer.Applications$Application.addTyped$1(Applications.scala:605)
[error] dotty.tools.dotc.typer.Applications$Application.matchArgs(Applications.scala:669)
[error] dotty.tools.dotc.typer.Applications$Application.init(Applications.scala:491)
[error] dotty.tools.dotc.typer.Applications$TypedApply.<init>(Applications.scala:795)
[error] dotty.tools.dotc.typer.Applications$ApplyToUntyped.<init>(Applications.scala:912)
[error] dotty.tools.dotc.typer.Applications.ApplyTo(Applications.scala:1142)
[error] dotty.tools.dotc.typer.Applications.ApplyTo$(Applications.scala:351)
[error] dotty.tools.dotc.typer.Typer.ApplyTo(Typer.scala:120)
[error] dotty.tools.dotc.typer.Applications.simpleApply$1(Applications.scala:985)
[error] dotty.tools.dotc.typer.Applications.realApply$1$$anonfun$2(Applications.scala:1068)
[error] dotty.tools.dotc.typer.Typer.tryEither(Typer.scala:3413)
[error] dotty.tools.dotc.typer.Applications.realApply$1(Applications.scala:1079)
[error] dotty.tools.dotc.typer.Applications.typedApply(Applications.scala:1117)
[error] dotty.tools.dotc.typer.Applications.typedApply$(Applications.scala:351)
[error] dotty.tools.dotc.typer.Typer.typedApply(Typer.scala:120)
[error] dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3113)
[error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3197)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3274)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3278)
[error] dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3327)
[error] dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3346)
[error] dotty.tools.dotc.typer.Typer.typedBlockStats(Typer.scala:1193)
[error] dotty.tools.dotc.typer.Typer.typedBlock(Typer.scala:1197)
[error] dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3121)
[error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3197)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3274)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3278)
[error] dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3389)
[error] dotty.tools.dotc.typer.Namer.typedAheadExpr$$anonfun$1(Namer.scala:1685)
[error] dotty.tools.dotc.typer.Namer.typedAhead(Namer.scala:1675)
[error] dotty.tools.dotc.typer.Namer.typedAheadExpr(Namer.scala:1685)
[error] dotty.tools.dotc.typer.Namer.typedAheadRhs$1$$anonfun$1(Namer.scala:1941)
[error] dotty.tools.dotc.inlines.PrepareInlineable$.dropInlineIfError(PrepareInlineable.scala:256)
[error] dotty.tools.dotc.typer.Namer.typedAheadRhs$1(Namer.scala:1941)
[error] dotty.tools.dotc.typer.Namer.rhsType$1(Namer.scala:1949)
[error] dotty.tools.dotc.typer.Namer.cookedRhsType$1(Namer.scala:1967)
[error] dotty.tools.dotc.typer.Namer.lhsType$1(Namer.scala:1968)
[error] dotty.tools.dotc.typer.Namer.inferredResultType(Namer.scala:1979)
[error] dotty.tools.dotc.typer.Namer.inferredType$1(Namer.scala:1723)
[error] dotty.tools.dotc.typer.Namer.valOrDefDefSig(Namer.scala:1729)
[error] dotty.tools.dotc.typer.Namer.defDefSig(Namer.scala:1828)
[error] dotty.tools.dotc.typer.Namer$Completer.typeSig(Namer.scala:808)
[error] dotty.tools.dotc.typer.Namer$Completer.completeInCreationContext(Namer.scala:955)
[error] dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:831)
[error] dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:178)
[error] dotty.tools.dotc.core.Denotations$Denotation.completeInfo$1(Denotations.scala:190)
[error] dotty.tools.dotc.core.Denotations$Denotation.info(Denotations.scala:192)
[error] dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:398)
[error] dotty.tools.dotc.typer.Typer.retrieveSym(Typer.scala:3060)
[error] dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3085)
[error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3196)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3274)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3278)
[error] dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3300)
[error] dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3346)
[error] dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:2790)
[error] dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$1(Typer.scala:3101)
[error] dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3105)
[error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3196)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3274)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3278)
[error] dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3300)
[error] dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3346)
[error] dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:2923)
[error] dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3147)
[error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3197)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3274)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3278)
[error] dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3389)
[error] dotty.tools.dotc.typer.TyperPhase.typeCheck$$anonfun$1(TyperPhase.scala:47)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] dotty.tools.dotc.core.Phases$Phase.monitor(Phases.scala:477)
[error] dotty.tools.dotc.typer.TyperPhase.typeCheck(TyperPhase.scala:53)
[error] dotty.tools.dotc.typer.TyperPhase.$anonfun$4(TyperPhase.scala:99)
[error] scala.collection.Iterator$$anon$6.hasNext(Iterator.scala:479)
[error] scala.collection.Iterator$$anon$9.hasNext(Iterator.scala:583)
[error] scala.collection.immutable.List.prependedAll(List.scala:152)
[error] scala.collection.immutable.List$.from(List.scala:684)
[error] scala.collection.immutable.List$.from(List.scala:681)
[error] scala.collection.IterableOps$WithFilter.map(Iterable.scala:898)
[error] dotty.tools.dotc.typer.TyperPhase.runOn(TyperPhase.scala:100)
[error] dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:315)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1323)
[error] dotty.tools.dotc.Run.runPhases$1(Run.scala:337)
[error] dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:350)
[error] dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:360)
[error] dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:69)
[error] dotty.tools.dotc.Run.compileUnits(Run.scala:360)
[error] dotty.tools.dotc.Run.compileSources(Run.scala:261)
[error] dotty.tools.dotc.Run.compile(Run.scala:246)
[error] dotty.tools.dotc.Driver.doCompile(Driver.scala:37)
[error] dotty.tools.xsbt.CompilerBridgeDriver.run(CompilerBridgeDriver.java:141)
[error] dotty.tools.xsbt.CompilerBridge.run(CompilerBridge.java:22)
[error] sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:91)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$7(MixedAnalyzingCompiler.scala:193)
[error] scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
[error] sbt.internal.inc.MixedAnalyzingCompiler.timed(MixedAnalyzingCompiler.scala:248)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4(MixedAnalyzingCompiler.scala:183)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4$adapted(MixedAnalyzingCompiler.scala:163)
[error] sbt.internal.inc.JarUtils$.withPreviousJar(JarUtils.scala:239)
[error] sbt.internal.inc.MixedAnalyzingCompiler.compileScala$1(MixedAnalyzingCompiler.scala:163)
[error] sbt.internal.inc.MixedAnalyzingCompiler.compile(MixedAnalyzingCompiler.scala:211)
[error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1(IncrementalCompilerImpl.scala:534)
[error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1$adapted(IncrementalCompilerImpl.scala:534)
[error] sbt.internal.inc.Incremental$.$anonfun$apply$5(Incremental.scala:180)
[error] sbt.internal.inc.Incremental$.$anonfun$apply$5$adapted(Incremental.scala:178)
[error] sbt.internal.inc.Incremental$$anon$2.run(Incremental.scala:464)
[error] sbt.internal.inc.IncrementalCommon$CycleState.next(IncrementalCommon.scala:116)
[error] sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:56)
[error] sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:52)
[error] sbt.internal.inc.IncrementalCommon.cycle(IncrementalCommon.scala:263)
[error] sbt.internal.inc.Incremental$.$anonfun$incrementalCompile$8(Incremental.scala:419)
[error] sbt.internal.inc.Incremental$.withClassfileManager(Incremental.scala:506)
[error] sbt.internal.inc.Incremental$.incrementalCompile(Incremental.scala:406)
[error] sbt.internal.inc.Incremental$.apply(Incremental.scala:172)
[error] sbt.internal.inc.IncrementalCompilerImpl.compileInternal(IncrementalCompilerImpl.scala:534)
[error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileIncrementally$1(IncrementalCompilerImpl.scala:488)
[error] sbt.internal.inc.IncrementalCompilerImpl.handleCompilationError(IncrementalCompilerImpl.scala:332)
[error] sbt.internal.inc.IncrementalCompilerImpl.compileIncrementally(IncrementalCompilerImpl.scala:425)
[error] sbt.internal.inc.IncrementalCompilerImpl.compile(IncrementalCompilerImpl.scala:137)
[error] sbt.Defaults$.compileIncrementalTaskImpl(Defaults.scala:2371)
[error] sbt.Defaults$.$anonfun$compileIncrementalTask$2(Defaults.scala:2321)
[error] sbt.internal.server.BspCompileTask$.$anonfun$compute$1(BspCompileTask.scala:31)
[error] sbt.internal.io.Retry$.apply(Retry.scala:47)
[error] sbt.internal.io.Retry$.apply(Retry.scala:29)
[error] sbt.internal.io.Retry$.apply(Retry.scala:24)
[error] sbt.internal.server.BspCompileTask$.compute(BspCompileTask.scala:31)
[error] sbt.Defaults$.$anonfun$compileIncrementalTask$1(Defaults.scala:2319)
[error] scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error] sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:63)
[error] sbt.std.Transform$$anon$4.work(Transform.scala:69)
[error] sbt.Execute.$anonfun$submit$2(Execute.scala:283)
[error] sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:24)
[error] sbt.Execute.work(Execute.scala:292)
[error] sbt.Execute.$anonfun$submit$1(Execute.scala:283)
[error] sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265)
[error] sbt.CompletionService$$anon$2.call(CompletionService.scala:65)
[error] java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error] java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
[error] java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error] java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
[error] java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)

Note

I did not expect this code to compile; I was still writing the Hinze function.

Adam-Vandervorst avatar Apr 25 '24 14:04 Adam-Vandervorst