summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/files/neg/t8079a.check4
-rw-r--r--test/files/neg/t8079a.scala4
-rw-r--r--test/files/neg/variances.check2
-rw-r--r--test/files/pos/fields_widen_trait_var.scala4
-rw-r--r--test/files/pos/t8079b.scala7
-rw-r--r--test/junit/scala/runtime/LambdaDeserializerTest.java1
-rw-r--r--test/junit/scala/tools/testing/ClearAfterClass.java1
-rw-r--r--test/pending/neg/t8079d.check4
-rw-r--r--test/pending/neg/t8079d.scala4
-rw-r--r--test/pending/pos/t8079c.scala7
10 files changed, 37 insertions, 1 deletions
diff --git a/test/files/neg/t8079a.check b/test/files/neg/t8079a.check
new file mode 100644
index 0000000000..6bbe78afa6
--- /dev/null
+++ b/test/files/neg/t8079a.check
@@ -0,0 +1,4 @@
+t8079a.scala:3: error: contravariant type I occurs in covariant position in type C.this.X of value b
+ def f2(b: X): Unit
+ ^
+one error found
diff --git a/test/files/neg/t8079a.scala b/test/files/neg/t8079a.scala
new file mode 100644
index 0000000000..4997ea282e
--- /dev/null
+++ b/test/files/neg/t8079a.scala
@@ -0,0 +1,4 @@
+trait C[-I] {
+ private[this] type X = C[I]
+ def f2(b: X): Unit
+}
diff --git a/test/files/neg/variances.check b/test/files/neg/variances.check
index cb1a60a632..3c1545a375 100644
--- a/test/files/neg/variances.check
+++ b/test/files/neg/variances.check
@@ -19,7 +19,7 @@ variances.scala:74: error: covariant type A occurs in contravariant position in
variances.scala:89: error: covariant type T occurs in invariant position in type T of type A
type A = T
^
-variances.scala:90: error: covariant type T occurs in contravariant position in type => test.TestAlias.B[C.this.A] of method foo
+variances.scala:90: error: covariant type A occurs in contravariant position in type => test.TestAlias.B[C.this.A] of method foo
def foo: B[A]
^
8 errors found
diff --git a/test/files/pos/fields_widen_trait_var.scala b/test/files/pos/fields_widen_trait_var.scala
new file mode 100644
index 0000000000..0ea9d9629a
--- /dev/null
+++ b/test/files/pos/fields_widen_trait_var.scala
@@ -0,0 +1,4 @@
+// check that the `var x` below is assigned the type `Int`, and not `Constant(0)`,
+// and that we can assign to it (if it gets a constant type, the `x` in `x = 42`
+// is constant-folded to `0` and we can't find a setter..
+trait C { protected final var x = 0; x = 42 }
diff --git a/test/files/pos/t8079b.scala b/test/files/pos/t8079b.scala
new file mode 100644
index 0000000000..f3b7b78077
--- /dev/null
+++ b/test/files/pos/t8079b.scala
@@ -0,0 +1,7 @@
+trait F1[/* - */T, /* + */ R]
+
+object Test {
+ import scala.annotation.unchecked._
+ type VariantF1[-T, +R] = F1[T @uncheckedVariance, R @uncheckedVariance]
+ trait C[+T] { def foo: VariantF1[Any, T] }
+}
diff --git a/test/junit/scala/runtime/LambdaDeserializerTest.java b/test/junit/scala/runtime/LambdaDeserializerTest.java
index 3ed1ae1365..4e9c5c8954 100644
--- a/test/junit/scala/runtime/LambdaDeserializerTest.java
+++ b/test/junit/scala/runtime/LambdaDeserializerTest.java
@@ -136,6 +136,7 @@ public final class LambdaDeserializerTest {
}
}
+ @SuppressWarnings("unchecked")
private <A> A deserizalizeLambdaCreatingAllowedMap(A f1, HashMap<String, MethodHandle> cache, MethodHandles.Lookup lookup) {
SerializedLambda serialized = writeReplace(f1);
HashMap<String, MethodHandle> allowed = createAllowedMap(lookup, serialized);
diff --git a/test/junit/scala/tools/testing/ClearAfterClass.java b/test/junit/scala/tools/testing/ClearAfterClass.java
index 95e170ec13..7f87f9a4d7 100644
--- a/test/junit/scala/tools/testing/ClearAfterClass.java
+++ b/test/junit/scala/tools/testing/ClearAfterClass.java
@@ -45,6 +45,7 @@ public class ClearAfterClass {
}
}
+ @SuppressWarnings("unchecked")
public <T> T cached(String key, scala.Function0<T> t) {
Map<String, Object> perClassCache = cache.get(getClass());
return (T) perClassCache.computeIfAbsent(key, s -> t.apply());
diff --git a/test/pending/neg/t8079d.check b/test/pending/neg/t8079d.check
new file mode 100644
index 0000000000..f63f4902f8
--- /dev/null
+++ b/test/pending/neg/t8079d.check
@@ -0,0 +1,4 @@
+t8079d.scala:3: error: contravariant type I occurs in covariant position in type C.this.X of value b
+ def f2(b: X): Unit
+ ^
+one error found
diff --git a/test/pending/neg/t8079d.scala b/test/pending/neg/t8079d.scala
new file mode 100644
index 0000000000..ad420b99e3
--- /dev/null
+++ b/test/pending/neg/t8079d.scala
@@ -0,0 +1,4 @@
+trait C[-I] {
+ protected[this] type X = C[I]
+ def f2(b: X): Unit
+}
diff --git a/test/pending/pos/t8079c.scala b/test/pending/pos/t8079c.scala
new file mode 100644
index 0000000000..ae7f37e2bf
--- /dev/null
+++ b/test/pending/pos/t8079c.scala
@@ -0,0 +1,7 @@
+trait F1[/* - */T, /* + */ R]
+
+object Test {
+ import scala.annotation.unchecked._
+ private[this] type VariantF1[-T, +R] = F1[T @uncheckedVariance, R @uncheckedVariance]
+ trait C[+T] { def foo: VariantF1[Any, T] }
+}