diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/files/neg/structural.check | 2 | ||||
-rw-r--r-- | test/files/neg/structural.scala | 10 | ||||
-rw-r--r-- | test/files/neg/unit2anyref.check | 10 | ||||
-rw-r--r-- | test/files/neg/unit2anyref.scala | 3 |
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 |