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

assertion failed: <notype> & A / NoType & A #16236

Closed
oyvindberg opened this issue Oct 23, 2022 · 0 comments · Fixed by #16241
Closed

assertion failed: <notype> & A / NoType & A #16236

oyvindberg opened this issue Oct 23, 2022 · 0 comments · Fixed by #16241
Assignees
Milestone

Comments

@oyvindberg
Copy link

Compiler version

3.2.0

Minimized code

trait A

def consume[T](t: T): Unit = ()

def fails(p: (Double & A) | Null): Unit = consume(p) // error

def switchedOrder(p: (A & Double) | Null): Unit = consume(p) // ok
def nonPrimitive(p: (String & A) | Null): Unit = consume(p) // ok
def notNull(p: (Double & A)): Unit = consume(p) // ok

Output

scalac: Error: assertion failed: <notype> & A / NoType & TypeRef(ThisType(TypeRef(NoPrefix,module class <empty>)),trait A)
java.lang.AssertionError: assertion failed: <notype> & A / NoType & TypeRef(ThisType(TypeRef(NoPrefix,module class <empty>)),trait A)
	at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
	at dotty.tools.dotc.core.Types$AndType$.apply(Types.scala:3203)
	at dotty.tools.dotc.core.TypeOps$.approximateOr$1$$anonfun$2(TypeOps.scala:352)
	at scala.collection.IterableOnceOps.reduceLeft(IterableOnce.scala:738)
	at scala.collection.IterableOnceOps.reduceLeft$(IterableOnce.scala:724)
	at scala.collection.AbstractIterable.reduceLeft(Iterable.scala:926)
	at dotty.tools.dotc.core.TypeOps$.approximateOr$1(TypeOps.scala:352)
	at dotty.tools.dotc.core.TypeOps$.orDominator(TypeOps.scala:362)
	at dotty.tools.dotc.core.Types$OrType.join(Types.scala:3287)
	at dotty.tools.dotc.core.TypeComparer.secondTry$1(TypeComparer.scala:489)
	at dotty.tools.dotc.core.TypeComparer.compareNamed$1(TypeComparer.scala:306)
	at dotty.tools.dotc.core.TypeComparer.firstTry$1(TypeComparer.scala:312)
	at dotty.tools.dotc.core.TypeComparer.recur(TypeComparer.scala:1336)
	at dotty.tools.dotc.core.TypeComparer.isSubType(TypeComparer.scala:194)
	at dotty.tools.dotc.core.TypeComparer.fourthTry$1(TypeComparer.scala:820)
	at dotty.tools.dotc.core.TypeComparer.tryBaseType$1(TypeComparer.scala:770)
	at dotty.tools.dotc.core.TypeComparer.thirdTryNamed$1(TypeComparer.scala:540)
	at dotty.tools.dotc.core.TypeComparer.compareNamed$1(TypeComparer.scala:304)
	at dotty.tools.dotc.core.TypeComparer.firstTry$1(TypeComparer.scala:312)
	at dotty.tools.dotc.core.TypeComparer.recur(TypeComparer.scala:1336)
	at dotty.tools.dotc.core.TypeComparer.compareTypeParamRef$2(TypeComparer.scala:562)
	at dotty.tools.dotc.core.TypeComparer.thirdTry$1(TypeComparer.scala:577)
	at dotty.tools.dotc.core.TypeComparer.secondTry$1(TypeComparer.scala:395)
	at dotty.tools.dotc.core.TypeComparer.firstTry$1(TypeComparer.scala:316)
	at dotty.tools.dotc.core.TypeComparer.recur(TypeComparer.scala:1336)
	at dotty.tools.dotc.core.TypeComparer.isSubType(TypeComparer.scala:194)
	at dotty.tools.dotc.core.TypeComparer.isSubType(TypeComparer.scala:204)
	at dotty.tools.dotc.core.TypeComparer.isSub(TypeComparer.scala:206)
	at dotty.tools.dotc.core.ConstraintHandling.op$proxy2$1(ConstraintHandling.scala:412)
	at dotty.tools.dotc.core.ConstraintHandling.isSubTypeWhenFrozen(ConstraintHandling.scala:412)
	at dotty.tools.dotc.core.ConstraintHandling.isSubTypeWhenFrozen$(ConstraintHandling.scala:27)
	at dotty.tools.dotc.core.TypeComparer.isSubTypeWhenFrozen(TypeComparer.scala:30)
	at dotty.tools.dotc.core.TypeComparer.compareTypeParamRef$2(TypeComparer.scala:563)
	at dotty.tools.dotc.core.TypeComparer.thirdTry$1(TypeComparer.scala:577)
	at dotty.tools.dotc.core.TypeComparer.secondTry$1(TypeComparer.scala:395)
	at dotty.tools.dotc.core.TypeComparer.firstTry$1(TypeComparer.scala:316)
	at dotty.tools.dotc.core.TypeComparer.recur(TypeComparer.scala:1336)
	at dotty.tools.dotc.core.TypeComparer.firstTry$1(TypeComparer.scala:318)
	at dotty.tools.dotc.core.TypeComparer.recur(TypeComparer.scala:1336)
	at dotty.tools.dotc.core.TypeComparer.isSubType(TypeComparer.scala:194)
	at dotty.tools.dotc.core.TypeComparer.isSubType(TypeComparer.scala:204)
	at dotty.tools.dotc.core.TypeComparer.topLevelSubType(TypeComparer.scala:128)
	at dotty.tools.dotc.core.TypeComparer.testSubType(TypeComparer.scala:144)
	at dotty.tools.dotc.core.TypeComparer$.testSubType(TypeComparer.scala:2767)
	at dotty.tools.dotc.typer.Typer.adaptNoArgsOther$1(Typer.scala:3725)
	at dotty.tools.dotc.typer.Typer.adaptNoArgs$1(Typer.scala:3822)
	at dotty.tools.dotc.typer.Typer.adapt1(Typer.scala:4038)
	at dotty.tools.dotc.typer.Typer.adapt(Typer.scala:3368)
	at dotty.tools.dotc.typer.ProtoTypes$FunProto.typedArg(ProtoTypes.scala:484)
	at dotty.tools.dotc.typer.Applications$ApplyToUntyped.typedArg(Applications.scala:866)
	at dotty.tools.dotc.typer.Applications$ApplyToUntyped.typedArg(Applications.scala:866)
	at dotty.tools.dotc.typer.Applications$Application.addTyped$1(Applications.scala:557)
	at dotty.tools.dotc.typer.Applications$Application.matchArgs(Applications.scala:622)
	at dotty.tools.dotc.typer.Applications$Application.init(Applications.scala:460)
	at dotty.tools.dotc.typer.Applications$TypedApply.<init>(Applications.scala:748)
	at dotty.tools.dotc.typer.Applications$ApplyToUntyped.<init>(Applications.scala:865)
	at dotty.tools.dotc.typer.Applications.ApplyTo(Applications.scala:1077)
	at dotty.tools.dotc.typer.Applications.ApplyTo$(Applications.scala:327)
	at dotty.tools.dotc.typer.Typer.ApplyTo(Typer.scala:117)
	at dotty.tools.dotc.typer.Applications.simpleApply$1(Applications.scala:923)
	at dotty.tools.dotc.typer.Applications.realApply$1$$anonfun$3(Applications.scala:1003)
	at dotty.tools.dotc.typer.Typer.tryEither(Typer.scala:3131)
	at dotty.tools.dotc.typer.Applications.realApply$1(Applications.scala:1014)
	at dotty.tools.dotc.typer.Applications.typedApply(Applications.scala:1052)
	at dotty.tools.dotc.typer.Applications.typedApply$(Applications.scala:327)
	at dotty.tools.dotc.typer.Typer.typedApply(Typer.scala:117)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2859)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2922)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2987)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2991)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3107)
	at dotty.tools.dotc.typer.Typer.$anonfun$48(Typer.scala:2295)
	at dotty.tools.dotc.typer.PrepareInlineable$.dropInlineIfError(PrepareInlineable.scala:248)
	at dotty.tools.dotc.typer.Typer.typedDefDef(Typer.scala:2295)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2835)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2921)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2987)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2991)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3013)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3063)
	at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:2500)
	at dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$1(Typer.scala:2847)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2851)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2921)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2987)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2991)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3013)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3063)
	at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:2629)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2892)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2922)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2987)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2991)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3107)
	at dotty.tools.dotc.typer.TyperPhase.typeCheck$$anonfun$1(TyperPhase.scala:43)
	at dotty.tools.dotc.typer.TyperPhase.typeCheck$$anonfun$adapted$1(TyperPhase.scala:50)
	at scala.Function0.apply$mcV$sp(Function0.scala:39)
	at dotty.tools.dotc.core.Phases$Phase.monitor(Phases.scala:417)
	at dotty.tools.dotc.typer.TyperPhase.typeCheck(TyperPhase.scala:50)
	at dotty.tools.dotc.typer.TyperPhase.runOn$$anonfun$3(TyperPhase.scala:84)
	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:333)
	at dotty.tools.dotc.typer.TyperPhase.runOn(TyperPhase.scala:84)
	at dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:234)
	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:1328)
	at dotty.tools.dotc.Run.runPhases$1(Run.scala:245)
	at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:253)
	at dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:262)
	at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:68)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:262)
	at dotty.tools.dotc.Run.compileSources(Run.scala:186)
	at dotty.tools.dotc.Run.compile(Run.scala:170)
	at dotty.tools.dotc.Driver.doCompile(Driver.scala:35)
	at dotty.tools.xsbt.CompilerBridgeDriver.run(CompilerBridgeDriver.java:88)
	at dotty.tools.xsbt.CompilerBridge.run(CompilerBridge.java:22)
	at sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:91)
	at org.jetbrains.jps.incremental.scala.local.IdeaIncrementalCompiler.compile(IdeaIncrementalCompiler.scala:53)
	at org.jetbrains.jps.incremental.scala.local.LocalServer.doCompile(LocalServer.scala:49)
	at org.jetbrains.jps.incremental.scala.local.LocalServer.compile(LocalServer.scala:27)
	at org.jetbrains.jps.incremental.scala.remote.Main$.compileLogic(Main.scala:203)
	at org.jetbrains.jps.incremental.scala.remote.Main$.$anonfun$handleCommand$1(Main.scala:190)
	at org.jetbrains.jps.incremental.scala.remote.Main$.decorated$1(Main.scala:180)
	at org.jetbrains.jps.incremental.scala.remote.Main$.handleCommand(Main.scala:187)
	at org.jetbrains.jps.incremental.scala.remote.Main$.serverLogic(Main.scala:163)
	at org.jetbrains.jps.incremental.scala.remote.Main$.nailMain(Main.scala:103)
	at org.jetbrains.jps.incremental.scala.remote.Main.nailMain(Main.scala)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
	at java.base/java.lang.reflect.Method.invoke(Method.java:577)
	at com.facebook.nailgun.NGSession.runImpl(NGSession.java:312)
	at com.facebook.nailgun.NGSession.run(NGSession.java:198)

Expectation

I know this involves a somewhat nonsensical type, you won't really have Double with A.

However, I would expect to be able to express and use the type, creating it is another matter.
Seeing as it is accepted without the | Null part, hopefully it's not too hard.

@oyvindberg oyvindberg added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Oct 23, 2022
@dwijnand dwijnand self-assigned this Oct 24, 2022
@dwijnand dwijnand added area:typer stat:needs triage Every issue needs to have an "area" and "itype" label and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Oct 24, 2022
@dwijnand dwijnand linked a pull request Oct 24, 2022 that will close this issue
@Kordyjan Kordyjan added this to the 3.2.2 milestone Aug 1, 2023
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