summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/files/neg/any-vs-anyref.check64
-rw-r--r--test/files/neg/any-vs-anyref.scala29
-rw-r--r--test/files/neg/not-possible-cause.check7
-rw-r--r--test/files/neg/t3614.check4
-rw-r--r--test/files/neg/t6263.check3
-rw-r--r--test/files/neg/t900.check3
-rw-r--r--test/files/run/reflection-equality.check106
-rw-r--r--test/files/run/t5256a.check10
-rw-r--r--test/files/run/t5256b.check10
-rw-r--r--test/files/run/t5256d.check64
-rw-r--r--test/files/run/t5256e.check4
-rw-r--r--test/files/run/t5256f.check8
12 files changed, 205 insertions, 107 deletions
diff --git a/test/files/neg/any-vs-anyref.check b/test/files/neg/any-vs-anyref.check
new file mode 100644
index 0000000000..63c4853130
--- /dev/null
+++ b/test/files/neg/any-vs-anyref.check
@@ -0,0 +1,64 @@
+any-vs-anyref.scala:6: error: type mismatch;
+ found : a.type (with underlying type A)
+ required: AnyRef
+Note that A is bounded only by Equals, which means AnyRef is not a known parent.
+Such types can participate in value classes, but instances
+cannot appear in singleton types or in reference comparisons.
+ def foo1[A <: Product](a: A) = { type X = a.type }
+ ^
+any-vs-anyref.scala:7: error: type mismatch;
+ found : a.type (with underlying type A)
+ required: AnyRef
+Note that A is bounded only by Product, Quux, which means AnyRef is not a known parent.
+Such types can participate in value classes, but instances
+cannot appear in singleton types or in reference comparisons.
+ def foo2[A <: Product with Quux](a: A) = { type X = a.type }
+ ^
+any-vs-anyref.scala:8: error: type mismatch;
+ found : a.type (with underlying type Product)
+ required: AnyRef
+Note that Product extends Any, not AnyRef.
+Such types can participate in value classes, but instances
+cannot appear in singleton types or in reference comparisons.
+ def foo3(a: Product) = { type X = a.type }
+ ^
+any-vs-anyref.scala:9: error: type mismatch;
+ found : Product with Quux
+ required: AnyRef
+Note that the parents of this type (Product, Quux) extend Any, not AnyRef.
+Such types can participate in value classes, but instances
+cannot appear in singleton types or in reference comparisons.
+ def foo4(a: Product with Quux) = { type X = a.type }
+ ^
+any-vs-anyref.scala:10: error: value eq is not a member of Quux with Product
+Note that the parents of this type (Quux, Product) extend Any, not AnyRef.
+Such types can participate in value classes, but instances
+cannot appear in singleton types or in reference comparisons.
+ def foo5(x: Quux with Product) = (x eq "abc") && ("abc" eq x)
+ ^
+any-vs-anyref.scala:11: error: value eq is not a member of Quux with Product{def f: Int}
+Note that the parents of this type (Quux, Product) extend Any, not AnyRef.
+Such types can participate in value classes, but instances
+cannot appear in singleton types or in reference comparisons.
+ def foo6(x: Quux with Product { def f: Int }) = (x eq "abc") && ("abc" eq x)
+ ^
+any-vs-anyref.scala:12: error: type mismatch;
+ found : Quux with Product{def eq(other: String): Boolean}
+ required: AnyRef
+Note that the parents of this type (Quux, Product) extend Any, not AnyRef.
+Such types can participate in value classes, but instances
+cannot appear in singleton types or in reference comparisons.
+ def foo7(x: Quux with Product { def eq(other: String): Boolean }) = (x eq "abc") && ("abc" eq x)
+ ^
+any-vs-anyref.scala:22: error: value eq is not a member of Bippy
+Note that Bippy extends Any, not AnyRef.
+Such types can participate in value classes, but instances
+cannot appear in singleton types or in reference comparisons.
+ def bad1(x: Bippy, y: Bippy) = x eq y
+ ^
+any-vs-anyref.scala:27: error: type mismatch;
+ found : Quux{def g(x: String): String}
+ required: Quux{def g(x: Int): Int}
+ f(new Quux { def g(x: String) = x })
+ ^
+9 errors found
diff --git a/test/files/neg/any-vs-anyref.scala b/test/files/neg/any-vs-anyref.scala
new file mode 100644
index 0000000000..8d237fbaec
--- /dev/null
+++ b/test/files/neg/any-vs-anyref.scala
@@ -0,0 +1,29 @@
+trait Quux extends Any
+trait QuuxRef extends AnyRef
+final class Bippy(val x: Any) extends AnyVal with Quux
+
+object Foo {
+ def foo1[A <: Product](a: A) = { type X = a.type }
+ def foo2[A <: Product with Quux](a: A) = { type X = a.type }
+ def foo3(a: Product) = { type X = a.type }
+ def foo4(a: Product with Quux) = { type X = a.type }
+ def foo5(x: Quux with Product) = (x eq "abc") && ("abc" eq x)
+ def foo6(x: Quux with Product { def f: Int }) = (x eq "abc") && ("abc" eq x)
+ def foo7(x: Quux with Product { def eq(other: String): Boolean }) = (x eq "abc") && ("abc" eq x)
+
+ def ok1[A <: QuuxRef](a: A) = { type X = a.type }
+ def ok2[A <: Product with QuuxRef](a: A) = { type X = a.type }
+ def ok3(a: QuuxRef) = { type X = a.type }
+ def ok4(a: Product with QuuxRef) = { type X = a.type }
+ def ok5(x: QuuxRef with Product) = (x eq "abc") && ("abc" eq x)
+ def ok6(x: QuuxRef with Product { def f: Int }) = (x eq "abc") && ("abc" eq x)
+ def ok7(x: QuuxRef { def eq(other: String): Boolean }) = (x eq "abc") && ("abc" eq x)
+
+ def bad1(x: Bippy, y: Bippy) = x eq y
+}
+
+object Bar {
+ def f(x: Quux { def g(x: Int): Int }): Int = x g 5
+ f(new Quux { def g(x: String) = x })
+ f(new Quux { def g(x: Int) = x })
+}
diff --git a/test/files/neg/not-possible-cause.check b/test/files/neg/not-possible-cause.check
index 9111cd0d3d..5c09fa1545 100644
--- a/test/files/neg/not-possible-cause.check
+++ b/test/files/neg/not-possible-cause.check
@@ -1,10 +1,9 @@
not-possible-cause.scala:2: error: type mismatch;
found : a.type (with underlying type A)
required: AnyRef
-Note that implicit conversions are not applicable because they are ambiguous:
- both method any2stringfmt in object Predef of type (x: Any)scala.runtime.StringFormat
- and method any2stringadd in object Predef of type (x: Any)scala.runtime.StringAdd
- are possible conversion functions from a.type to AnyRef
+Note that A is bounded only by Equals, which means AnyRef is not a known parent.
+Such types can participate in value classes, but instances
+cannot appear in singleton types or in reference comparisons.
def foo[A <: Product](a: A) { type X = a.type }
^
one error found
diff --git a/test/files/neg/t3614.check b/test/files/neg/t3614.check
index 5fdb5cbf1f..0f9c83aa0d 100644
--- a/test/files/neg/t3614.check
+++ b/test/files/neg/t3614.check
@@ -1,4 +1,4 @@
-t3614.scala:2: error: class type required but AnyRef{def a: <?>} found
+t3614.scala:2: error: class type required but AnyRef{def a: Int} found
def v = new ({ def a=0 })
^
-one error found \ No newline at end of file
+one error found
diff --git a/test/files/neg/t6263.check b/test/files/neg/t6263.check
index 1c5834e1ca..9e9c7c615b 100644
--- a/test/files/neg/t6263.check
+++ b/test/files/neg/t6263.check
@@ -1,6 +1,9 @@
t6263.scala:5: error: type mismatch;
found : A.this.c.type (with underlying type C)
required: AnyRef
+Note that C extends Any, not AnyRef.
+Such types can participate in value classes, but instances
+cannot appear in singleton types or in reference comparisons.
type t = c.type
^
one error found
diff --git a/test/files/neg/t900.check b/test/files/neg/t900.check
index ff5304a135..6fe26a31ac 100644
--- a/test/files/neg/t900.check
+++ b/test/files/neg/t900.check
@@ -1,6 +1,9 @@
t900.scala:4: error: type mismatch;
found : Foo.this.x.type (with underlying type Foo.this.bar)
required: AnyRef
+Note that bar is unbounded, which means AnyRef is not a known parent.
+Such types can participate in value classes, but instances
+cannot appear in singleton types or in reference comparisons.
def break(): x.type
^
one error found
diff --git a/test/files/run/reflection-equality.check b/test/files/run/reflection-equality.check
index be531fbbd3..17c1f6dd70 100644
--- a/test/files/run/reflection-equality.check
+++ b/test/files/run/reflection-equality.check
@@ -1,53 +1,53 @@
-Type in expressions to have them evaluated.
-Type :help for more information.
-
-scala>
-
-scala> class X {
- def methodIntIntInt(x: Int, y: Int) = x+y
-}
-defined class X
-
-scala>
-
-scala> import scala.reflect.runtime.universe._
-import scala.reflect.runtime.universe._
-
-scala> import scala.reflect.runtime.{ currentMirror => cm }
-import scala.reflect.runtime.{currentMirror=>cm}
-
-scala> def im: InstanceMirror = cm.reflect(new X)
-im: reflect.runtime.universe.InstanceMirror
-
-scala> val cs: ClassSymbol = im.symbol
-cs: reflect.runtime.universe.ClassSymbol = class X
-
-scala> val ts: Type = cs.typeSignature
-ts: reflect.runtime.universe.Type =
-java.lang.Object {
- def <init>: <?>
- def methodIntIntInt: <?>
-}
-
-scala> val ms: MethodSymbol = ts.declaration(newTermName("methodIntIntInt")).asMethod
-ms: reflect.runtime.universe.MethodSymbol = method methodIntIntInt
-
-scala> val MethodType( _, t1 ) = ms.typeSignature
-t1: reflect.runtime.universe.Type = scala.Int
-
-scala> val t2 = typeOf[scala.Int]
-t2: reflect.runtime.universe.Type = Int
-
-scala> t1 == t2
-res0: Boolean = false
-
-scala> t1 =:= t2
-res1: Boolean = true
-
-scala> t1 <:< t2
-res2: Boolean = true
-
-scala> t2 <:< t1
-res3: Boolean = true
-
-scala>
+Type in expressions to have them evaluated.
+Type :help for more information.
+
+scala>
+
+scala> class X {
+ def methodIntIntInt(x: Int, y: Int) = x+y
+}
+defined class X
+
+scala>
+
+scala> import scala.reflect.runtime.universe._
+import scala.reflect.runtime.universe._
+
+scala> import scala.reflect.runtime.{ currentMirror => cm }
+import scala.reflect.runtime.{currentMirror=>cm}
+
+scala> def im: InstanceMirror = cm.reflect(new X)
+im: reflect.runtime.universe.InstanceMirror
+
+scala> val cs: ClassSymbol = im.symbol
+cs: reflect.runtime.universe.ClassSymbol = class X
+
+scala> val ts: Type = cs.typeSignature
+ts: reflect.runtime.universe.Type =
+java.lang.Object {
+ def <init>(): X
+ def methodIntIntInt(x: scala.Int,y: scala.Int): scala.Int
+}
+
+scala> val ms: MethodSymbol = ts.declaration(newTermName("methodIntIntInt")).asMethod
+ms: reflect.runtime.universe.MethodSymbol = method methodIntIntInt
+
+scala> val MethodType( _, t1 ) = ms.typeSignature
+t1: reflect.runtime.universe.Type = scala.Int
+
+scala> val t2 = typeOf[scala.Int]
+t2: reflect.runtime.universe.Type = Int
+
+scala> t1 == t2
+res0: Boolean = false
+
+scala> t1 =:= t2
+res1: Boolean = true
+
+scala> t1 <:< t2
+res2: Boolean = true
+
+scala> t2 <:< t1
+res3: Boolean = true
+
+scala>
diff --git a/test/files/run/t5256a.check b/test/files/run/t5256a.check
index 518663b3da..7e60139db3 100644
--- a/test/files/run/t5256a.check
+++ b/test/files/run/t5256a.check
@@ -1,6 +1,6 @@
-class A
-A
+class A
+A
Object {
- def <init>: <?>
- def foo: <?>
-}
+ def <init>(): A
+ def foo: Nothing
+}
diff --git a/test/files/run/t5256b.check b/test/files/run/t5256b.check
index d6015f2743..a80df6eb30 100644
--- a/test/files/run/t5256b.check
+++ b/test/files/run/t5256b.check
@@ -1,6 +1,6 @@
-class A
-Test.A
+class A
+Test.A
Object {
- def <init>: <?>
- def foo: <?>
-}
+ def <init>(): Test.A
+ def foo: Nothing
+}
diff --git a/test/files/run/t5256d.check b/test/files/run/t5256d.check
index dd32c05a93..9742ae572e 100644
--- a/test/files/run/t5256d.check
+++ b/test/files/run/t5256d.check
@@ -1,32 +1,32 @@
-Type in expressions to have them evaluated.
-Type :help for more information.
-
-scala>
-
-scala> import scala.reflect.runtime.universe._
-import scala.reflect.runtime.universe._
-
-scala> import scala.reflect.runtime.{currentMirror => cm}
-import scala.reflect.runtime.{currentMirror=>cm}
-
-scala> class A { def foo = ??? }
-defined class A
-
-scala> val c = cm.classSymbol(classOf[A])
-c: reflect.runtime.universe.ClassSymbol = class A
-
-scala> println(c)
-class A
-
-scala> println(c.fullName)
-$line8.$read.$iw.$iw.$iw.$iw.A
-
-scala> println(c.typeSignature)
-java.lang.Object {
- def <init>: <?>
- def foo: <?>
-}
-
-scala>
-
-scala>
+Type in expressions to have them evaluated.
+Type :help for more information.
+
+scala>
+
+scala> import scala.reflect.runtime.universe._
+import scala.reflect.runtime.universe._
+
+scala> import scala.reflect.runtime.{currentMirror => cm}
+import scala.reflect.runtime.{currentMirror=>cm}
+
+scala> class A { def foo = ??? }
+defined class A
+
+scala> val c = cm.classSymbol(classOf[A])
+c: reflect.runtime.universe.ClassSymbol = class A
+
+scala> println(c)
+class A
+
+scala> println(c.fullName)
+$line8.$read.$iw.$iw.$iw.$iw.A
+
+scala> println(c.typeSignature)
+java.lang.Object {
+ def <init>(): A
+ def foo: scala.Nothing
+}
+
+scala>
+
+scala>
diff --git a/test/files/run/t5256e.check b/test/files/run/t5256e.check
index 6c6de90acc..011115720c 100644
--- a/test/files/run/t5256e.check
+++ b/test/files/run/t5256e.check
@@ -1,6 +1,6 @@
class A
Test.C.A
Object {
- def <init>: <?>
- def foo: <?>
+ def <init>(): C.this.A
+ def foo: Nothing
}
diff --git a/test/files/run/t5256f.check b/test/files/run/t5256f.check
index c840793fd5..e0fec85596 100644
--- a/test/files/run/t5256f.check
+++ b/test/files/run/t5256f.check
@@ -1,12 +1,12 @@
class A1
Test.A1
Object {
- def <init>: <?>
- def foo: <?>
+ def <init>(): Test.A1
+ def foo: Nothing
}
class A2
Test.A2
Object {
- def <init>: <?>
- def foo: <?>
+ def <init>(): Test.this.A2
+ def foo: Nothing
}