diff options
author | Adriaan Moors <adriaan@lightbend.com> | 2016-10-04 12:48:30 -0500 |
---|---|---|
committer | Adriaan Moors <adriaan@lightbend.com> | 2016-10-04 15:48:33 -0500 |
commit | 20896646122fa82dc81f1405173b09eac37ae7cc (patch) | |
tree | 6422d91f1142c7c393eed6433700ae226d3a2157 /test | |
parent | 1f6006d0d4f8edf4db04915702f8b7e3c8ca1f5e (diff) | |
download | scala-20896646122fa82dc81f1405173b09eac37ae7cc.tar.gz scala-20896646122fa82dc81f1405173b09eac37ae7cc.tar.bz2 scala-20896646122fa82dc81f1405173b09eac37ae7cc.zip |
SI-9943 final/sealed class does not yield SAM type
Cannot subclass such a class. (Well, we could subclass a sealed
class in the same compilation unit. We ignore this for simplicity.)
This is a bit of a sneaky fix for this bug, but our hand
is pretty much forced by other constraints, in this intersection
of overload resolution involving built-in function types and SAMs,
and type inference for higher-order function literals (#5307).
Luckily, in this particular issue, the overloading clash seems
accidental. The `sealed` `<:<` class is not a SAM type as it
cannot be subclassed outside of `Predef`. For simplicity,
we don't consider where the SAM conversion occurs and exclude
all sealed classes from yielding SAM types.
Thanks to Miles for pointing out that `final` was missing in my
first iteration of this fix.
Diffstat (limited to 'test')
-rw-r--r-- | test/files/pos/t9943.scala | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/test/files/pos/t9943.scala b/test/files/pos/t9943.scala new file mode 100644 index 0000000000..0d4717ccbb --- /dev/null +++ b/test/files/pos/t9943.scala @@ -0,0 +1,9 @@ +class Foo[T] { + def toMap[K, V](implicit ev: Foo[T] <:< Foo[(K, V)]): Foo[Map[K, V]] = null + def toMap[K](keySelector: T => K): Foo[Map[K, T]] = null +} + +object Foo { + (??? : Foo[Int]) toMap (_ % 2) + (??? : Foo[(Int, String)]).toMap +} |