diff options
author | Josh Suereth <Joshua.Suereth@gmail.com> | 2012-09-02 04:19:47 -0700 |
---|---|---|
committer | Josh Suereth <Joshua.Suereth@gmail.com> | 2012-09-02 04:19:47 -0700 |
commit | 6e1ff1c92d32b567a41b10c0e4321adf01d3e616 (patch) | |
tree | c23ef6bdf01f643ce98204c0e3d10420d1a86058 /test/files/neg | |
parent | 6b87cdcd7bd6d1932e87e6bf8dc6029d6461a488 (diff) | |
parent | 35316be5a89b2c9622e92594245aaf72a3820c88 (diff) | |
download | scala-6e1ff1c92d32b567a41b10c0e4321adf01d3e616.tar.gz scala-6e1ff1c92d32b567a41b10c0e4321adf01d3e616.tar.bz2 scala-6e1ff1c92d32b567a41b10c0e4321adf01d3e616.zip |
Merge pull request #1232 from paulp/topic/210-errors-and-warnings
Topic/210 errors and warnings
Diffstat (limited to 'test/files/neg')
-rw-r--r-- | test/files/neg/any-vs-anyref.check | 64 | ||||
-rw-r--r-- | test/files/neg/any-vs-anyref.scala | 29 | ||||
-rw-r--r-- | test/files/neg/not-possible-cause.check | 9 | ||||
-rw-r--r-- | test/files/neg/not-possible-cause.scala | 3 | ||||
-rw-r--r-- | test/files/neg/t3614.check | 4 | ||||
-rw-r--r-- | test/files/neg/t6263.check | 9 | ||||
-rw-r--r-- | test/files/neg/t6263.scala | 6 | ||||
-rw-r--r-- | test/files/neg/t900.check | 3 |
8 files changed, 125 insertions, 2 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 new file mode 100644 index 0000000000..5c09fa1545 --- /dev/null +++ b/test/files/neg/not-possible-cause.check @@ -0,0 +1,9 @@ +not-possible-cause.scala:2: 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 foo[A <: Product](a: A) { type X = a.type } + ^ +one error found diff --git a/test/files/neg/not-possible-cause.scala b/test/files/neg/not-possible-cause.scala new file mode 100644 index 0000000000..83ec24dec8 --- /dev/null +++ b/test/files/neg/not-possible-cause.scala @@ -0,0 +1,3 @@ +object Foo { + def foo[A <: Product](a: A) { type X = a.type } +} 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 new file mode 100644 index 0000000000..9e9c7c615b --- /dev/null +++ b/test/files/neg/t6263.check @@ -0,0 +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/t6263.scala b/test/files/neg/t6263.scala new file mode 100644 index 0000000000..6575185b5c --- /dev/null +++ b/test/files/neg/t6263.scala @@ -0,0 +1,6 @@ +class C(val a: Any) extends AnyVal +class A { + implicit def c2AnyRef(c: C): AnyRef = new {} + val c = new C(0) + type t = c.type +} 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 |