Closed
Description
Here's a Scastie example
trait Ord[A] { def less(x: A, y: A): Boolean }
object Main {
implicit val intOrd: Ord[Int] = new Ord { // omitted [Int] here
def less(x: Int, y: Int) = x < y
}
def main(args: Array[String]): Unit = ()
}
this results in the following error:
java.lang.ClassCastException: dotty.tools.dotc.core.Types$HKTypeLambda cannot be cast to dotty.tools.dotc.core.Types$PolyType
at dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform(PostTyper.scala:189)
at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform$$anonfun$4(Trees.scala:1185)
at scala.collection.immutable.List.loop$1(List.scala:176)
at scala.collection.immutable.List.mapConserve(List.scala:200)
at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1185)
at dotty.tools.dotc.transform.MacroTransform$Transformer.transform(MacroTransform.scala:59)
at dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform$$anonfun$13(PostTyper.scala:220)
at dotty.tools.dotc.transform.SuperAccessors.wrapTemplate(SuperAccessors.scala:413)
at dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform(PostTyper.scala:220)
at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1168)
at dotty.tools.dotc.transform.MacroTransform$Transformer.transform(MacroTransform.scala:55)
at dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform(PostTyper.scala:245)
at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform$$anonfun$4(Trees.scala:1185)
at scala.collection.immutable.List.loop$1(List.scala:176)
at scala.collection.immutable.List.mapConserve(List.scala:200)
at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1185)
at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transformStats(Trees.scala:1183)
at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1118)
at dotty.tools.dotc.transform.MacroTransform$Transformer.transform(MacroTransform.scala:63)
at dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform(PostTyper.scala:281)
at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1163)
at dotty.tools.dotc.transform.MacroTransform$Transformer.transform(MacroTransform.scala:55)
at dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform(PostTyper.scala:248)
at dotty.tools.dotc.transform.MacroTransform$Transformer.transformStat$1(MacroTransform.scala:43)
at dotty.tools.dotc.transform.MacroTransform$Transformer.transformStats$$anonfun$1(MacroTransform.scala:47)
at dotty.tools.dotc.core.Decorators$ListDecorator$.loop$4(Decorators.scala:62)
at dotty.tools.dotc.core.Decorators$ListDecorator$.mapconserve$extension(Decorators.scala:78)
at dotty.tools.dotc.transform.MacroTransform$Transformer.transformStats(MacroTransform.scala:47)
at dotty.tools.dotc.transform.MacroTransform$Transformer.transform(MacroTransform.scala:61)
at dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform$$anonfun$13(PostTyper.scala:220)
at dotty.tools.dotc.transform.SuperAccessors.wrapTemplate(SuperAccessors.scala:413)
at dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform(PostTyper.scala:220)
at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1168)
at dotty.tools.dotc.transform.MacroTransform$Transformer.transform(MacroTransform.scala:55)
at dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform(PostTyper.scala:245)
at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform$$anonfun$4(Trees.scala:1185)
at scala.collection.immutable.List.loop$1(List.scala:176)
at scala.collection.immutable.List.mapConserve(List.scala:200)
at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1185)
at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transformStats(Trees.scala:1183)
at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1174)
at dotty.tools.dotc.transform.MacroTransform$Transformer.transform(MacroTransform.scala:55)
at dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform(PostTyper.scala:281)
at dotty.tools.dotc.transform.MacroTransform.run(MacroTransform.scala:22)
at dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$2(Phases.scala:283)
at scala.collection.immutable.List.map(List.scala:284)
at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:285)
at dotty.tools.dotc.Run.$anonfun$$anonfun$10(Run.scala:82)
at scala.compat.java8.JProcedure1.apply(JProcedure1.java:18)
at scala.compat.java8.JProcedure1.apply(JProcedure1.java:10)
at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:33)
at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:186)
at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:90)
at scala.compat.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
at dotty.tools.dotc.util.Stats$.monitorHeartBeat(Stats.scala:76)
at dotty.tools.dotc.Run.compileUnits(Run.scala:95)
at dotty.tools.dotc.Run.compileSources(Run.scala:64)
at dotty.tools.dotc.Run.compile(Run.scala:48)
at dotty.tools.dotc.Driver.doCompile(Driver.scala:26)
at dotty.tools.dotc.Driver.process(Driver.scala:124)
at xsbt.CachedCompilerImpl.run(CompilerInterface.scala:63)
at xsbt.CachedCompilerImpl.run(CompilerInterface.scala:53)
at xsbt.CompilerInterface.run(CompilerInterface.scala:37)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sbt.compiler.AnalyzingCompiler.call(AnalyzingCompiler.scala:107)
at sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:53)
at sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:47)
at sbt.compiler.MixedAnalyzingCompiler$$anonfun$compileScala$1$1.apply$mcV$sp(MixedAnalyzingCompiler.scala:50)
at sbt.compiler.MixedAnalyzingCompiler$$anonfun$compileScala$1$1.apply(MixedAnalyzingCompiler.scala:50)
at sbt.compiler.MixedAnalyzingCompiler$$anonfun$compileScala$1$1.apply(MixedAnalyzingCompiler.scala:50)
at sbt.compiler.MixedAnalyzingCompiler.timed(MixedAnalyzingCompiler.scala:74)
at sbt.compiler.MixedAnalyzingCompiler.compileScala$1(MixedAnalyzingCompiler.scala:49)
at sbt.compiler.MixedAnalyzingCompiler.compile(MixedAnalyzingCompiler.scala:64)
at sbt.compiler.IC$$anonfun$compileInternal$1.apply(IncrementalCompiler.scala:160)
at sbt.compiler.IC$$anonfun$compileInternal$1.apply(IncrementalCompiler.scala:160)
at sbt.inc.IncrementalCompile$$anonfun$doCompile$1.apply(Compile.scala:66)
at sbt.inc.IncrementalCompile$$anonfun$doCompile$1.apply(Compile.scala:64)
at sbt.inc.IncrementalCommon.cycle(IncrementalCommon.scala:32)
at sbt.inc.Incremental$$anonfun$1.apply(Incremental.scala:72)
at sbt.inc.Incremental$$anonfun$1.apply(Incremental.scala:71)
at sbt.inc.Incremental$.manageClassfiles(Incremental.scala:99)
at sbt.inc.Incremental$.compile(Incremental.scala:71)
at sbt.inc.IncrementalCompile$.apply(Compile.scala:54)
at sbt.compiler.IC$.compileInternal(IncrementalCompiler.scala:160)
at sbt.compiler.IC$.incrementalCompile(IncrementalCompiler.scala:138)
at sbt.Compiler$.compile(Compiler.scala:155)
at sbt.Defaults$.sbt$Defaults$$compileIncrementalTaskImpl(Defaults.scala:885)
at sbt.Defaults$$anonfun$compileIncrementalTask$1.apply(Defaults.scala:877)
at sbt.Defaults$$anonfun$compileIncrementalTask$1.apply(Defaults.scala:875)
at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
at sbt.std.Transform$$anon$4.work(System.scala:63)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
at sbt.Execute.work(Execute.scala:237)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)