summaryrefslogtreecommitdiff
path: root/test/files/neg
diff options
context:
space:
mode:
Diffstat (limited to 'test/files/neg')
-rw-r--r--test/files/neg/saferJavaConversions.check6
-rw-r--r--test/files/neg/saferJavaConversions.scala20
-rw-r--r--test/files/neg/t5580a.check6
-rw-r--r--test/files/neg/t5580a.scala11
4 files changed, 43 insertions, 0 deletions
diff --git a/test/files/neg/saferJavaConversions.check b/test/files/neg/saferJavaConversions.check
new file mode 100644
index 0000000000..0e53d2c437
--- /dev/null
+++ b/test/files/neg/saferJavaConversions.check
@@ -0,0 +1,6 @@
+saferJavaConversions.scala:13: error: type mismatch;
+ found : String("a")
+ required: Foo
+ val v = map.get("a") // now this is a type error
+ ^
+one error found
diff --git a/test/files/neg/saferJavaConversions.scala b/test/files/neg/saferJavaConversions.scala
new file mode 100644
index 0000000000..f0611204e6
--- /dev/null
+++ b/test/files/neg/saferJavaConversions.scala
@@ -0,0 +1,20 @@
+
+case class Foo(s: String)
+
+object Test {
+ def f1 = {
+ import scala.collection.JavaConversions._
+ val map: Map[Foo, String] = Map(Foo("a") -> "a", Foo("b") -> "b")
+ val v = map.get("a") // should be a type error, actually returns null
+ }
+ def f2 = {
+ import scala.collection.convert.wrapAsScala._
+ val map: Map[Foo, String] = Map(Foo("a") -> "a", Foo("b") -> "b")
+ val v = map.get("a") // now this is a type error
+ }
+ def f3 = {
+ import scala.collection.convert.wrapAsJava._
+ val map: Map[Foo, String] = Map(Foo("a") -> "a", Foo("b") -> "b")
+ val v = map.get("a")
+ }
+}
diff --git a/test/files/neg/t5580a.check b/test/files/neg/t5580a.check
new file mode 100644
index 0000000000..50a31857d5
--- /dev/null
+++ b/test/files/neg/t5580a.check
@@ -0,0 +1,6 @@
+t5580a.scala:9: error: polymorphic expression cannot be instantiated to expected type;
+ found : [A]scala.collection.mutable.Set[A]
+ required: scala.collection.mutable.Map[bar,scala.collection.mutable.Set[bar]]
+ if (map.get(tmp).isEmpty) map.put(tmp,collection.mutable.Set())
+ ^
+one error found
diff --git a/test/files/neg/t5580a.scala b/test/files/neg/t5580a.scala
new file mode 100644
index 0000000000..742f0e85ea
--- /dev/null
+++ b/test/files/neg/t5580a.scala
@@ -0,0 +1,11 @@
+import scala.collection.mutable.WeakHashMap
+
+class bar{ }
+class foo{
+ val map = WeakHashMap[AnyRef, collection.mutable.Map[bar, collection.mutable.Set[bar]]]()
+
+ def test={
+ val tmp:bar=null
+ if (map.get(tmp).isEmpty) map.put(tmp,collection.mutable.Set())
+ }
+}