diff options
author | Martin Odersky <odersky@gmail.com> | 2014-05-09 18:55:10 +0200 |
---|---|---|
committer | Samuel Gruetter <samuel.gruetter@epfl.ch> | 2014-05-20 13:38:49 +0200 |
commit | 394b645dd2d44ff68597527c6c690c73653f1bcb (patch) | |
tree | 22e72a22f891c002d5fef946361d223d6f6fc1a4 /tests/pos/t2429.scala | |
parent | 67e5130e63b10631106490cbc1cec5adcd5273e6 (diff) | |
download | dotty-394b645dd2d44ff68597527c6c690c73653f1bcb.tar.gz dotty-394b645dd2d44ff68597527c6c690c73653f1bcb.tar.bz2 dotty-394b645dd2d44ff68597527c6c690c73653f1bcb.zip |
Fix of pos/t2429
This was a hard nut to crack. The problem exemplified by t2429 is that in a situation like
val x: T = foo(...)
where `foo` needs implicit parameters the expected result type `T` is propagated into the
typechecking of foo(...) and consequently also into the implicit parameter search. This
is often necessary, for instance to instantiate type parameters. But it can lead to overconstrained
searches if in fact the right expansion is
val x: T = viewToT(foo(...)(implicit params))
where `viewToT` is some implicit conversion. The fix handles that case by re-hecking the
application foo(...) with an empty result type, if the implicit parameter search fails.
But the re-checking is very subtle as is explained in the comment to `TyperState#tryWithFallback`.
Diffstat (limited to 'tests/pos/t2429.scala')
-rwxr-xr-x | tests/pos/t2429.scala | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/pos/t2429.scala b/tests/pos/t2429.scala new file mode 100755 index 000000000..4cda3bde1 --- /dev/null +++ b/tests/pos/t2429.scala @@ -0,0 +1,25 @@ +object Msg { + trait T + + trait TSeq + + object TSeq { + implicit def fromSeq(s: Seq[T]): TSeq = sys.error("stub") + } + + def render: Unit = { + val msgs: TSeq = (List[(Any, Any)]().flatMap { + case (a, b) => { + a match { + case _ => b match { + case _ => sys.error("stub") + } + } + } + } /*: Seq[T] Adding this type annotation avoids the compile error.*/) + } +} +object Oops { + implicit def someImplicit(s: Seq[_]): String = sys.error("stub") + def item: String = Nil map { case e: Any => e } +} |