Closed
Description
minimized code
In code below, f
eta-expands to (=>Int)=>Int
- that seems to be intentional.
But what if a type variable is instantiated to the type of the by-name parameter (i assume ExprType
)?
object O{
def f(i: => Int): Int = 1
def m[A](a: A => Int) = 2
def n = m(f)
}
Stack trace
exception occurred while typechecking byname-typevar.scala
exception occurred while compiling byname-typevar.scala
java.lang.AssertionError: assertion failed while compiling byname-typevar.scala
Exception in thread "main" java.lang.AssertionError: assertion failed
at dotty.DottyPredef$.assertFail(DottyPredef.scala:16)
at dotty.tools.dotc.core.OrderingConstraint.replace(OrderingConstraint.scala:386)
at dotty.tools.dotc.core.OrderingConstraint.replace(OrderingConstraint.scala:382)
at dotty.tools.dotc.core.Types$TypeVar.instantiateWith(Types.scala:3993)
at dotty.tools.dotc.core.Types$TypeVar.instantiate(Types.scala:4005)
at dotty.tools.dotc.typer.Inferencing.doInstantiate$1(Inferencing.scala:500)
at dotty.tools.dotc.typer.Inferencing.interpolateTypeVars(Inferencing.scala:503)
at dotty.tools.dotc.typer.Typer.interpolateTypeVars(Typer.scala:83)
at dotty.tools.dotc.typer.Typer.simplify(Typer.scala:2216)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2204)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2240)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2252)
at dotty.tools.dotc.typer.Namer.typedAheadExpr$$anonfun$1(Namer.scala:1262)
at dotty.tools.dotc.typer.Namer.typedAhead(Namer.scala:1252)
at dotty.tools.dotc.typer.Namer.typedAheadExpr(Namer.scala:1262)
at dotty.tools.dotc.typer.Namer.rhsType$2(Namer.scala:1396)
at dotty.tools.dotc.typer.Namer.cookedRhsType$1(Namer.scala:1407)
at dotty.tools.dotc.typer.Namer.lhsType$1(Namer.scala:1408)
at dotty.tools.dotc.typer.Namer.inferredType$1(Namer.scala:1419)
at dotty.tools.dotc.typer.Namer.valOrDefDefSig(Namer.scala:1427)
at dotty.tools.dotc.typer.Namer.defDefSig(Namer.scala:1499)
at dotty.tools.dotc.typer.Namer$Completer.typeSig(Namer.scala:815)
at dotty.tools.dotc.typer.Namer$Completer.completeInCreationContext(Namer.scala:935)
at dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:843)
at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:258)
at dotty.tools.dotc.core.Denotations$Denotation.completeInfo$1(Denotations.scala:185)
at dotty.tools.dotc.core.Denotations$Denotation.info(Denotations.scala:187)
at dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:398)
at dotty.tools.dotc.typer.Typer.retrieveSym(Typer.scala:2096)
at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2121)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2201)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2240)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2252)
at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2274)
at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2318)
at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:1805)
at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2134)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2201)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2240)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2252)
at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2274)
at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:2318)
at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:1931)
at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2175)
at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2202)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2240)
at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2252)
at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2360)
at dotty.tools.dotc.typer.FrontEnd.liftedTree1$2(FrontEnd.scala:78)
at dotty.tools.dotc.typer.FrontEnd.typeCheck$$anonfun$1(FrontEnd.scala:83)
at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
at dotty.tools.dotc.typer.FrontEnd.monitor(FrontEnd.scala:42)
at dotty.tools.dotc.typer.FrontEnd.typeCheck(FrontEnd.scala:84)
at dotty.tools.dotc.typer.FrontEnd.runOn$$anonfun$3(FrontEnd.scala:114)
at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
at scala.collection.immutable.List.foreach(List.scala:305)
at dotty.tools.dotc.typer.FrontEnd.runOn(FrontEnd.scala:114)
at dotty.tools.dotc.Run.runPhases$4$$anonfun$4(Run.scala:167)
at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
at dotty.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:177)
at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:185)
at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:65)
at dotty.tools.dotc.Run.compileUnits(Run.scala:192)
at dotty.tools.dotc.Run.compileSources(Run.scala:129)
at dotty.tools.dotc.Run.compile(Run.scala:112)
at dotty.tools.dotc.Driver.doCompile(Driver.scala:36)
at dotty.tools.dotc.Driver.process(Driver.scala:189)
at dotty.tools.dotc.Driver.process(Driver.scala:158)
at dotty.tools.dotc.Driver.process(Driver.scala:170)
at dotty.tools.dotc.Driver.main(Driver.scala:197)
at dotty.tools.dotc.Main.main(Main.scala)