diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2015-06-21 06:17:59 +1000 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2015-06-23 08:43:53 +1000 |
commit | 1531900bffb2bed6288eda4e0945b0e6dea3f23d (patch) | |
tree | c4df9581205cf4e405457052c837520eca13f0ce /test/files/neg/t6895b.scala | |
parent | a3beedac5b957e3954be288b1be7c52a1d7d31b0 (diff) | |
download | scala-1531900bffb2bed6288eda4e0945b0e6dea3f23d.tar.gz scala-1531900bffb2bed6288eda4e0945b0e6dea3f23d.tar.bz2 scala-1531900bffb2bed6288eda4e0945b0e6dea3f23d.zip |
SI-6895 Test cases to explain the limitations in tcpoly inference
I've determined that the failure in this bug report boils down
to SI-2712. Submitting my working as neg tests for posterity.
The type error disabmiguator develops a serious stutter with this
example. I'll fix that in the following commit.
Diffstat (limited to 'test/files/neg/t6895b.scala')
-rw-r--r-- | test/files/neg/t6895b.scala | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/test/files/neg/t6895b.scala b/test/files/neg/t6895b.scala new file mode 100644 index 0000000000..c465065011 --- /dev/null +++ b/test/files/neg/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) +} |