aboutsummaryrefslogtreecommitdiff
path: root/tests/pos
diff options
context:
space:
mode:
authorodersky <odersky@gmail.com>2016-08-26 09:32:16 +0300
committerGitHub <noreply@github.com>2016-08-26 09:32:16 +0300
commitb3005424d449b6280aab9b2c92d13c1c9e914f76 (patch)
tree4c4c90a784dec3784a578e9bbd76628ee416f845 /tests/pos
parent0e8f05d88bfef95fac59f522fd9d06792126bd11 (diff)
parent41b7ca73480e868d830b08db382debf049418973 (diff)
downloaddotty-b3005424d449b6280aab9b2c92d13c1c9e914f76.tar.gz
dotty-b3005424d449b6280aab9b2c92d13c1c9e914f76.tar.bz2
dotty-b3005424d449b6280aab9b2c92d13c1c9e914f76.zip
Merge pull request #1460 from dotty-staging/fix-t1756
Make sure arguments are evaluated in the correct typer state.
Diffstat (limited to 'tests/pos')
-rw-r--r--tests/pos/t1756.scala33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/pos/t1756.scala b/tests/pos/t1756.scala
new file mode 100644
index 000000000..767eb54a7
--- /dev/null
+++ b/tests/pos/t1756.scala
@@ -0,0 +1,33 @@
+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[CI <: Ring[CI]](c: CI): Poly[CI] = 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, first with type error, after that was fixed with "orphan poly parameter CI".
+}