aboutsummaryrefslogtreecommitdiff
path: root/tests/untried/neg/t5060.scala
diff options
context:
space:
mode:
Diffstat (limited to 'tests/untried/neg/t5060.scala')
-rw-r--r--tests/untried/neg/t5060.scala19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/untried/neg/t5060.scala b/tests/untried/neg/t5060.scala
new file mode 100644
index 000000000..4d934a9a1
--- /dev/null
+++ b/tests/untried/neg/t5060.scala
@@ -0,0 +1,19 @@
+class A[+T] {
+ val foo0 = {
+ class AsVariantAsIWantToBe { def contains(x: T) = () }
+ new AsVariantAsIWantToBe
+ }
+ def foo1 = {
+ class VarianceIsTheSpiceOfTypes { def contains(x: T) = () }
+ new VarianceIsTheSpiceOfTypes
+ }
+}
+
+object Test {
+ def main(args: Array[String]): Unit = {
+ val xs: A[String] = new A[String]
+ println(xs.foo0 contains "abc")
+ println((xs: A[Any]).foo0 contains 5)
+ // java.lang.NoSuchMethodException: A$AsVariantAsIWantToBe$1.contains(java.lang.String)
+ }
+}