Skip to content

AssertionError - TypeBounds in AndType when using wildcard argument #5844

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

Closed
panacekcz opened this issue Feb 4, 2019 · 0 comments
Closed

Comments

@panacekcz
Copy link
Contributor

Passing a wildcard argument to a parameter that is used in an intersection can lead to an attempt to put type bounds into an intersection type.

Source:

trait A
trait B[X, Y]{
  def m(): X
}
trait C[X] extends B[X, X & A]

object O{
  def m(c: C[_]) = {
    val x = c.m()
  }
}

Output:

assertion failure for C[_](c) <:< ?{ m: ? }, frozen = false
exception occurred while typechecking andbounds.scala
exception occurred while compiling andbounds.scala
java.lang.AssertionError: assertion failed:  & A / TypeBounds(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Any)) & TypeRef(ThisType(TypeRef(NoPrefix,module class <empty>)),class A) while compiling andbounds.scala
Exception in thread "main" java.lang.AssertionError: assertion failed:  & A / TypeBounds(TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Nothing),TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Any)) & TypeRef(ThisType(TypeRef(NoPrefix,module class <empty>)),class A)
	at scala.Predef$.assert(Predef.scala:223)
	at dotty.tools.dotc.core.Types$AndType$.apply(Types.scala:2689)
	at dotty.tools.dotc.core.Types$AndType$.make(Types.scala:2707)
	at dotty.tools.dotc.core.Types$AndType.derivedAndType(Types.scala:2670)
	at dotty.tools.dotc.core.Types$TypeMap.derivedAndType(Types.scala:4355)
	at dotty.tools.dotc.core.Types$TypeMap.mapOver(Types.scala:4452)
	at dotty.tools.dotc.core.Substituters.subst1(Substituters.scala:35)
	at dotty.tools.dotc.core.Substituters.subst1$(Substituters.scala:24)
	at dotty.tools.dotc.core.Contexts$Context.subst1(Contexts.scala:70)
	at dotty.tools.dotc.core.Substituters$Subst1Map.apply(Substituters.scala:168)
	at dotty.tools.dotc.core.Types$TypeMap.$anonfun$mapOver$6(Types.scala:4401)
	at dotty.tools.dotc.core.Types$VariantTraversal.atVariance(Types.scala:4327)
	at dotty.tools.dotc.core.Types$TypeMap.mapArgs$1(Types.scala:4401)
	at dotty.tools.dotc.core.Types$TypeMap.mapArgs$1(Types.scala:4403)
	at dotty.tools.dotc.core.Types$TypeMap.mapOver(Types.scala:4409)
	at dotty.tools.dotc.core.Substituters.subst1(Substituters.scala:35)
	at dotty.tools.dotc.core.Substituters.subst1$(Substituters.scala:24)
	at dotty.tools.dotc.core.Contexts$Context.subst1(Contexts.scala:70)
	at dotty.tools.dotc.core.Types$Type.subst(Types.scala:1403)
	at dotty.tools.dotc.core.SymDenotations$ClassDenotation.computeApplied$1(SymDenotations.scala:1788)
	at dotty.tools.dotc.core.SymDenotations$ClassDenotation.recur$2(SymDenotations.scala:1793)
	at dotty.tools.dotc.core.SymDenotations$ClassDenotation.computeTypeProxy$1(SymDenotations.scala:1801)
	at dotty.tools.dotc.core.SymDenotations$ClassDenotation.recur$2(SymDenotations.scala:1809)
	at dotty.tools.dotc.core.SymDenotations$ClassDenotation.$anonfun$baseTypeOf$10(SymDenotations.scala:1849)
	at dotty.tools.dotc.reporting.trace$.conditionally(trace.scala:22)
	at dotty.tools.dotc.reporting.trace$.onDebug(trace.scala:14)
	at dotty.tools.dotc.core.SymDenotations$ClassDenotation.baseTypeOf(SymDenotations.scala:1847)
	at dotty.tools.dotc.core.Types$Type.$anonfun$baseType$1(Types.scala:918)
	at dotty.tools.dotc.util.Stats$.track(Stats.scala:37)
	at dotty.tools.dotc.core.Types$Type.baseType(Types.scala:917)
	at dotty.tools.dotc.core.TypeOps$AsSeenFromMap.$anonfun$apply$2(TypeOps.scala:41)
	at dotty.tools.dotc.reporting.trace$.conditionally(trace.scala:22)
	at dotty.tools.dotc.core.TypeOps$AsSeenFromMap.toPrefix$1(TypeOps.scala:35)
	at dotty.tools.dotc.core.TypeOps$AsSeenFromMap.$anonfun$apply$4(TypeOps.scala:60)
	at dotty.tools.dotc.reporting.trace$.conditionally(trace.scala:22)
	at dotty.tools.dotc.core.TypeOps$AsSeenFromMap.apply(TypeOps.scala:51)
	at dotty.tools.dotc.core.TypeOps$AsSeenFromMap.$anonfun$apply$5(TypeOps.scala:58)
	at dotty.tools.dotc.core.Types$VariantTraversal.atVariance(Types.scala:4327)
	at dotty.tools.dotc.core.TypeOps$AsSeenFromMap.$anonfun$apply$4(TypeOps.scala:58)
	at dotty.tools.dotc.reporting.trace$.conditionally(trace.scala:22)
	at dotty.tools.dotc.core.TypeOps$AsSeenFromMap.apply(TypeOps.scala:51)
	at dotty.tools.dotc.core.Types$TypeMap.mapOverLambda$1(Types.scala:4438)
	at dotty.tools.dotc.core.Types$TypeMap.mapOver(Types.scala:4440)
	at dotty.tools.dotc.core.TypeOps$AsSeenFromMap.$anonfun$apply$4(TypeOps.scala:64)
	at dotty.tools.dotc.reporting.trace$.conditionally(trace.scala:22)
	at dotty.tools.dotc.core.TypeOps$AsSeenFromMap.apply(TypeOps.scala:51)
	at dotty.tools.dotc.core.TypeOps.asSeenFrom(TypeOps.scala:25)
	at dotty.tools.dotc.core.TypeOps.asSeenFrom$(TypeOps.scala:24)
	at dotty.tools.dotc.core.Contexts$Context.asSeenFrom(Contexts.scala:70)
	at dotty.tools.dotc.core.Types$Type.$anonfun$asSeenFrom$1(Types.scala:828)
	at dotty.tools.dotc.util.Stats$.track(Stats.scala:37)
	at dotty.tools.dotc.core.Types$Type.asSeenFrom(Types.scala:827)
	at dotty.tools.dotc.core.Denotations$SingleDenotation.computeAsSeenFrom(Denotations.scala:1125)
	at dotty.tools.dotc.core.Denotations$SingleDenotation.computeAsSeenFrom(Denotations.scala:705)
	at dotty.tools.dotc.core.Denotations$PreDenotation.asSeenFrom(Denotations.scala:128)
	at dotty.tools.dotc.core.SymDenotations$ClassDenotation.findMember(SymDenotations.scala:1702)
	at dotty.tools.dotc.core.Types$Type.go$1(Types.scala:561)
	at dotty.tools.dotc.core.Types$Type.findMember(Types.scala:711)
	at dotty.tools.dotc.core.Types$Type.memberBasedOnFlags(Types.scala:544)
	at dotty.tools.dotc.core.Types$Type.$anonfun$member$1(Types.scala:529)
	at dotty.tools.dotc.util.Stats$.track(Stats.scala:37)
	at dotty.tools.dotc.core.Types$Type.member(Types.scala:529)
	at dotty.tools.dotc.typer.ProtoTypes$SelectionProto.isMatchedBy(ProtoTypes.scala:137)
	at dotty.tools.dotc.core.TypeComparer.isMatchedByProto(TypeComparer.scala:1230)
	at dotty.tools.dotc.core.TypeComparer.firstTry$1(TypeComparer.scala:243)
	at dotty.tools.dotc.core.TypeComparer.$anonfun$recur$2(TypeComparer.scala:966)
	at scala.runtime.java8.JFunction0$mcZ$sp.apply(JFunction0$mcZ$sp.java:23)
	at dotty.tools.dotc.reporting.trace$.apply(trace.scala:40)
	at dotty.tools.dotc.reporting.trace$.apply(trace.scala:44)
	at dotty.tools.dotc.core.TypeComparer.recur(TypeComparer.scala:148)
	at dotty.tools.dotc.core.TypeComparer.isSubType(TypeComparer.scala:139)
	at dotty.tools.dotc.core.TypeComparer.isSubType(TypeComparer.scala:146)
	at dotty.tools.dotc.core.TypeComparer.topLevelSubType(TypeComparer.scala:125)
	at dotty.tools.dotc.core.Types$Type.$anonfun$$less$colon$less$1(Types.scala:835)
	at scala.runtime.java8.JFunction0$mcZ$sp.apply(JFunction0$mcZ$sp.java:23)
	at dotty.tools.dotc.util.Stats$.track(Stats.scala:37)
	at dotty.tools.dotc.core.Types$Type.$less$colon$less(Types.scala:835)
	at dotty.tools.dotc.typer.Typer.adaptNoArgsOther$1(Typer.scala:2570)
	at dotty.tools.dotc.typer.Typer.adaptNoArgs$1(Typer.scala:2640)
	at dotty.tools.dotc.typer.Typer.adapt1(Typer.scala:2806)
	at dotty.tools.dotc.typer.Typer.$anonfun$adapt$3(Typer.scala:2287)
	at dotty.tools.dotc.reporting.trace$.apply(trace.scala:40)
	at dotty.tools.dotc.typer.Typer.$anonfun$adapt$1(Typer.scala:2286)
	at dotty.tools.dotc.util.Stats$.track(Stats.scala:37)
	at dotty.tools.dotc.typer.Typer.adapt(Typer.scala:2286)
	at dotty.tools.dotc.typer.Typer.$anonfun$typed$2(Typer.scala:2046)
	at dotty.tools.dotc.reporting.trace$.apply(trace.scala:40)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2039)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2058)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2130)
	at dotty.tools.dotc.typer.Typer.typeSelectOnTerm$1(Typer.scala:430)
	at dotty.tools.dotc.typer.Typer.$anonfun$typedSelect$1(Typer.scala:465)
	at dotty.tools.dotc.util.Stats$.track(Stats.scala:37)
	at dotty.tools.dotc.typer.Typer.typedSelect(Typer.scala:427)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:1938)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2011)
	at dotty.tools.dotc.typer.Typer.$anonfun$typed$2(Typer.scala:2046)
	at dotty.tools.dotc.reporting.trace$.apply(trace.scala:40)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2039)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2058)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2130)
	at dotty.tools.dotc.typer.Applications.$anonfun$typedApply$1(Applications.scala:767)
	at dotty.tools.dotc.util.Stats$.track(Stats.scala:37)
	at dotty.tools.dotc.typer.Applications.realApply$1(Applications.scala:765)
	at dotty.tools.dotc.typer.Applications.typedApply(Applications.scala:868)
	at dotty.tools.dotc.typer.Applications.typedApply$(Applications.scala:763)
	at dotty.tools.dotc.typer.Typer.typedApply(Typer.scala:80)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:1958)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2012)
	at dotty.tools.dotc.typer.Typer.$anonfun$typed$2(Typer.scala:2046)
	at dotty.tools.dotc.reporting.trace$.apply(trace.scala:40)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2039)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2058)
	at dotty.tools.dotc.typer.Namer.$anonfun$typedAheadExpr$1(Namer.scala:1080)
	at dotty.tools.dotc.typer.Namer.typedAheadImpl(Namer.scala:1070)
	at dotty.tools.dotc.typer.Namer.typedAheadExpr(Namer.scala:1080)
	at dotty.tools.dotc.typer.Namer.rhsType$1(Namer.scala:1203)
	at dotty.tools.dotc.typer.Namer.cookedRhsType$1(Namer.scala:1215)
	at dotty.tools.dotc.typer.Namer.lhsType$1(Namer.scala:1216)
	at dotty.tools.dotc.typer.Namer.inferredType$1(Namer.scala:1234)
	at dotty.tools.dotc.typer.Namer.valOrDefDefSig(Namer.scala:1242)
	at dotty.tools.dotc.typer.Namer$Completer.typeSig(Namer.scala:751)
	at dotty.tools.dotc.typer.Namer$Completer.completeInCreationContext(Namer.scala:867)
	at dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:781)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:235)
	at dotty.tools.dotc.core.Denotations$Denotation.completeInfo$1(Denotations.scala:180)
	at dotty.tools.dotc.core.Denotations$Denotation.info(Denotations.scala:182)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:341)
	at dotty.tools.dotc.typer.Typer.retrieveSym(Typer.scala:1910)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:1935)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2011)
	at dotty.tools.dotc.typer.Typer.$anonfun$typed$2(Typer.scala:2046)
	at dotty.tools.dotc.reporting.trace$.apply(trace.scala:40)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2039)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2058)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2077)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2119)
	at dotty.tools.dotc.typer.Typer.typedBlockStats(Typer.scala:681)
	at dotty.tools.dotc.typer.Typer.$anonfun$typedBlock$1(Typer.scala:684)
	at dotty.tools.dotc.util.Stats$.track(Stats.scala:37)
	at dotty.tools.dotc.typer.Typer.typedBlock(Typer.scala:683)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:1965)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2012)
	at dotty.tools.dotc.typer.Typer.$anonfun$typed$2(Typer.scala:2046)
	at dotty.tools.dotc.reporting.trace$.apply(trace.scala:40)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2039)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2058)
	at dotty.tools.dotc.typer.Namer.$anonfun$typedAheadExpr$1(Namer.scala:1080)
	at dotty.tools.dotc.typer.Namer.typedAheadImpl(Namer.scala:1070)
	at dotty.tools.dotc.typer.Namer.typedAheadExpr(Namer.scala:1080)
	at dotty.tools.dotc.typer.Namer.rhsType$1(Namer.scala:1203)
	at dotty.tools.dotc.typer.Namer.cookedRhsType$1(Namer.scala:1215)
	at dotty.tools.dotc.typer.Namer.lhsType$1(Namer.scala:1216)
	at dotty.tools.dotc.typer.Namer.inferredType$1(Namer.scala:1234)
	at dotty.tools.dotc.typer.Namer.valOrDefDefSig(Namer.scala:1242)
	at dotty.tools.dotc.typer.Namer.defDefSig(Namer.scala:1312)
	at dotty.tools.dotc.typer.Namer$Completer.typeSig(Namer.scala:755)
	at dotty.tools.dotc.typer.Namer$Completer.completeInCreationContext(Namer.scala:867)
	at dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:781)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:235)
	at dotty.tools.dotc.core.Denotations$Denotation.completeInfo$1(Denotations.scala:180)
	at dotty.tools.dotc.core.Denotations$Denotation.info(Denotations.scala:182)
	at dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:341)
	at dotty.tools.dotc.typer.Typer.retrieveSym(Typer.scala:1910)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:1935)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2011)
	at dotty.tools.dotc.typer.Typer.$anonfun$typed$2(Typer.scala:2046)
	at dotty.tools.dotc.reporting.trace$.apply(trace.scala:40)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2039)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2058)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2077)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2119)
	at dotty.tools.dotc.typer.Typer.$anonfun$typedClassDef$1(Typer.scala:1652)
	at dotty.tools.dotc.util.Stats$.track(Stats.scala:37)
	at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:1563)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:1948)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2011)
	at dotty.tools.dotc.typer.Typer.$anonfun$typed$2(Typer.scala:2046)
	at dotty.tools.dotc.reporting.trace$.apply(trace.scala:40)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2039)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2058)
	at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2077)
	at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2119)
	at dotty.tools.dotc.typer.Typer.$anonfun$typedPackageDef$1(Typer.scala:1773)
	at dotty.tools.dotc.util.Stats$.track(Stats.scala:37)
	at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:1766)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:1990)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2012)
	at dotty.tools.dotc.typer.Typer.$anonfun$typed$2(Typer.scala:2046)
	at dotty.tools.dotc.reporting.trace$.apply(trace.scala:40)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2039)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2058)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2130)
	at dotty.tools.dotc.typer.FrontEnd.$anonfun$typeCheck$1(FrontEnd.scala:61)
	at dotty.tools.dotc.typer.FrontEnd.monitor(FrontEnd.scala:35)
	at dotty.tools.dotc.typer.FrontEnd.typeCheck(FrontEnd.scala:59)
	at dotty.tools.dotc.typer.FrontEnd.$anonfun$runOn$6(FrontEnd.scala:89)
	at dotty.tools.dotc.typer.FrontEnd.$anonfun$runOn$6$adapted(FrontEnd.scala:89)
	at scala.collection.immutable.List.foreach(List.scala:392)
	at dotty.tools.dotc.typer.FrontEnd.runOn(FrontEnd.scala:89)
	at dotty.tools.dotc.Run.$anonfun$compileUnits$3(Run.scala:158)
	at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
	at dotty.tools.dotc.util.Stats$.trackTime(Stats.scala:49)
	at dotty.tools.dotc.Run.$anonfun$compileUnits$2(Run.scala:155)
	at dotty.tools.dotc.Run.$anonfun$compileUnits$2$adapted(Run.scala:153)
	at scala.collection.IndexedSeqOptimized.foreach(IndexedSeqOptimized.scala:36)
	at scala.collection.IndexedSeqOptimized.foreach$(IndexedSeqOptimized.scala:33)
	at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:198)
	at dotty.tools.dotc.Run.runPhases$1(Run.scala:153)
	at dotty.tools.dotc.Run.$anonfun$compileUnits$1(Run.scala:178)
	at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
	at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:102)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:133)
	at dotty.tools.dotc.Run.compileSources(Run.scala:120)
	at dotty.tools.dotc.Run.compile(Run.scala:104)
	at dotty.tools.dotc.Driver.doCompile(Driver.scala:33)
	at dotty.tools.dotc.Driver.process(Driver.scala:166)
	at dotty.tools.dotc.Driver.process(Driver.scala:135)
	at dotty.tools.dotc.Driver.process(Driver.scala:147)
	at dotty.tools.dotc.Driver.main(Driver.scala:174)
	at dotty.tools.dotc.Main.main(Main.scala)
odersky added a commit to dotty-staging/dotty that referenced this issue Feb 11, 2019
odersky added a commit to dotty-staging/dotty that referenced this issue Feb 11, 2019
smarter added a commit that referenced this issue Feb 16, 2019
Fix #5844: Use an approximating type map to substitute parent type params
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants