Closed
Description
The following code crashes in the pickler on master (0f8c950, retesting on latest). The trouble is probably in computing mImpl.Map
out of an argument for mImpl
of type Nothing
. Presumably, the code should compile successfully; mImpl.Map
should be >: Nothing <: Any
, so that passing Nothing
is fine.
Treating mImpl.Map
as an error would instead violate the Liskov Substitution Principle — we do that already, but that's unfortunate.
import scala.collection.immutable.HashMap
trait MapImpl {
type Key
type Value
type Map
val lookup: Map => Key => Value
}
class HashMapImpl[K, V] extends MapImpl {
type Key = K
type Value = V
type Map = HashMap[K, V]
val lookup: Map => Key => Value = m => k => m(k)
}
object Foo {
val Server0:
(mImpl: MapImpl) => mImpl.Map => mImpl.Key => mImpl.Value
= mImpl => mImpl.lookup
val Client:
(server: (mImpl: MapImpl & {type Key = String} & {type Value = Int}) => mImpl.Map => String => Int) => Int =
// server => server(??? : (HashMapImpl[String, Int]))(???)("test lookup key") //works
// server => server(HashMapImpl[String, Int])(???)("") //works
server => server(???)(???)("test lookup key") // crashes
}
cannot take signature of (v1: ?1.Map): String => Int
exception occurred while compiling testcase-2019-05-13-14.38.scala
NoExplanation(cannot resolve reference to type [cannot display due to assertion failed: denotation class Nothing invalid in run 1. ValidFor: Period(1..10, run = 2), raw string = Skolem(1188445627)].Map
the classfile defining the type might be missing from the classpath) while compiling testcase-2019-05-13-14.38.scala
Exception in thread "main" dotty.tools.dotc.core.MissingType:
at dotty.tools.dotc.core.TypeErasure.dotty$tools$dotc$core$TypeErasure$$sigName(TypeErasure.scala:551)
at dotty.tools.dotc.core.TypeErasure$.sigName(TypeErasure.scala:152)
at dotty.tools.dotc.core.Signature.prepend$$anonfun$1(Signature.scala:98)
at scala.collection.immutable.List.map(List.scala:286)
at dotty.tools.dotc.core.Signature.prepend(Signature.scala:98)
at dotty.tools.dotc.core.Types$MethodType.computeSignature(Types.scala:3203)
at dotty.tools.dotc.core.Types$SignatureCachingType.signature(Types.scala:2891)
at dotty.tools.dotc.core.Types$MethodOrPoly.signature(Types.scala:3042)
at dotty.tools.dotc.core.Denotations$SingleDenotation.signature(Denotations.scala:727)
at dotty.tools.dotc.core.Types$NamedType.computeSignature(Types.scala:1801)
at dotty.tools.dotc.core.Types$SignatureCachingType.signature(Types.scala:2891)
at dotty.tools.dotc.core.Types$NamedType.signature(Types.scala:1758)
at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:367)
at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$2(TreePickler.scala:378)
at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
at dotty.tools.dotc.core.tasty.TreePickler.withLength(TreePickler.scala:44)
at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:380)
at dotty.tools.dotc.core.tasty.TreePickler.pickleTree(TreePickler.scala:369)
at dotty.tools.dotc.core.tasty.TreePickler.pickleTree$$anonfun$2(TreePickler.scala:378)