summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@typesafe.com>2014-03-18 15:37:23 -0700
committerAdriaan Moors <adriaan.moors@typesafe.com>2014-03-18 15:37:23 -0700
commit06655acb8a15db57bf659b622d2a18ca3d834bc5 (patch)
tree4fe4168eaf96dbd3b6ece421bbad10f6331926d6 /test
parentdf44b2718dcc489a057d2a60cdaadffed2ce0df5 (diff)
parent9f42c09e4e1dd8f56ac98c5e79b45912f111e8de (diff)
downloadscala-06655acb8a15db57bf659b622d2a18ca3d834bc5.tar.gz
scala-06655acb8a15db57bf659b622d2a18ca3d834bc5.tar.bz2
scala-06655acb8a15db57bf659b622d2a18ca3d834bc5.zip
Merge pull request #3639 from retronym/ticket/8341
SI-8341 Refine handoff of undet. params from implicit search
Diffstat (limited to 'test')
-rw-r--r--test/files/neg/t8431.check27
-rw-r--r--test/files/neg/t8431.scala63
2 files changed, 90 insertions, 0 deletions
diff --git a/test/files/neg/t8431.check b/test/files/neg/t8431.check
new file mode 100644
index 0000000000..75351a8ae7
--- /dev/null
+++ b/test/files/neg/t8431.check
@@ -0,0 +1,27 @@
+t8431.scala:24: error: type mismatch;
+ found : CanBuildFrom[Invariant[Nothing]]
+ required: CanBuildFrom[Invariant[G]]
+ s.combined // fail
+ ^
+t8431.scala:24: error: value combined is not a member of Invariant[Nothing]
+ s.combined // fail
+ ^
+t8431.scala:35: error: type mismatch;
+ found : CanBuildFrom[Invariant[Nothing]]
+ required: CanBuildFrom[Invariant[G]]
+ s.combined // was okay!
+ ^
+t8431.scala:35: error: value combined is not a member of Invariant[Nothing]
+ s.combined // was okay!
+ ^
+t8431.scala:45: error: type mismatch;
+ found : CanBuildFrom[Invariant[Nothing]]
+ required: CanBuildFrom[Invariant[G]]
+ convert2(s).combined
+ ^
+t8431.scala:48: error: type mismatch;
+ found : CanBuildFrom[Invariant[Nothing]]
+ required: CanBuildFrom[Invariant[G]]
+ {val c1 = convert2(s); c1.combined}
+ ^
+6 errors found
diff --git a/test/files/neg/t8431.scala b/test/files/neg/t8431.scala
new file mode 100644
index 0000000000..29b852d0c0
--- /dev/null
+++ b/test/files/neg/t8431.scala
@@ -0,0 +1,63 @@
+trait Covariant[+A]
+trait Invariant[A] extends Covariant[A @annotation.unchecked.uncheckedVariance]
+
+trait Combinable[G] {
+ def combined = 0
+}
+
+trait CanBuildFrom[+C]
+
+object C {
+ implicit def convert1[G, TRAVONCE[+e] <: Covariant[e]]
+ (xs: TRAVONCE[G]): Combinable[G] = ???
+
+ implicit def convert2[G, SET[e] <: Invariant[e]]
+ (xs: SET[_ <: G])
+ (implicit cbf: CanBuildFrom[SET[G]]): Combinable[G] = ???
+
+ implicit def cbf[A]: CanBuildFrom[Invariant[A]] = ???
+}
+
+class Test1 {
+ import C.{cbf, convert1, convert2}
+ val s: Invariant[Nothing] = ???
+ s.combined // fail
+}
+
+class Test2 {
+ import C.{cbf, convert2, convert1}
+
+ val s: Invariant[Nothing] = ???
+
+ // Non-uniformity with Test1 was due to order of typechecking implicit candidates:
+ // the last candidate typechecked was the only one that could contribute undetermined type parameters
+ // to the enclosing context, due to mutation of `Context#undetparam` in `doTypedApply`.
+ s.combined // was okay!
+}
+
+
+class TestExplicit {
+ import C.{cbf, convert2}
+
+ val s: Invariant[Nothing] = ???
+
+ // Now the implicit Test fail uniformly as per this explicit conversion
+ convert2(s).combined
+
+ // Breaking this expression down makes it work.
+ {val c1 = convert2(s); c1.combined}
+}
+
+// These ones work before and after; infering G=Null doesn't need to contribute an undetermined type param.
+class Test3 {
+ import C.{cbf, convert1, convert2}
+ val s: Invariant[Null] = ???
+ s.combined // okay
+}
+
+class Test4 {
+ import C.{cbf, convert2, convert1}
+
+ val s: Invariant[Null] = ???
+ s.combined // okay
+}