diff options
author | Paul Phillips <paulp@improving.org> | 2012-03-21 12:33:57 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-03-21 12:33:57 -0700 |
commit | a36a05933499acd3aeeb414d36099ea8ae6e6ca9 (patch) | |
tree | fda17e3d9b62a0ba70683ca1782a20d90630c840 /test/files | |
parent | bd8bff3370a124330ee51747826dba855497487c (diff) | |
parent | 5d555ef90f443e20d2e46c668e456df0a643dae8 (diff) | |
download | scala-a36a05933499acd3aeeb414d36099ea8ae6e6ca9.tar.gz scala-a36a05933499acd3aeeb414d36099ea8ae6e6ca9.tar.bz2 scala-a36a05933499acd3aeeb414d36099ea8ae6e6ca9.zip |
Merge branch 'issue/SI-5580' of /scala/trunk into develop
Diffstat (limited to 'test/files')
-rw-r--r-- | test/files/neg/saferJavaConversions.check | 6 | ||||
-rw-r--r-- | test/files/neg/saferJavaConversions.scala | 20 | ||||
-rw-r--r-- | test/files/neg/t5580a.check | 6 | ||||
-rw-r--r-- | test/files/neg/t5580a.scala | 11 | ||||
-rw-r--r-- | test/files/pos/t5580b.scala | 19 |
5 files changed, 62 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()) + } +} diff --git a/test/files/pos/t5580b.scala b/test/files/pos/t5580b.scala new file mode 100644 index 0000000000..d5a4a0a2b2 --- /dev/null +++ b/test/files/pos/t5580b.scala @@ -0,0 +1,19 @@ +/** It's a pos test because it does indeed compile, + * not so much because I'm glad it does. Testing + * that error messages created and discarded during + * implicit search don't blow it up. + */ + +import scala.collection.mutable.WeakHashMap +import scala.collection.JavaConversions._ + +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()) + } +} |