summaryrefslogtreecommitdiff
path: root/test/files/pos/t6895b.scala
diff options
context:
space:
mode:
authorMiles Sabin <miles@milessabin.com>2016-05-20 12:49:25 +0100
committerMiles Sabin <miles@milessabin.com>2016-05-24 08:46:40 +0100
commit892a6d6878accb67e3fe68aefaa256396db05a90 (patch)
tree89024c06147fddf825904bc5891e1ee2cbf4c2d1 /test/files/pos/t6895b.scala
parent207e32df30fd733e4dd1cb28fb8cb5c3153c21a6 (diff)
downloadscala-892a6d6878accb67e3fe68aefaa256396db05a90.tar.gz
scala-892a6d6878accb67e3fe68aefaa256396db05a90.tar.bz2
scala-892a6d6878accb67e3fe68aefaa256396db05a90.zip
SI-2712 Add support for higher order unification
Diffstat (limited to 'test/files/pos/t6895b.scala')
-rw-r--r--test/files/pos/t6895b.scala39
1 files changed, 39 insertions, 0 deletions
diff --git a/test/files/pos/t6895b.scala b/test/files/pos/t6895b.scala
new file mode 100644
index 0000000000..c465065011
--- /dev/null
+++ b/test/files/pos/t6895b.scala
@@ -0,0 +1,39 @@
+trait Foo[F[_]]
+trait Bar[F[_], A]
+
+trait Or[A, B]
+
+class Test {
+ implicit def orFoo[A]: Foo[({type L[X] = Or[A, X]})#L] = ???
+ implicit def barFoo[F[_]](implicit f: Foo[F]): Foo[({type L[X] = Bar[F, X]})#L] = ???
+
+ // Now we can define a couple of type aliases:
+ type StringOr[X] = Or[String, X]
+ type BarStringOr[X] = Bar[StringOr, X]
+
+ // ok
+ implicitly[Foo[BarStringOr]]
+ barFoo[StringOr](null) : Foo[BarStringOr]
+ barFoo(null) : Foo[BarStringOr]
+
+ // nok
+ implicitly[Foo[({type L[X] = Bar[StringOr, X]})#L]]
+ // Let's write the application explicitly, and then
+ // compile with just this line enabled and -explaintypes.
+ barFoo(null) : Foo[({type L[X] = Bar[StringOr, X]})#L]
+
+ // Foo[[X]Bar[F,X]] <: Foo[[X]Bar[[X]Or[String,X],X]]?
+ // Bar[[X]Or[String,X],X] <: Bar[F,X]?
+ // F[_] <: Or[String,_]?
+ // false
+ // false
+ // false
+
+ // Note that the type annotation above is typechecked as
+ // Foo[[X]Bar[[X]Or[String,X],X]], ie the type alias `L`
+ // is eta expanded.
+ //
+ // This is done so that it does not escape its defining scope.
+ // However, one this is done, higher kinded inference
+ // no longer is able to unify F with `StringOr` (SI-2712)
+}