diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/files/neg/accesses.check | 6 | ||||
-rw-r--r-- | test/files/neg/accesses2.check | 4 | ||||
-rw-r--r-- | test/files/neg/accesses2.scala | 11 | ||||
-rw-r--r-- | test/files/neg/t0259.check | 4 | ||||
-rw-r--r-- | test/files/neg/t3653.check | 6 | ||||
-rw-r--r-- | test/files/neg/t588.check | 10 | ||||
-rw-r--r-- | test/files/neg/t6443c.check | 4 | ||||
-rw-r--r-- | test/files/neg/t663.check | 6 | ||||
-rw-r--r-- | test/files/neg/t7899.check | 6 | ||||
-rw-r--r-- | test/files/neg/t7899.scala | 7 | ||||
-rw-r--r-- | test/files/neg/valueclasses-doubledefs.check | 4 | ||||
-rw-r--r-- | test/files/neg/valueclasses-pavlov.check | 4 | ||||
-rw-r--r-- | test/files/pos/t7584.scala | 11 | ||||
-rw-r--r-- | test/files/pos/t7902.scala | 17 | ||||
-rw-r--r-- | test/files/res/t687.check | 6 | ||||
-rw-r--r-- | test/files/run/private-override.check | 1 | ||||
-rw-r--r-- | test/files/run/private-override.scala | 17 | ||||
-rw-r--r-- | test/files/run/t7584b.scala | 14 | ||||
-rw-r--r-- | test/files/run/t7899.scala | 5 |
19 files changed, 105 insertions, 38 deletions
diff --git a/test/files/neg/accesses.check b/test/files/neg/accesses.check index db58af12ce..5a5e03233e 100644 --- a/test/files/neg/accesses.check +++ b/test/files/neg/accesses.check @@ -1,7 +1,3 @@ -accesses.scala:23: error: overriding method f2 in class A of type ()Unit; - method f2 has weaker access privileges; it should not be private - private def f2(): Unit = () - ^ accesses.scala:24: error: overriding method f3 in class A of type ()Unit; method f3 has weaker access privileges; it should be at least protected private[p2] def f3(): Unit = () @@ -14,4 +10,4 @@ accesses.scala:26: error: overriding method f5 in class A of type ()Unit; method f5 has weaker access privileges; it should be at least protected[p1] protected[p2] def f5(): Unit ^ -four errors found +three errors found diff --git a/test/files/neg/accesses2.check b/test/files/neg/accesses2.check new file mode 100644 index 0000000000..554a7b4c81 --- /dev/null +++ b/test/files/neg/accesses2.check @@ -0,0 +1,4 @@ +accesses2.scala:5: error: class B1 needs to be abstract, since method f2 in class A of type ()Int is not defined + class B1 extends A { + ^ +one error found diff --git a/test/files/neg/accesses2.scala b/test/files/neg/accesses2.scala new file mode 100644 index 0000000000..c7640f84b5 --- /dev/null +++ b/test/files/neg/accesses2.scala @@ -0,0 +1,11 @@ +package p2 { + abstract class A { + private[p2] def f2(): Int + } + class B1 extends A { + private def f2(): Int = 1 + } + abstract class B2 extends A { + private def f2(): Int = 1 + } +} diff --git a/test/files/neg/t0259.check b/test/files/neg/t0259.check index 24e35e6176..8c15d98419 100644 --- a/test/files/neg/t0259.check +++ b/test/files/neg/t0259.check @@ -1,6 +1,6 @@ t0259.scala:4: error: double definition: -constructor TestCase3:(groups: String*)test.TestCase3 and -constructor TestCase3:(groups: (String, Int)*)test.TestCase3 at line 3 +constructor TestCase3: (groups: (String, Int)*)test.TestCase3 at line 3 and +constructor TestCase3: (groups: String*)test.TestCase3 at line 4 have same type after erasure: (groups: Seq)test.TestCase3 def this( groups: String*) = this() ^ diff --git a/test/files/neg/t3653.check b/test/files/neg/t3653.check index ac6e2ca9dc..ad68e29fb4 100644 --- a/test/files/neg/t3653.check +++ b/test/files/neg/t3653.check @@ -1,7 +1,7 @@ t3653.scala:3: error: double definition: -method x:(implicit x: Int)Int and -method x:(i: Int)Int at line 2 -have same type after erasure: (x: Int)Int +def x(i: Int): Int at line 2 and +def x(implicit x: Int): Int at line 3 +have same type after erasure: (i: Int)Int def x(implicit x: Int) = 5 ^ one error found diff --git a/test/files/neg/t588.check b/test/files/neg/t588.check index f8b5516fdc..ff08f77a6f 100644 --- a/test/files/neg/t588.check +++ b/test/files/neg/t588.check @@ -1,13 +1,13 @@ t588.scala:3: error: double definition: -method visit:(f: Int => String)Boolean and -method visit:(f: Int => Unit)Boolean at line 2 +def visit(f: Int => Unit): Boolean at line 2 and +def visit(f: Int => String): Boolean at line 3 have same type after erasure: (f: Function1)Boolean def visit(f: Int => String): Boolean ^ t588.scala:10: error: double definition: -method f:(brac: Test.this.TypeB)Unit and -method f:(node: Test.this.TypeA)Unit at line 9 -have same type after erasure: (brac: Test#TraitA)Unit +def f(node: Test.this.TypeA): Unit at line 9 and +def f(brac: Test.this.TypeB): Unit at line 10 +have same type after erasure: (node: Test#TraitA)Unit def f(brac : TypeB) : Unit; ^ two errors found diff --git a/test/files/neg/t6443c.check b/test/files/neg/t6443c.check index 7cf8d23f4b..7b7f419f6c 100644 --- a/test/files/neg/t6443c.check +++ b/test/files/neg/t6443c.check @@ -1,6 +1,6 @@ t6443c.scala:16: error: double definition: -method foo:(d: B.D)(a: Any)(d2: d.type)Unit and -method foo:(d: B.D)(a: Any, d2: d.type)Unit at line 11 +def foo(d: B.D)(a: Any,d2: d.type): Unit at line 11 and +def foo(d: B.D)(a: Any)(d2: d.type): Unit at line 16 have same type after erasure: (d: B.D, a: Object, d2: B.D)Unit def foo(d: D)(a: Any)(d2: d.type): Unit = () ^ diff --git a/test/files/neg/t663.check b/test/files/neg/t663.check index 40161fb3e3..633e27ee12 100644 --- a/test/files/neg/t663.check +++ b/test/files/neg/t663.check @@ -1,7 +1,7 @@ t663.scala:11: error: name clash between defined and inherited member: -method asMatch:(m: Test.this.Node)Any and -method asMatch:(node: Test.this.Matchable)Any in trait MatchableImpl -have same type after erasure: (m: test.Test#NodeImpl)Object +def asMatch(node: Test.this.Matchable): Any in trait MatchableImpl and +def asMatch(m: Test.this.Node): Any at line 11 +have same type after erasure: (node: test.Test#NodeImpl)Object def asMatch(m : Node) : Any = { ^ one error found diff --git a/test/files/neg/t7899.check b/test/files/neg/t7899.check new file mode 100644 index 0000000000..febfe76b8a --- /dev/null +++ b/test/files/neg/t7899.check @@ -0,0 +1,6 @@ +t7899.scala:5: error: type mismatch; + found : Int => Int + required: (=> Int) => ? + foo(identity)() + ^ +one error found diff --git a/test/files/neg/t7899.scala b/test/files/neg/t7899.scala new file mode 100644 index 0000000000..f2dea3ab1f --- /dev/null +++ b/test/files/neg/t7899.scala @@ -0,0 +1,7 @@ +object Test { + def foo[B](f: (=> Int) => B): () => B = () => f(0) + + def main(args: Array[String]) { + foo(identity)() + } +} diff --git a/test/files/neg/valueclasses-doubledefs.check b/test/files/neg/valueclasses-doubledefs.check index 556d7a0900..ec513aca6b 100644 --- a/test/files/neg/valueclasses-doubledefs.check +++ b/test/files/neg/valueclasses-doubledefs.check @@ -1,6 +1,6 @@ valueclasses-doubledefs.scala:5: error: double definition: -method apply:(x: Meter)String and -method apply:(x: Double)String at line 4 +def apply(x: Double): String at line 4 and +def apply(x: Meter): String at line 5 have same type after erasure: (x: Double)String def apply(x: Meter) = x.toString ^ diff --git a/test/files/neg/valueclasses-pavlov.check b/test/files/neg/valueclasses-pavlov.check index 031589edad..17102a0c68 100644 --- a/test/files/neg/valueclasses-pavlov.check +++ b/test/files/neg/valueclasses-pavlov.check @@ -1,6 +1,6 @@ valueclasses-pavlov.scala:8: error: double definition: -method foo:(x: Box2)String and -method foo:(x: String)String at line 7 +def foo(x: String): String at line 7 and +def foo(x: Box2): String at line 8 have same type after erasure: (x: String)String def foo(x: Box2) = "foo(Box2): ok" ^ diff --git a/test/files/pos/t7584.scala b/test/files/pos/t7584.scala deleted file mode 100644 index 52d127ecb9..0000000000 --- a/test/files/pos/t7584.scala +++ /dev/null @@ -1,11 +0,0 @@ -object Test { - def fold[A, B](f: (A, => B) => B) = ??? - def f[A, B](x: A, y: B): B = ??? - def bip[A, B] = fold[A, B]((x, y) => f(x, y)) - def bop[A, B] = fold[A, B](f) - - // these work: - fold[Int, Int]((x, y) => f(x, y)) - fold[Int, Int](f) -} - diff --git a/test/files/pos/t7902.scala b/test/files/pos/t7902.scala new file mode 100644 index 0000000000..47c525c179 --- /dev/null +++ b/test/files/pos/t7902.scala @@ -0,0 +1,17 @@ +import scala.language.higherKinds + +object Bug { + class Tag[W[M1[X1]]] + + def ofType[W[M2[X2]]]: Tag[W] = ??? + type InSeq [M3[X3]] = Some[M3[Any]] + + // fail + val x = ofType[InSeq] + + // okay + val y: Any = ofType[InSeq] + object T { + val z = ofType[InSeq] + } +} diff --git a/test/files/res/t687.check b/test/files/res/t687.check index b741b262b9..5f72c98636 100644 --- a/test/files/res/t687.check +++ b/test/files/res/t687.check @@ -1,8 +1,8 @@ nsc> nsc> t687/QueryB.scala:3: error: name clash between defined and inherited member: -method equals:(o: Object)Boolean and -method equals:(x$1: Any)Boolean in class Any -have same type after erasure: (o: Object)Boolean +def equals(x$1: Any): Boolean in class Any and +override def equals(o: Object): Boolean at line 3 +have same type after erasure: (x$1: Object)Boolean override def equals(o : Object) = false; ^ diff --git a/test/files/run/private-override.check b/test/files/run/private-override.check new file mode 100644 index 0000000000..00750edc07 --- /dev/null +++ b/test/files/run/private-override.check @@ -0,0 +1 @@ +3 diff --git a/test/files/run/private-override.scala b/test/files/run/private-override.scala new file mode 100644 index 0000000000..0a3f57f97c --- /dev/null +++ b/test/files/run/private-override.scala @@ -0,0 +1,17 @@ +package test.p1.p2 { + abstract class A { + private[p2] def f2(): Int = 1 + } + abstract class Other extends A { + // It's a private method - not a private[p2] method. Not a failed + // "weaker access privileges" override, a different namespace. + private def f2(): Int = super.f2() + 2 + def go() = f2() + } +} + +object Test extends test.p1.p2.Other { + def main(args: Array[String]): Unit = { + println(go()) + } +} diff --git a/test/files/run/t7584b.scala b/test/files/run/t7584b.scala new file mode 100644 index 0000000000..fd560f0418 --- /dev/null +++ b/test/files/run/t7584b.scala @@ -0,0 +1,14 @@ +object Test extends App { + def fold[A, B](f: (A, => B) => B) = (b: B) => f(null.asInstanceOf[A], b) + def f[A, B](x: A, y: B): B = y + def bip[A, B] = fold[A, B]((x, y) => f(x, y)) + def bop[A, B] = fold[A, B](f(_, _)) + + // these work: + fold[Int, Int]((x, y) => f(x, y))(0) + fold[Int, Int](f(_, _))(0) + + // Used to throw a ClassCastException. Since the fix for SI-7899, these issue type errors. + // fold[Int, Int](f _)(0) + // fold[Int, Int](f)(0) +} diff --git a/test/files/run/t7899.scala b/test/files/run/t7899.scala new file mode 100644 index 0000000000..5879d4b9fe --- /dev/null +++ b/test/files/run/t7899.scala @@ -0,0 +1,5 @@ +object Test extends App { + def id[A](a: => A): A = null.asInstanceOf[A] + def foo(f: (=> Int) => Int) = () => f(???) + foo(id)() // should be allowed and not throw ??? +} |