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

dotc assertion error on (non-sensical?) parameter type. #13769

Closed
Adam-Vandervorst opened this issue Oct 18, 2021 · 2 comments
Closed

dotc assertion error on (non-sensical?) parameter type. #13769

Adam-Vandervorst opened this issue Oct 18, 2021 · 2 comments
Assignees
Labels
area:parser itype:bug Spree Suitable for a future Spree

Comments

@Adam-Vandervorst
Copy link

Compiler version

3.0.2

Minimized code

val tup = (1, "s")
val te = tup.map((x: _ <: Singleton) => List(x))

Output

scalac: Error: assertion failed: TypeBounds(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),object scala),trait Singleton))
scalac: Error: assertion failed: TypeBounds(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),object scala),trait Singleton))
java.lang.AssertionError: assertion failed: TypeBounds(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),object scala),trait Singleton))
	at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
	at dotty.tools.dotc.core.Types$TypeBounds.<init>(Types.scala:4893)
	at dotty.tools.dotc.core.Types$RealTypeBounds.<init>(Types.scala:4953)
	at dotty.tools.dotc.core.Types$TypeBounds$.apply(Types.scala:4997)
	at dotty.tools.dotc.core.Types$TypeBounds$.upper(Types.scala:5006)
	at dotty.tools.dotc.typer.ProtoTypes$.dotty$tools$dotc$typer$ProtoTypes$$$wildApprox(ProtoTypes.scala:794)
	at dotty.tools.dotc.typer.ProtoTypes$.wildApprox$$anonfun$1(ProtoTypes.scala:765)
	at scala.collection.immutable.List.mapConserve(List.scala:472)
	at dotty.tools.dotc.typer.ProtoTypes$.dotty$tools$dotc$typer$ProtoTypes$$$wildApprox(ProtoTypes.scala:765)
	at dotty.tools.dotc.typer.ProtoTypes$WildApproxMap.apply(ProtoTypes.scala:845)
	at dotty.tools.dotc.core.Types$TypeMap.mapOverLambda(Types.scala:5375)
	at dotty.tools.dotc.core.Types$TypeMap.mapOver(Types.scala:5400)
	at dotty.tools.dotc.typer.ProtoTypes$.dotty$tools$dotc$typer$ProtoTypes$$$wildApprox(ProtoTypes.scala:837)
	at dotty.tools.dotc.typer.ProtoTypes$.dotty$tools$dotc$typer$ProtoTypes$$$wildApprox(ProtoTypes.scala:771)
	at dotty.tools.dotc.typer.ProtoTypes$.wildApprox(ProtoTypes.scala:840)
	at dotty.tools.dotc.typer.Implicits$ImplicitSearch.<init>(Implicits.scala:1123)
	at dotty.tools.dotc.typer.Implicits.inferImplicit(Implicits.scala:991)
	at dotty.tools.dotc.typer.Implicits.inferImplicit$(Implicits.scala:774)
	at dotty.tools.dotc.typer.Typer.inferImplicit(Typer.scala:106)
	at dotty.tools.dotc.typer.Implicits.inferView(Implicits.scala:820)
	at dotty.tools.dotc.typer.Implicits.inferView$(Implicits.scala:774)
	at dotty.tools.dotc.typer.Typer.inferView(Typer.scala:106)
	at dotty.tools.dotc.typer.Typer.adaptToSubType$1(Typer.scala:3707)
	at dotty.tools.dotc.typer.Typer.adaptNoArgsOther$4(Typer.scala:3530)
	at dotty.tools.dotc.typer.Typer.adaptNoArgs$1(Typer.scala:3619)
	at dotty.tools.dotc.typer.Typer.adapt1(Typer.scala:3810)
	at dotty.tools.dotc.typer.Typer.adapt(Typer.scala:3162)
	at dotty.tools.dotc.typer.Typer.readapt$1(Typer.scala:3173)
	at dotty.tools.dotc.typer.Typer.adaptToSubType$1(Typer.scala:3651)
	at dotty.tools.dotc.typer.Typer.adaptNoArgsOther$4(Typer.scala:3530)
	at dotty.tools.dotc.typer.Typer.adaptNoArgs$1(Typer.scala:3619)
	at dotty.tools.dotc.typer.Typer.adapt1(Typer.scala:3810)
	at dotty.tools.dotc.typer.Typer.adapt(Typer.scala:3162)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2821)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2825)
	at dotty.tools.dotc.typer.Typer.typedFunctionValue(Typer.scala:1408)
	at dotty.tools.dotc.typer.Typer.typedFunction(Typer.scala:1197)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2703)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2756)
	at dotty.tools.dotc.typer.ProtoTypes$FunProto.$anonfun$5(ProtoTypes.scala:428)
	at dotty.tools.dotc.typer.ProtoTypes$FunProto.cacheTypedArg(ProtoTypes.scala:359)
	at dotty.tools.dotc.typer.ProtoTypes$FunProto.typedArg(ProtoTypes.scala:429)
	at dotty.tools.dotc.typer.Applications$ApplyToUntyped.typedArg(Applications.scala:850)
	at dotty.tools.dotc.typer.Applications$ApplyToUntyped.typedArg(Applications.scala:850)
	at dotty.tools.dotc.typer.Applications$Application.addTyped$1(Applications.scala:544)
	at dotty.tools.dotc.typer.Applications$Application.matchArgs(Applications.scala:609)
	at dotty.tools.dotc.typer.Applications$Application.init(Applications.scala:447)
	at dotty.tools.dotc.typer.Applications$TypedApply.<init>(Applications.scala:735)
	at dotty.tools.dotc.typer.Applications$ApplyToUntyped.<init>(Applications.scala:849)
	at dotty.tools.dotc.typer.Applications.ApplyTo(Applications.scala:1057)
	at dotty.tools.dotc.typer.Applications.ApplyTo$(Applications.scala:317)
	at dotty.tools.dotc.typer.Typer.ApplyTo(Typer.scala:106)
	at dotty.tools.dotc.typer.Applications.simpleApply$1(Applications.scala:904)
	at dotty.tools.dotc.typer.Applications.realApply$5$$anonfun$4(Applications.scala:983)
	at dotty.tools.dotc.typer.Typer.tryEither(Typer.scala:2949)
	at dotty.tools.dotc.typer.Applications.realApply$1(Applications.scala:994)
	at dotty.tools.dotc.typer.Applications.typedApply(Applications.scala:1032)
	at dotty.tools.dotc.typer.Applications.typedApply$(Applications.scala:317)
	at dotty.tools.dotc.typer.Typer.typedApply(Typer.scala:106)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2693)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2756)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2821)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2825)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2941)
	at dotty.tools.dotc.typer.Typer.typedValDef(Typer.scala:2092)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2667)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2755)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2821)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2825)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2847)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2897)
	at dotty.tools.dotc.typer.Typer.typedBlockStats(Typer.scala:1025)
	at dotty.tools.dotc.typer.Typer.typedBlock(Typer.scala:1029)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2701)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2756)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2821)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2825)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2941)
	at dotty.tools.dotc.typer.Namer.typedAheadExpr$$anonfun$1(Namer.scala:1424)
	at dotty.tools.dotc.typer.Namer.typedAhead(Namer.scala:1414)
	at dotty.tools.dotc.typer.Namer.typedAheadExpr(Namer.scala:1424)
	at dotty.tools.dotc.typer.Namer.typedAheadRhs$1$$anonfun$1(Namer.scala:1676)
	at dotty.tools.dotc.typer.PrepareInlineable$.dropInlineIfError(PrepareInlineable.scala:225)
	at dotty.tools.dotc.typer.Namer.typedAheadRhs$2(Namer.scala:1676)
	at dotty.tools.dotc.typer.Namer.rhsType$1(Namer.scala:1684)
	at dotty.tools.dotc.typer.Namer.cookedRhsType$1(Namer.scala:1711)
	at dotty.tools.dotc.typer.Namer.lhsType$1(Namer.scala:1712)
	at dotty.tools.dotc.typer.Namer.inferredResultType(Namer.scala:1723)
	at dotty.tools.dotc.typer.Namer.inferredType$1(Namer.scala:1463)
	at dotty.tools.dotc.typer.Namer.valOrDefDefSig(Namer.scala:1470)
	at dotty.tools.dotc.typer.Namer.defDefSig(Namer.scala:1554)
	at dotty.tools.dotc.typer.Namer$Completer.typeSig(Namer.scala:755)
	at dotty.tools.dotc.typer.Namer$Completer.completeInCreationContext(Namer.scala:887)
	at dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:779)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:167)
	at dotty.tools.dotc.core.Denotations$Denotation.completeInfo$1(Denotations.scala:188)
	at dotty.tools.dotc.core.Denotations$Denotation.info(Denotations.scala:190)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:369)
	at dotty.tools.dotc.typer.Typer.retrieveSym(Typer.scala:2635)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2660)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2755)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2821)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2825)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2847)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2897)
	at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:2352)
	at dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$2(Typer.scala:2681)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2685)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2755)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2821)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2825)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2847)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2897)
	at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:2475)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2726)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2756)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2821)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2825)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2941)
	at dotty.tools.dotc.typer.FrontEnd.liftedTree1$1(FrontEnd.scala:79)
	at dotty.tools.dotc.typer.FrontEnd.typeCheck$$anonfun$1(FrontEnd.scala:84)
	at dotty.tools.dotc.typer.FrontEnd.monitor(FrontEnd.scala:43)
	at dotty.tools.dotc.typer.FrontEnd.typeCheck(FrontEnd.scala:85)
	at dotty.tools.dotc.typer.FrontEnd.runOn$$anonfun$3(FrontEnd.scala:120)
	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.FrontEnd.runOn(FrontEnd.scala:120)
	at dotty.tools.dotc.Run.runPhases$4$$anonfun$4(Run.scala:205)
	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$5(Run.scala:216)
	at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:224)
	at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
	at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:67)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:231)
	at dotty.tools.dotc.Run.compileSources(Run.scala:166)
	at dotty.tools.dotc.Run.compile(Run.scala:150)
	at dotty.tools.dotc.Driver.doCompile(Driver.scala:39)
	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:92)
	at org.jetbrains.jps.incremental.scala.local.IdeaIncrementalCompiler.compile(IdeaIncrementalCompiler.scala:57)
	at org.jetbrains.jps.incremental.scala.local.LocalServer.doCompile(LocalServer.scala:52)
	at org.jetbrains.jps.incremental.scala.local.LocalServer.compile(LocalServer.scala:30)
	at org.jetbrains.jps.incremental.scala.remote.Main$.compileLogic(Main.scala:179)
	at org.jetbrains.jps.incremental.scala.remote.Main$.$anonfun$handleCommand$1(Main.scala:162)
	at org.jetbrains.jps.incremental.scala.remote.Main$.decorated$1(Main.scala:152)
	at org.jetbrains.jps.incremental.scala.remote.Main$.handleCommand(Main.scala:159)
	at org.jetbrains.jps.incremental.scala.remote.Main$.serverLogic(Main.scala:135)
	at org.jetbrains.jps.incremental.scala.remote.Main$.nailMain(Main.scala:72)
	at org.jetbrains.jps.incremental.scala.remote.Main.nailMain(Main.scala)
	at jdk.internal.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at com.martiansoftware.nailgun.NGSession.run(NGSession.java:319)

Expectation

Give an error like "Can't use wildcards here" or "Nonsensical bound for argument x".

@smarter
Copy link
Member

smarter commented Oct 18, 2021

(x: _ <: Int) => ??? should definitely be rejected by the parser, like it already is in Scala 2.

@smarter smarter added area:parser Spree Suitable for a future Spree labels Oct 18, 2021
@KacperFKorban KacperFKorban self-assigned this Oct 19, 2021
smarter added a commit that referenced this issue Oct 27, 2021
solves dotc assertion error on (non-sensical?) parameter type. #13769
@KacperFKorban
Copy link
Member

Fixed in #13830

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:parser itype:bug Spree Suitable for a future Spree
Projects
None yet
Development

No branches or pull requests

3 participants