diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/files/neg/bug1279a.check | 6 | ||||
-rw-r--r-- | test/files/neg/lazy-override.check | 9 | ||||
-rw-r--r-- | test/files/neg/lazy-override.scala | 19 | ||||
-rwxr-xr-x | test/files/pos/t0851.scala | 14 |
4 files changed, 44 insertions, 4 deletions
diff --git a/test/files/neg/bug1279a.check b/test/files/neg/bug1279a.check index a2259f6cda..edfd1fe871 100644 --- a/test/files/neg/bug1279a.check +++ b/test/files/neg/bug1279a.check @@ -1,8 +1,6 @@ -bug1279a.scala:34: error: no type parameters for method all4Impl: (M{type T <: U})Stream[M{type T <: U}] exist so that it can be applied to arguments (first.selfType) - --- because --- -argument expression's type is not compatible with formal parameter type; +bug1279a.scala:34: error: type mismatch; found : first.selfType required: M{type T <: this.T} def all4Impl[U](first: M {type T <: U}): Stream[M {type T <: U}] = Stream.cons(first, all4Impl(first.next)) - ^ + ^ one error found diff --git a/test/files/neg/lazy-override.check b/test/files/neg/lazy-override.check new file mode 100644 index 0000000000..d1c9d305f0 --- /dev/null +++ b/test/files/neg/lazy-override.check @@ -0,0 +1,9 @@ +lazy-override.scala:11: error: error overriding value x in class A of type Int; + lazy value x cannot override a concrete non-lazy value + override lazy val x: Int = { print("/*B.x*/"); 3 } + ^ +lazy-override.scala:13: error: error overriding lazy value y in class A of type Int; + value y must be declared lazy to override a concrete lazy value + override val y: Int = { print("/*B.y*/"); 3 } + ^ +two errors found diff --git a/test/files/neg/lazy-override.scala b/test/files/neg/lazy-override.scala new file mode 100644 index 0000000000..f41d7f038b --- /dev/null +++ b/test/files/neg/lazy-override.scala @@ -0,0 +1,19 @@ + +/** Test which should fail compilation */ + class A { + val x: Int = { print("/*A.x*/"); 2 } + lazy val y: Int = { print("/*A.y*/"); 2 } + } + + + class B extends A { + // lazy overrides strict val + override lazy val x: Int = { print("/*B.x*/"); 3 } + // strict val overrides lazy + override val y: Int = { print("/*B.y*/"); 3 } + } + + + + + diff --git a/test/files/pos/t0851.scala b/test/files/pos/t0851.scala new file mode 100755 index 0000000000..fc7109dcd4 --- /dev/null +++ b/test/files/pos/t0851.scala @@ -0,0 +1,14 @@ +package test + +object test1 { + case class Foo[T,T2](f : (T,T2) => String) extends (((T,T2)) => String){ + def apply(t : T) = (s:T2) => f(t,s) + def apply(p : (T,T2)) = f(p._1,p._2) + } + implicit def g[T](f : (T,String) => String) = Foo(f) + def main(args : Array[String]) : Unit = { + val f = (x:Int,s:String) => s + x + println(f(1)) + () + } +} |