aboutsummaryrefslogtreecommitdiff
path: root/tests/pending/pos
diff options
context:
space:
mode:
Diffstat (limited to 'tests/pending/pos')
-rw-r--r--tests/pending/pos/boundspropagation.scala26
-rw-r--r--tests/pending/pos/t1164.scala29
-rwxr-xr-xtests/pending/pos/t1756.scala54
-rw-r--r--tests/pending/pos/t2454.scala25
4 files changed, 105 insertions, 29 deletions
diff --git a/tests/pending/pos/boundspropagation.scala b/tests/pending/pos/boundspropagation.scala
new file mode 100644
index 000000000..560d5416c
--- /dev/null
+++ b/tests/pending/pos/boundspropagation.scala
@@ -0,0 +1,26 @@
+// scalac fails for test2/3
+// dotc fails for all three
+object test1 {
+ class Tree[-T >: Null]
+
+
+ def f(x: Any): Tree[Null] = x match {
+ case y: Tree[_] => y
+ }
+}
+object test2 {
+ class Tree[T >: Null]
+
+
+ def f(x: Any): Tree[Null] = x match {
+ case y: Tree[_] => y
+ }
+}
+object test3 {
+ class Tree[+T >: Null]
+
+
+ def f(x: Any): Tree[Null] = x match {
+ case y: Tree[_] => y
+ }
+}
diff --git a/tests/pending/pos/t1164.scala b/tests/pending/pos/t1164.scala
deleted file mode 100644
index ab58c1d6b..000000000
--- a/tests/pending/pos/t1164.scala
+++ /dev/null
@@ -1,29 +0,0 @@
-
-
-object test {
-
- class Foo[a](val arg : a)
-
- object Foo {
- def apply [a](arg : a, right :a) = new Foo[a](arg)
- def unapply [a](m : Foo[a]) = Some (m.arg)
- }
-
- def matchAndGetArgFromFoo[a]( e:Foo[a]):a = {e match { case Foo(x) => x }}
-
-
- // Try the same thing as above but use function as argument to Bar
- // constructor
-
- type FunIntToA [a] = (Int) => a
- class Bar[a] (var f: FunIntToA[a])
-
- object Bar {
- def apply[a](f: FunIntToA[a]) = new Bar[a](f)
- def unapply[a](m: Bar[a]) = Some (m.f)
- }
-
- def matchAndGetFunFromBar[a](b:Bar[a]) : FunIntToA[a] = { b match { case Bar(x) => x}}
-
-
-}
diff --git a/tests/pending/pos/t1756.scala b/tests/pending/pos/t1756.scala
new file mode 100755
index 000000000..1d067c3b0
--- /dev/null
+++ b/tests/pending/pos/t1756.scala
@@ -0,0 +1,54 @@
+
+/**
+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.
+*/
+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
+}
diff --git a/tests/pending/pos/t2454.scala b/tests/pending/pos/t2454.scala
new file mode 100644
index 000000000..00f2e6f67
--- /dev/null
+++ b/tests/pending/pos/t2454.scala
@@ -0,0 +1,25 @@
+package am;
+
+trait One[M[_]] {
+ val x : Int
+}
+
+trait Two[M[_,_]] {
+ val x : Int
+}
+
+object Test {
+ // Works.
+ val x = new Two[Map] {
+ val x = 5
+ }
+
+ val o = new One[java.util.List] {
+ val x = 1
+ }
+
+ // Does not work
+ val y = new Two[java.util.concurrent.ConcurrentHashMap] {
+ val x = 3
+ }
+}