summaryrefslogtreecommitdiff
path: root/test/files/neg
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2009-06-22 20:26:34 +0000
committerPaul Phillips <paulp@improving.org>2009-06-22 20:26:34 +0000
commitc22ebf74e0ec17d18bf097c1d47426bd647010a5 (patch)
treeaf3b6479902ecc6c98931d9b7e6ca786d1cfb80f /test/files/neg
parent2ebff1417c9cfd39251a6a95a72c17af24b813c1 (diff)
downloadscala-c22ebf74e0ec17d18bf097c1d47426bd647010a5.tar.gz
scala-c22ebf74e0ec17d18bf097c1d47426bd647010a5.tar.bz2
scala-c22ebf74e0ec17d18bf097c1d47426bd647010a5.zip
Attempted to resolve the improbable mess surrou...
Attempted to resolve the improbable mess surrounding implicit conversions from Unit. Modified test case which relied on the supposedly verboten behavior; verbotenized () => AnyRef; added new test case which fails if verboten behavior should ever return.
Diffstat (limited to 'test/files/neg')
-rw-r--r--test/files/neg/structural.check2
-rw-r--r--test/files/neg/structural.scala10
-rw-r--r--test/files/neg/unit2anyref.check10
-rw-r--r--test/files/neg/unit2anyref.scala3
4 files changed, 19 insertions, 6 deletions
diff --git a/test/files/neg/structural.check b/test/files/neg/structural.check
index 3a4a627b26..cc2b5c5920 100644
--- a/test/files/neg/structural.check
+++ b/test/files/neg/structural.check
@@ -2,7 +2,7 @@ structural.scala:3: error: illegal dependent method type
def f(x: { type D; def m: D }) = x.m
^
structural.scala:19: error: illegal dependent method type
- def f9[C <: AnyRef](x: AnyRef{ type D <: AnyRef; def m[E >: Null <: AnyRef](x: AnyRef): D }) = x.m[Tata](()) //suceed
+ def f9[C <: AnyRef](x: AnyRef{ type D <: AnyRef; def m[E >: Null <: AnyRef](x: AnyRef): D }) = x.m[Tata](new AnyRef) //suceed
^
structural.scala:10: error: Parameter type in structural refinement may not refer to abstract type defined outside that same refinement
def f1[C <: AnyRef](x: AnyRef{ type D <: AnyRef; def m[E >: Null <: AnyRef](x: A): AnyRef; val x: A }) = x.m[Tata](x.x) //fail
diff --git a/test/files/neg/structural.scala b/test/files/neg/structural.scala
index cf75de9322..ae15c4b166 100644
--- a/test/files/neg/structural.scala
+++ b/test/files/neg/structural.scala
@@ -13,11 +13,11 @@ object Test extends Application {
def f4[C <: AnyRef](x: AnyRef{ type D <: AnyRef; def m[E >: Null <: AnyRef](x: D): AnyRef; val x: D }) = x.m[Tata](x.x) //suceed
def f5[C <: AnyRef](x: AnyRef{ type D <: AnyRef; def m[E >: Null <: AnyRef](x: E): AnyRef; val x: Tata }) = x.m[Tata](x.x) //suceed
- def f6[C <: AnyRef](x: AnyRef{ type D <: AnyRef; def m[E >: Null <: AnyRef](x: AnyRef): A }) = x.m[Tata](()) //suceed
- def f7[C <: AnyRef](x: AnyRef{ type D <: AnyRef; def m[E >: Null <: AnyRef](x: AnyRef): B }) = x.m[Tata](()) //suceed
- def f8[C <: AnyRef](x: AnyRef{ type D <: AnyRef; def m[E >: Null <: AnyRef](x: AnyRef): C }) = x.m[Tata](()) //suceed
- def f9[C <: AnyRef](x: AnyRef{ type D <: AnyRef; def m[E >: Null <: AnyRef](x: AnyRef): D }) = x.m[Tata](()) //suceed
- def f0[C <: AnyRef](x: AnyRef{ type D <: AnyRef; def m[E >: Null <: AnyRef](x: AnyRef): E }) = x.m[Tata](()) //suceed
+ def f6[C <: AnyRef](x: AnyRef{ type D <: AnyRef; def m[E >: Null <: AnyRef](x: AnyRef): A }) = x.m[Tata](new AnyRef) //suceed
+ def f7[C <: AnyRef](x: AnyRef{ type D <: AnyRef; def m[E >: Null <: AnyRef](x: AnyRef): B }) = x.m[Tata](new AnyRef) //suceed
+ def f8[C <: AnyRef](x: AnyRef{ type D <: AnyRef; def m[E >: Null <: AnyRef](x: AnyRef): C }) = x.m[Tata](new AnyRef) //suceed
+ def f9[C <: AnyRef](x: AnyRef{ type D <: AnyRef; def m[E >: Null <: AnyRef](x: AnyRef): D }) = x.m[Tata](new AnyRef) //suceed
+ def f0[C <: AnyRef](x: AnyRef{ type D <: AnyRef; def m[E >: Null <: AnyRef](x: AnyRef): E }) = x.m[Tata](new AnyRef) //suceed
}
diff --git a/test/files/neg/unit2anyref.check b/test/files/neg/unit2anyref.check
new file mode 100644
index 0000000000..6459949341
--- /dev/null
+++ b/test/files/neg/unit2anyref.check
@@ -0,0 +1,10 @@
+unit2anyref.scala:2: error: type mismatch;
+ found : Unit
+ required: AnyRef
+Note that implicit conversions are not applicable because they are ambiguous:
+ both method orderingToOrdered in object Predef of type [T](x: T)(implicit ord: Ordering[T])Ordered[T]
+ and method any2stringadd in object Predef of type (x: Any)scala.runtime.StringAdd
+ are possible conversion functions from Unit to AnyRef
+ val x: AnyRef = () // this should not succeed.
+ ^
+one error found
diff --git a/test/files/neg/unit2anyref.scala b/test/files/neg/unit2anyref.scala
new file mode 100644
index 0000000000..3f5c2d19a9
--- /dev/null
+++ b/test/files/neg/unit2anyref.scala
@@ -0,0 +1,3 @@
+object Test {
+ val x: AnyRef = () // this should not succeed.
+} \ No newline at end of file