diff options
author | Adriaan Moors <adriaan.moors@epfl.ch> | 2012-07-23 08:50:13 -0700 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@epfl.ch> | 2012-07-23 08:50:13 -0700 |
commit | 3bcd6f8cb5ad63dff3514fd2d74fdcc23959bec2 (patch) | |
tree | be08a99fb120ab98e09f090ba4d3ec48e6049e8a /test | |
parent | 7b62eeea86c62f5e068c366065f8f4c2e6624eb7 (diff) | |
parent | 5c5e8d4dcd151a6e2bf9e7c259c618b9b4eff00f (diff) | |
download | scala-3bcd6f8cb5ad63dff3514fd2d74fdcc23959bec2.tar.gz scala-3bcd6f8cb5ad63dff3514fd2d74fdcc23959bec2.tar.bz2 scala-3bcd6f8cb5ad63dff3514fd2d74fdcc23959bec2.zip |
Merge pull request #975 from adriaanm/ticket-4881b
SI-4881 infer variance from formals, then result
Diffstat (limited to 'test')
-rw-r--r-- | test/files/neg/t5845.check | 5 | ||||
-rw-r--r-- | test/files/pos/t4881.scala | 31 |
2 files changed, 32 insertions, 4 deletions
diff --git a/test/files/neg/t5845.check b/test/files/neg/t5845.check index 8c6100d6de..c0b402fccb 100644 --- a/test/files/neg/t5845.check +++ b/test/files/neg/t5845.check @@ -1,7 +1,4 @@ -t5845.scala:9: error: value +++ is not a member of Int - println(5 +++ 5) - ^ t5845.scala:15: error: value +++ is not a member of Int println(5 +++ 5) ^ -two errors found +one error found diff --git a/test/files/pos/t4881.scala b/test/files/pos/t4881.scala new file mode 100644 index 0000000000..46cfad9793 --- /dev/null +++ b/test/files/pos/t4881.scala @@ -0,0 +1,31 @@ +class Contra[-T] +trait A +trait B extends A +trait C extends B + +// test improved variance inference: first try formals to see in which variance positions the type param appears; +// only when that fails to determine variance, look at result type +object Test { + def contraLBUB[a >: C <: A](): Contra[a] = null + def contraLB[a >: C](): Contra[a] = null + +{ + val x = contraLBUB() //inferred Contra[C] instead of Contra[A] + val x1: Contra[A] = x +} + +{ + val x = contraLB() //inferred Contra[C] instead of Contra[Any] + val x1: Contra[Any] = x +} + +{ + val x = contraLBUB // make sure it does the same thing as its ()-less counterpart + val x1: Contra[A] = x +} + +{ + val x = contraLB + val x1: Contra[Any] = x +} +} |