Skip to content

ClassCastException in OrderingConstraint.nonParamBounds #4720

Closed
@panacekcz

Description

@panacekcz

Seems to work in release 0.8.0, crash in master:

cce.scala:

object Test {
  def main(args: Array[String]):Unit = m(1)
  def m[Y<:Int, Z>:Int, W>:Z<:Y](d:Y):Unit={}
}

dotc cce.scala:

exception occurred while typechecking cce.scala
exception occurred while compiling cce.scala
Exception in thread "main" java.lang.ClassCastException: dotty.tools.dotc.core.Types$CachedTypeRef cannot be cast to dotty.tools.dotc.core.Types$TypeBounds
        at dotty.tools.dotc.core.OrderingConstraint.nonParamBounds(OrderingConstraint.scala:195)
        at dotty.tools.dotc.core.ConstraintHandling.$anonfun$addToConstraint$2(ConstraintHandling.scala:350)
        at scala.runtime.java8.JFunction1$mcZI$sp.apply(JFunction1$mcZI$sp.java:12)
        at scala.collection.Iterator.forall(Iterator.scala:956)
        at scala.collection.Iterator.forall$(Iterator.scala:954)
        at scala.collection.AbstractIterator.forall(Iterator.scala:1432)
        at scala.collection.IterableLike.forall(IterableLike.scala:74)
        at scala.collection.IterableLike.forall$(IterableLike.scala:73)
        at scala.collection.AbstractIterable.forall(Iterable.scala:54)
        at dotty.tools.dotc.core.ConstraintHandling.addToConstraint(ConstraintHandling.scala:348)
        at dotty.tools.dotc.core.ConstraintHandling.addToConstraint$(ConstraintHandling.scala:344)
        at dotty.tools.dotc.core.TypeComparer.addToConstraint(TypeComparer.scala:19)
        at dotty.tools.dotc.typer.ProtoTypes$.constrained(ProtoTypes.scala:459)
        at dotty.tools.dotc.typer.Typer.adapt1(Typer.scala:2534)
        at dotty.tools.dotc.typer.Typer.$anonfun$adapt$1(Typer.scala:2091)
        at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
        at dotty.tools.dotc.typer.Typer.adapt(Typer.scala:2086)
        at dotty.tools.dotc.typer.Typer.$anonfun$typed$2(Typer.scala:1873)
        at dotty.tools.dotc.reporting.trace$.apply(trace.scala:40)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1869)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1885)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:1944)
        at dotty.tools.dotc.typer.Applications.$anonfun$typedApply$1(Applications.scala:694)
        at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
        at dotty.tools.dotc.typer.Applications.realApply$1(Applications.scala:692)
        at dotty.tools.dotc.typer.Applications.typedApply(Applications.scala:792)
        at dotty.tools.dotc.typer.Applications.typedApply$(Applications.scala:690)
        at dotty.tools.dotc.typer.Typer.typedApply(Typer.scala:82)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:1791)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1842)
        at dotty.tools.dotc.typer.Typer.$anonfun$typed$2(Typer.scala:1873)
        at dotty.tools.dotc.reporting.trace$.apply(trace.scala:40)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1869)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1885)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:1944)
        at dotty.tools.dotc.typer.Typer.$anonfun$typedDefDef$1(Typer.scala:1431)
        at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
        at dotty.tools.dotc.typer.Typer.typedDefDef(Typer.scala:1410)
        at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:1779)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1841)
        at dotty.tools.dotc.typer.Typer.$anonfun$typed$2(Typer.scala:1873)
        at dotty.tools.dotc.reporting.trace$.apply(trace.scala:40)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1869)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1885)
        at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:1904)
        at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:1933)
        at dotty.tools.dotc.typer.Typer.$anonfun$typedClassDef$1(Typer.scala:1536)
        at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
        at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:1458)
        at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:1782)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1841)
        at dotty.tools.dotc.typer.Typer.$anonfun$typed$2(Typer.scala:1873)
        at dotty.tools.dotc.reporting.trace$.apply(trace.scala:40)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1869)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1885)
        at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:1904)
        at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:1933)
        at dotty.tools.dotc.typer.Typer.$anonfun$typedPackageDef$1(Typer.scala:1648)
        at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
        at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:1641)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:1821)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1842)
        at dotty.tools.dotc.typer.Typer.$anonfun$typed$2(Typer.scala:1873)
        at dotty.tools.dotc.reporting.trace$.apply(trace.scala:40)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1869)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1885)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:1944)
        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:194)
        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