aboutsummaryrefslogtreecommitdiff
path: root/tests/pending
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-08-21 11:18:42 +0200
committerMartin Odersky <odersky@gmail.com>2016-08-21 15:19:27 +0200
commit704f4d745e2b71b30e44533d38936cdb43813acf (patch)
tree0426d2f410348c673f04af2bb9febfd1bedf7f8c /tests/pending
parent1b2fc1f016f837ca51c7627d359ed88e24692df6 (diff)
downloaddotty-704f4d745e2b71b30e44533d38936cdb43813acf.tar.gz
dotty-704f4d745e2b71b30e44533d38936cdb43813acf.tar.bz2
dotty-704f4d745e2b71b30e44533d38936cdb43813acf.zip
Make sure arguments are evaluated in the correct typer state.
There's a tricky interaction with caching of typed arguments in FunProto types and backtracking using different typer states. We might end up with a typed argument that is evaluated in one typer state and that is used in another. The problem is that the argument typing might have inserted type variables (maybe by adding polymorphic implicit views) that are not registered in the typer state in which the application is finally typed. In that case we will see an "orphan poly parameter" in pickling. The fix is to discard argument types is their typerstate is not committed to the one in which the application is finally typed. To apply the fix we need to track - for typer states: whether or not it was committed, and what its parent is. - for function prototypes: the typer state in which an argument with cached type was evaluated. Test case is t1756.scala, which produced an "orphan poly parameter CI" before.
Diffstat (limited to 'tests/pending')
-rw-r--r--tests/pending/pos/t1756.scala59
1 files changed, 0 insertions, 59 deletions
diff --git a/tests/pending/pos/t1756.scala b/tests/pending/pos/t1756.scala
deleted file mode 100644
index 34bf273ab..000000000
--- a/tests/pending/pos/t1756.scala
+++ /dev/null
@@ -1,59 +0,0 @@
-
-/**
-This is a tricky issue which has to do with the fact that too much conflicting
-type information is propagated into a single implicit search, where the intended
-solution applies two implicit searches.
-
-Roughly, in x + x * y, the first x is first typed as Poly[A]. That
-means the x * y is then typed as Poly[A]. Then the second x is typed
-as Poly[A], then y is typed as Poly[Poly[A]]. The application x * y
-fails, so the coef2poly implicit conversion is applied to x. That
-means we look for an implicit conversion from type Poly[A] to type
-?{val *(x$1: ?>: Poly[Poly[A]] <: Any): Poly[A]}. Note that the result
-type Poly[A] is propagated into the implicit search. Poly[A] comes as
-expected type from x+, because the lhs x is still typed as a Poly[A].
-This means that the argument of the implicit conversion is typechecked
-with expected type A with Poly[A]. And no solution is found.
-
-To solve this, I added a fallback scheme similar to implicit arguments:
-When an implicit view that adds a method matching given arguments and result
-type fails, try again without the result type.
-
-However, troubles are not yet over. We now get an oprhan poly param C when pickling
-and, if typr printer and -Ylog:front is on, an infinite type of the form
-
- mu x. Ring[LazyRef(x) & A]
-*/
-trait Ring[T <: Ring[T]] {
- def +(that: T): T
- def *(that: T): T
-}
-
-class A extends Ring[A] {
- def +(that: A) = new A
- def *(that: A) = new A
-}
-
-class Poly[C <: Ring[C]](val c: C) extends Ring[Poly[C]] {
- def +(that: Poly[C]) = new Poly(this.c + that.c)
- def *(that: Poly[C]) = new Poly(this.c*that.c)
-}
-
-object Test extends App {
-
- implicit def coef2poly[C <: Ring[C]](c: C): Poly[C] = new Poly(c)
-
- val a = new A
- val x = new Poly(new A)
-
- println(x + a) // works
- println(a + x) // works
-
- val y = new Poly(new Poly(new A))
-
- println(x + y*x) // works
- println(x*y + x) // works
- println(y*x + x) // works
-
- println(x + x*y) // failed before
-}