Skip to content

Parser should reject wildcards in invalid positions #4373

Closed
@sir-wabbit

Description

@sir-wabbit

Seems to be caused by wildcards in unions or intersections in type bounds.

class X[A >: _ | X[_]]
// or
class X[A >: _ | _]
// or
class X[A <: (Int & _)]
Exception in thread "main" java.lang.AssertionError: assertion failed: TypeBounds(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Any)) AppliedType(TypeRef(ThisType(TypeRef(ThisType(TypeRef(NoPrefix,module class <empty>)),module class App$)),class X),List(TypeBounds(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Any))))
	at scala.Predef$.assert(Predef.scala:219)
	at dotty.tools.dotc.core.Types$OrType.<init>(Types.scala:2523)
	at dotty.tools.dotc.core.Types$CachedOrType.<init>(Types.scala:2551)
	at dotty.tools.dotc.core.Types$OrType$.apply(Types.scala:2556)
	at dotty.tools.dotc.typer.TypeAssigner.assignType(TypeAssigner.scala:488)
	at dotty.tools.dotc.typer.TypeAssigner.assignType$(TypeAssigner.scala:487)
	at dotty.tools.dotc.typer.Typer.assignType(Typer.scala:83)
	at dotty.tools.dotc.typer.Typer.$anonfun$typedOrTypeTree$1(Typer.scala:1188)
	at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
	at dotty.tools.dotc.typer.Typer.typedOrTypeTree(Typer.scala:1184)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:1801)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1829)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:1816)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1829)
	at dotty.tools.dotc.typer.Typer.$anonfun$typed$2(Typer.scala:1860)
	at dotty.tools.dotc.reporting.trace$.op1$3(trace.scala:32)
	at dotty.tools.dotc.reporting.trace$.apply(trace.scala:33)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1856)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1868)
	at dotty.tools.dotc.typer.Typer.$anonfun$typedTypeBoundsTree$1(Typer.scala:1286)
	at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
	at dotty.tools.dotc.typer.Typer.typedTypeBoundsTree(Typer.scala:1284)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:1806)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1829)
	at dotty.tools.dotc.typer.Typer.$anonfun$typed$2(Typer.scala:1860)
	at dotty.tools.dotc.reporting.trace$.op1$3(trace.scala:32)
	at dotty.tools.dotc.reporting.trace$.apply(trace.scala:33)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1856)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1868)
	at dotty.tools.dotc.typer.Namer.$anonfun$typedAheadType$1(Namer.scala:1006)
	at dotty.tools.dotc.typer.Namer.typedAheadImpl(Namer.scala:999)
	at dotty.tools.dotc.typer.Namer.typedAheadType(Namer.scala:1006)
	at dotty.tools.dotc.typer.Namer.typeDefSig(Namer.scala:1256)
	at dotty.tools.dotc.typer.Namer$TypeDefCompleter.typeSig(Namer.scala:878)
	at dotty.tools.dotc.typer.Namer$Completer.completeInCreationContext(Namer.scala:843)
	at dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:821)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:248)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeInfo$1(SymDenotations.scala:211)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.info(SymDenotations.scala:213)
	at dotty.tools.dotc.ast.desugar$DerivedFromParamTree.derivedTree(Desugar.scala:98)
	at dotty.tools.dotc.ast.desugar$DerivedFromParamTree.derivedTree(Desugar.scala:51)
	at dotty.tools.dotc.typer.Typer.$anonfun$typedTypeTree$1(Typer.scala:1158)
	at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
	at dotty.tools.dotc.typer.Typer.typedTypeTree(Typer.scala:1153)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:1798)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1829)
	at dotty.tools.dotc.typer.Typer.$anonfun$typed$2(Typer.scala:1860)
	at dotty.tools.dotc.reporting.trace$.op1$3(trace.scala:32)
	at dotty.tools.dotc.reporting.trace$.apply(trace.scala:33)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1856)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1868)
	at dotty.tools.dotc.typer.Namer.$anonfun$typedAheadType$1(Namer.scala:1006)
	at dotty.tools.dotc.typer.Namer.typedAheadImpl(Namer.scala:999)
	at dotty.tools.dotc.typer.Namer.typedAheadType(Namer.scala:1006)
	at dotty.tools.dotc.typer.Namer.typeDefSig(Namer.scala:1256)
	at dotty.tools.dotc.typer.Namer$TypeDefCompleter.typeSig(Namer.scala:878)
	at dotty.tools.dotc.typer.Namer$Completer.completeInCreationContext(Namer.scala:843)
	at dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:821)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:248)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeInfo$1(SymDenotations.scala:211)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.info(SymDenotations.scala:213)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:354)
	at dotty.tools.dotc.typer.Namer.$anonfun$defDefSig$1(Namer.scala:1217)
	at dotty.tools.dotc.typer.Namer.$anonfun$defDefSig$1$adapted(Namer.scala:1217)
	at scala.collection.immutable.List.foreach(List.scala:389)
	at dotty.tools.dotc.typer.Namer.defDefSig(Namer.scala:1217)
	at dotty.tools.dotc.typer.Namer$Completer.typeSig(Namer.scala:796)
	at dotty.tools.dotc.typer.Namer$Completer.completeInCreationContext(Namer.scala:843)
	at dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:821)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:248)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeInfo$1(SymDenotations.scala:211)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.info(SymDenotations.scala:213)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:354)
	at dotty.tools.dotc.typer.Namer$ClassCompleter.completeInCreationContext(Namer.scala:979)
	at dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:821)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:248)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeInfo$1(SymDenotations.scala:211)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.info(SymDenotations.scala:213)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:354)
	at dotty.tools.dotc.typer.Typer.retrieveSym(Typer.scala:1730)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:1755)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1828)
	at dotty.tools.dotc.typer.Typer.$anonfun$typed$2(Typer.scala:1860)
	at dotty.tools.dotc.reporting.trace$.op1$3(trace.scala:32)
	at dotty.tools.dotc.reporting.trace$.apply(trace.scala:33)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1856)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1868)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:1887)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:1916)
	at dotty.tools.dotc.typer.Typer.$anonfun$typedClassDef$1(Typer.scala:1529)
	at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
	at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:1455)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:1768)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1828)
	at dotty.tools.dotc.typer.Typer.$anonfun$typed$2(Typer.scala:1860)
	at dotty.tools.dotc.reporting.trace$.op1$3(trace.scala:32)
	at dotty.tools.dotc.reporting.trace$.apply(trace.scala:33)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1856)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1868)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:1887)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:1916)
	at dotty.tools.dotc.typer.Typer.$anonfun$typedPackageDef$1(Typer.scala:1636)
	at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
	at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:1627)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:1808)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1829)
	at dotty.tools.dotc.typer.Typer.$anonfun$typed$2(Typer.scala:1860)
	at dotty.tools.dotc.reporting.trace$.op1$3(trace.scala:32)
	at dotty.tools.dotc.reporting.trace$.apply(trace.scala:33)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1856)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1868)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:1928)
	at dotty.tools.dotc.typer.FrontEnd.$anonfun$typeCheck$1(FrontEnd.scala:66)
	at dotty.tools.dotc.typer.FrontEnd.monitor(FrontEnd.scala:34)
	at dotty.tools.dotc.typer.FrontEnd.typeCheck(FrontEnd.scala:64)
	at dotty.tools.dotc.typer.FrontEnd.$anonfun$runOn$7(FrontEnd.scala:95)
	at dotty.tools.dotc.typer.FrontEnd.$anonfun$runOn$7$adapted(FrontEnd.scala:95)
	at scala.collection.immutable.List.foreach(List.scala:389)
	at dotty.tools.dotc.typer.FrontEnd.runOn(FrontEnd.scala:95)
	at dotty.tools.dotc.Run.$anonfun$compileUnits$3(Run.scala:174)
	at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
	at dotty.tools.dotc.util.Stats$.trackTime(Stats.scala:47)
	at dotty.tools.dotc.Run.$anonfun$compileUnits$2(Run.scala:171)
	at dotty.tools.dotc.Run.$anonfun$compileUnits$2$adapted(Run.scala:169)
	at scala.collection.IndexedSeqOptimized.foreach(IndexedSeqOptimized.scala:32)
	at scala.collection.IndexedSeqOptimized.foreach$(IndexedSeqOptimized.scala:29)
	at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:191)
	at dotty.tools.dotc.Run.runPhases$1(Run.scala:169)
	at dotty.tools.dotc.Run.$anonfun$compileUnits$1(Run.scala:194)
	at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
	at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:88)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:149)
	at dotty.tools.dotc.Run.compileSources(Run.scala:136)
	at dotty.tools.dotc.Run.compile(Run.scala:120)
	at dotty.tools.dotc.Driver.doCompile(Driver.scala:29)
	at dotty.tools.dotc.Driver.process(Driver.scala:127)
	at dotty.tools.dotc.Driver.process(Driver.scala:96)
	at dotty.tools.dotc.Driver.process(Driver.scala:108)
	at dotty.tools.dotc.Driver.main(Driver.scala:135)
	at dotty.tools.dotc.Main.main(Main.scala)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions