diff options
Diffstat (limited to 'test')
71 files changed, 774 insertions, 54 deletions
diff --git a/test/files/jvm/throws-annot-from-java.check b/test/files/jvm/throws-annot-from-java.check new file mode 100644 index 0000000000..be3ba412f8 --- /dev/null +++ b/test/files/jvm/throws-annot-from-java.check @@ -0,0 +1,47 @@ +Type in expressions to have them evaluated. +Type :help for more information. + +scala> :power +** Power User mode enabled - BEEP WHIR GYVE ** +** :phase has been set to 'typer'. ** +** scala.tools.nsc._ has been imported ** +** global._, definitions._ also imported ** +** Try :help, :vals, power.<tab> ** + +scala> :paste +// Entering paste mode (ctrl-D to finish) + +{ + val clazz = rootMirror.getClassByName(newTermName("test.ThrowsDeclaration_2")); + { + val method = clazz.info.member(newTermName("foo")) + val throwsAnn = method.annotations.head + val atp = throwsAnn.atp + println("foo") + println("atp.typeParams.isEmpty: " + atp.typeParams.isEmpty) + println(throwsAnn) + } + println + + { + val method = clazz.info.member(newTermName("bar")) + val throwsAnn = method.annotations.head + val Literal(const) = throwsAnn.args.head + val tp = const.typeValue + println("bar") + println("tp.typeParams.isEmpty: " + tp.typeParams.isEmpty) + println(throwsAnn) + } +} + +// Exiting paste mode, now interpreting. + +foo +atp.typeParams.isEmpty: true +throws[IllegalStateException](classOf[java.lang.IllegalStateException]) + +bar +tp.typeParams.isEmpty: true +throws[test.PolymorphicException[_]](classOf[test.PolymorphicException]) + +scala> diff --git a/test/files/jvm/throws-annot-from-java/PolymorphicException_1.scala b/test/files/jvm/throws-annot-from-java/PolymorphicException_1.scala new file mode 100644 index 0000000000..58fa536f0b --- /dev/null +++ b/test/files/jvm/throws-annot-from-java/PolymorphicException_1.scala @@ -0,0 +1,3 @@ +package test + +class PolymorphicException[T] extends Exception diff --git a/test/files/jvm/throws-annot-from-java/Test_3.scala b/test/files/jvm/throws-annot-from-java/Test_3.scala new file mode 100644 index 0000000000..de1d984573 --- /dev/null +++ b/test/files/jvm/throws-annot-from-java/Test_3.scala @@ -0,0 +1,29 @@ +import scala.tools.partest.ReplTest + +object Test extends ReplTest { + def code = """:power +:paste +{ + val clazz = rootMirror.getClassByName(newTermName("test.ThrowsDeclaration_2")); + { + val method = clazz.info.member(newTermName("foo")) + val throwsAnn = method.annotations.head + val atp = throwsAnn.atp + println("foo") + println("atp.typeParams.isEmpty: " + atp.typeParams.isEmpty) + println(throwsAnn) + } + println + + { + val method = clazz.info.member(newTermName("bar")) + val throwsAnn = method.annotations.head + val Literal(const) = throwsAnn.args.head + val tp = const.typeValue + println("bar") + println("tp.typeParams.isEmpty: " + tp.typeParams.isEmpty) + println(throwsAnn) + } +} +""" +} diff --git a/test/files/jvm/throws-annot-from-java/ThrowsDeclaration_2.java b/test/files/jvm/throws-annot-from-java/ThrowsDeclaration_2.java new file mode 100644 index 0000000000..3708fe626b --- /dev/null +++ b/test/files/jvm/throws-annot-from-java/ThrowsDeclaration_2.java @@ -0,0 +1,6 @@ +package test; + +public class ThrowsDeclaration_2 { + public void foo() throws IllegalStateException {}; + public void bar() throws PolymorphicException {}; +} diff --git a/test/files/neg/macro-false-deprecation-warning.check b/test/files/neg/macro-false-deprecation-warning.check new file mode 100644 index 0000000000..7d56505ec4 --- /dev/null +++ b/test/files/neg/macro-false-deprecation-warning.check @@ -0,0 +1,4 @@ +Impls_Macros_1.scala:5: error: illegal start of simple expression +} +^ +one error found diff --git a/test/files/neg/macro-false-deprecation-warning.flags b/test/files/neg/macro-false-deprecation-warning.flags new file mode 100644 index 0000000000..59af162db6 --- /dev/null +++ b/test/files/neg/macro-false-deprecation-warning.flags @@ -0,0 +1 @@ +-language:experimental.macros -deprecation
\ No newline at end of file diff --git a/test/files/neg/macro-false-deprecation-warning/Impls_Macros_1.scala b/test/files/neg/macro-false-deprecation-warning/Impls_Macros_1.scala new file mode 100644 index 0000000000..6dc2ea114b --- /dev/null +++ b/test/files/neg/macro-false-deprecation-warning/Impls_Macros_1.scala @@ -0,0 +1,15 @@ +import scala.reflect.macros.Context + +object Helper { + def unapplySeq[T](x: List[T]): Option[Seq[T]] = +} + +object Macros { + def impl[T: c.WeakTypeTag](c: Context)(x: c.Expr[List[T]]) = { + c.universe.reify(Helper.unapplySeq(x.splice)) + } + + object UnapplyMacro { + def unapplySeq[T](x: List[T]): Option[Seq[T]] = macro impl[T] + } +} diff --git a/test/files/neg/t2968.check b/test/files/neg/t2968.check new file mode 100644 index 0000000000..5d2387f98c --- /dev/null +++ b/test/files/neg/t2968.check @@ -0,0 +1,10 @@ +t2968.scala:8: error: Missing closing brace `}' assumed here +} // missing brace +^ +t2968.scala:17: error: Missing closing brace `}' assumed here +} // missing brace +^ +t2968.scala:26: error: Missing closing brace `}' assumed here +} // missing brace +^ +three errors found diff --git a/test/files/neg/t2968.scala b/test/files/neg/t2968.scala new file mode 100644 index 0000000000..41c3a798a5 --- /dev/null +++ b/test/files/neg/t2968.scala @@ -0,0 +1,26 @@ +object t1 { + case object Const { + } + + class Var + { + +} // missing brace + +object t2 { + case class Const() { + } + + class Var + { + +} // missing brace + +object t3 { + final case class Const() { + } + + class Var + { + +} // missing brace diff --git a/test/files/neg/t2968b.check b/test/files/neg/t2968b.check new file mode 100644 index 0000000000..36d25a2d12 --- /dev/null +++ b/test/files/neg/t2968b.check @@ -0,0 +1,4 @@ +t2968b.scala:7: error: '}' expected but eof found. +// missing brace + ^ +one error found diff --git a/test/files/neg/t2968b.scala b/test/files/neg/t2968b.scala new file mode 100644 index 0000000000..422b618aba --- /dev/null +++ b/test/files/neg/t2968b.scala @@ -0,0 +1,7 @@ +case class Const() +{ +} + +class Var +{ +// missing brace diff --git a/test/files/neg/t5353.check b/test/files/neg/t5353.check new file mode 100644 index 0000000000..75e2435600 --- /dev/null +++ b/test/files/neg/t5353.check @@ -0,0 +1,4 @@ +t5353.scala:2: error: this type parameter must be specified + def f(x: Boolean) = if (x) Array("abc") else Array() + ^ +one error found diff --git a/test/files/neg/t5353.scala b/test/files/neg/t5353.scala new file mode 100644 index 0000000000..1ee869aac1 --- /dev/null +++ b/test/files/neg/t5353.scala @@ -0,0 +1,3 @@ +class A { + def f(x: Boolean) = if (x) Array("abc") else Array() +} diff --git a/test/files/neg/t5378.check b/test/files/neg/t5378.check new file mode 100644 index 0000000000..c1460083f6 --- /dev/null +++ b/test/files/neg/t5378.check @@ -0,0 +1,31 @@ +t5378.scala:7: error: Type bound in structural refinement may not refer to an abstract type defined outside that refinement + def contains = new { def apply[T1 <: T](value: T1) = ??? } + ^ +t5378.scala:8: error: Type bound in structural refinement may not refer to an abstract type defined outside that refinement + def contains1 = new { def apply[T1 <: A1](value: T1) = ??? } + ^ +t5378.scala:9: error: Type bound in structural refinement may not refer to an abstract type defined outside that refinement + def contains2 = new { def apply[T1 <: A2](value: T1) = ??? } + ^ +t5378.scala:15: error: Type bound in structural refinement may not refer to an abstract type defined outside that refinement + new Bippy { def apply[T1 <: T](value: T1) = ??? } + ^ +t5378.scala:16: error: Type bound in structural refinement may not refer to an abstract type defined outside that refinement + new Bippy { def apply[T1 <: B1](value: T1) = ??? } + ^ +t5378.scala:17: error: Type bound in structural refinement may not refer to an abstract type defined outside that refinement + new Bippy { def apply[T1 <: B2](value: T1) = ??? } + ^ +t5378.scala:21: error: Type bound in structural refinement may not refer to an abstract type defined outside that refinement + def apply1[T1 <: B3](value: T1) = ??? + ^ +t5378.scala:23: error: Parameter type in structural refinement may not refer to an abstract type defined outside that refinement + def apply3(value: B3) = ??? + ^ +t5378.scala:28: error: Parameter type in structural refinement may not refer to an abstract type defined outside that refinement + def apply1(s: String)(x: Int)(value: T) = ??? + ^ +t5378.scala:29: error: Type bound in structural refinement may not refer to an abstract type defined outside that refinement + def apply2[T1 <: T](s: String)(x: Int)(value: T1) = ??? + ^ +10 errors found diff --git a/test/files/neg/t5378.scala b/test/files/neg/t5378.scala new file mode 100644 index 0000000000..fa6afa02be --- /dev/null +++ b/test/files/neg/t5378.scala @@ -0,0 +1,54 @@ +import scala.language.reflectiveCalls + +class Coll[+T] { + type A1 <: T + type A2 <: A1 + + def contains = new { def apply[T1 <: T](value: T1) = ??? } + def contains1 = new { def apply[T1 <: A1](value: T1) = ??? } + def contains2 = new { def apply[T1 <: A2](value: T1) = ??? } + def contains3 = { + trait Bippy { + type B1 <: T + type B2 <: B1 + } + new Bippy { def apply[T1 <: T](value: T1) = ??? } + new Bippy { def apply[T1 <: B1](value: T1) = ??? } + new Bippy { def apply[T1 <: B2](value: T1) = ??? } + new Bippy { + type B3 = B2 + type B4 = List[B2] + def apply1[T1 <: B3](value: T1) = ??? + def apply2[T1 <: B4](value: T1) = ??? + def apply3(value: B3) = ??? + def apply4(value: B4) = value.head + } + } + def contains4 = new { + def apply1(s: String)(x: Int)(value: T) = ??? + def apply2[T1 <: T](s: String)(x: Int)(value: T1) = ??? + } + def containsOk = { + trait Bippy { + type B1 <: AnyRef + type B2 <: B1 + } + new Bippy { def apply[T1 <: AnyRef](value: T1) = ??? } + new Bippy { type B1 = String ; def apply[T1 <: B1](value: T1) = ??? } + new Bippy { type B2 = String ; def apply[T1 <: B2](value: T1) = ??? } + } +} + +object Test { + def main(args: Array[String]): Unit = { + val xs = new Coll[List[String]] + val ys: Coll[Traversable[String]] = xs + + println(ys contains Nil) + // java.lang.NoSuchMethodException: Coll$$anon$1.apply(scala.collection.Traversable) + // at java.lang.Class.getMethod(Class.java:1605) + // at Test$.reflMethod$Method1(a.scala:14) + // at Test$.main(a.scala:14) + // at Test.main(a.scala) + } +} diff --git a/test/files/neg/t5692a.check b/test/files/neg/t5692a.check index ded95a8820..7fbfb5dba7 100644 --- a/test/files/neg/t5692a.check +++ b/test/files/neg/t5692a.check @@ -1,4 +1,4 @@ -Test_2.scala:2: error: type parameter not specified +Test_2.scala:2: error: this type parameter must be specified def x = Macros.foo ^ one error found diff --git a/test/files/neg/t5692b.check b/test/files/neg/t5692b.check index e453870ec8..16796826b4 100644 --- a/test/files/neg/t5692b.check +++ b/test/files/neg/t5692b.check @@ -1,4 +1,4 @@ -Test_2.scala:2: error: type parameters not specified +Test_2.scala:2: error: these type parameters must be specified def x = Macros.foo ^ one error found diff --git a/test/files/neg/t6426.check b/test/files/neg/t6426.check new file mode 100644 index 0000000000..149f74c4de --- /dev/null +++ b/test/files/neg/t6426.check @@ -0,0 +1,7 @@ +t6426.scala:4: error: wildcard invalid as backquoted identifier + println(`_`.Buffer(0)) + ^ +t6426.scala:5: error: ')' expected but '}' found. +} +^ +two errors found diff --git a/test/files/neg/t6426.scala b/test/files/neg/t6426.scala new file mode 100644 index 0000000000..a27d18eb58 --- /dev/null +++ b/test/files/neg/t6426.scala @@ -0,0 +1,5 @@ +class A { + import collection.{mutable => _, _} + + println(`_`.Buffer(0)) +} diff --git a/test/files/neg/t6539/Macro_1.scala b/test/files/neg/t6539/Macro_1.scala index ed52776d95..4f7d289e2e 100644 --- a/test/files/neg/t6539/Macro_1.scala +++ b/test/files/neg/t6539/Macro_1.scala @@ -5,6 +5,6 @@ object M { def m(a: Any, b: Any): Any = macro mImpl def mImpl(c: Context)(a: c.Expr[Any], b: c.Expr[Any]) = a - @reflect.macros.compileTimeOnly("cto may only be used as an argument to " + "m") + @reflect.internal.annotations.compileTimeOnly("cto may only be used as an argument to " + "m") def cto = 0 } diff --git a/test/files/neg/t6539/Test_2.scala b/test/files/neg/t6539/Test_2.scala index 5a602879ec..26f4504222 100644 --- a/test/files/neg/t6539/Test_2.scala +++ b/test/files/neg/t6539/Test_2.scala @@ -3,4 +3,10 @@ object Test { M.m(M.cto, ()) // error M.m((), M.cto) // okay M.cto // error + + locally { + val expr = scala.reflect.runtime.universe.reify(2) + val splice = expr.splice + val value = expr.value + } } diff --git a/test/files/neg/t6601.check b/test/files/neg/t6601.check deleted file mode 100644 index 1410e1b11a..0000000000 --- a/test/files/neg/t6601.check +++ /dev/null @@ -1,4 +0,0 @@ -AccessPrivateConstructor_2.scala:2: error: constructor PrivateConstructor in class PrivateConstructor cannot be accessed in class AccessPrivateConstructor - new PrivateConstructor("") // Scalac should forbid accessing to the private constructor! - ^ -one error found diff --git a/test/files/neg/t6601/AccessPrivateConstructor_2.scala b/test/files/neg/t6601/AccessPrivateConstructor_2.scala deleted file mode 100644 index 816bc10d79..0000000000 --- a/test/files/neg/t6601/AccessPrivateConstructor_2.scala +++ /dev/null @@ -1,3 +0,0 @@ -class AccessPrivateConstructor { - new PrivateConstructor("") // Scalac should forbid accessing to the private constructor! -} diff --git a/test/files/neg/t6601/PrivateConstructor_1.scala b/test/files/neg/t6601/PrivateConstructor_1.scala deleted file mode 100644 index f09d7ad068..0000000000 --- a/test/files/neg/t6601/PrivateConstructor_1.scala +++ /dev/null @@ -1 +0,0 @@ -class PrivateConstructor private(val s: String) extends AnyVal diff --git a/test/files/neg/t6963.check b/test/files/neg/t6963.check deleted file mode 100644 index 41cb796b0b..0000000000 --- a/test/files/neg/t6963.check +++ /dev/null @@ -1,2 +0,0 @@ -error: -Xmigration is deprecated: This setting is no longer useful and will be removed. Please remove it from your build. -one error found diff --git a/test/files/neg/t6963.flags b/test/files/neg/t6963.flags deleted file mode 100644 index 0b6d71496a..0000000000 --- a/test/files/neg/t6963.flags +++ /dev/null @@ -1 +0,0 @@ --Xmigration -deprecation -Xfatal-warnings
\ No newline at end of file diff --git a/test/files/neg/t6963.scala b/test/files/neg/t6963.scala deleted file mode 100644 index 4da52764f5..0000000000 --- a/test/files/neg/t6963.scala +++ /dev/null @@ -1,3 +0,0 @@ - -object test { -} diff --git a/test/files/neg/t6963a.check b/test/files/neg/t6963a.check new file mode 100644 index 0000000000..159896fd10 --- /dev/null +++ b/test/files/neg/t6963a.check @@ -0,0 +1,5 @@ +t6963a.scala:4: error: method scanRight in trait TraversableLike has changed semantics in version 2.9.0: +The behavior of `scanRight` has changed. The previous behavior can be reproduced with scanRight.reverse. + List(1,2,3,4,5).scanRight(0)(_+_) + ^ +one error found diff --git a/test/files/neg/t6963a.flags b/test/files/neg/t6963a.flags new file mode 100644 index 0000000000..4c61ed9430 --- /dev/null +++ b/test/files/neg/t6963a.flags @@ -0,0 +1 @@ +-Xfatal-warnings -Xmigration:2.7 diff --git a/test/files/neg/t6963a.scala b/test/files/neg/t6963a.scala new file mode 100644 index 0000000000..b3366b2557 --- /dev/null +++ b/test/files/neg/t6963a.scala @@ -0,0 +1,5 @@ +object Test { + import scala.collection.mutable._ + + List(1,2,3,4,5).scanRight(0)(_+_) +} diff --git a/test/files/neg/t6963b.check b/test/files/neg/t6963b.check new file mode 100644 index 0000000000..7e205a41d0 --- /dev/null +++ b/test/files/neg/t6963b.check @@ -0,0 +1,13 @@ +t6963b.scala:2: error: An Array will no longer match as Seq[_]. + def f1(x: Any) = x.isInstanceOf[Seq[_]] + ^ +t6963b.scala:4: error: An Array will no longer match as Seq[_]. + case _: Seq[_] => true + ^ +t6963b.scala:16: error: An Array will no longer match as Seq[_]. + case (Some(_: Seq[_]), Nil, _) => 1 + ^ +t6963b.scala:17: error: An Array will no longer match as Seq[_]. + case (None, List(_: List[_], _), _) => 2 + ^ +four errors found diff --git a/test/files/neg/t6963b.flags b/test/files/neg/t6963b.flags new file mode 100644 index 0000000000..83caa2b147 --- /dev/null +++ b/test/files/neg/t6963b.flags @@ -0,0 +1 @@ +-Xmigration:2.7 -Xfatal-warnings
\ No newline at end of file diff --git a/test/files/neg/t6963b.scala b/test/files/neg/t6963b.scala new file mode 100644 index 0000000000..3cfa8f0dca --- /dev/null +++ b/test/files/neg/t6963b.scala @@ -0,0 +1,20 @@ +object Test { + def f1(x: Any) = x.isInstanceOf[Seq[_]] + def f2(x: Any) = x match { + case _: Seq[_] => true + case _ => false + } + + def f3(x: Any) = x match { + case _: Array[_] => true + case _ => false + } + + def f4(x: Any) = x.isInstanceOf[Traversable[_]] + + def f5(x1: Any, x2: Any, x3: AnyRef) = (x1, x2, x3) match { + case (Some(_: Seq[_]), Nil, _) => 1 + case (None, List(_: List[_], _), _) => 2 + case _ => 3 + } +} diff --git a/test/files/pos/t5130.scala b/test/files/pos/t5130.scala new file mode 100644 index 0000000000..676d3c7050 --- /dev/null +++ b/test/files/pos/t5130.scala @@ -0,0 +1,46 @@ +import scala.language.reflectiveCalls + +class A { + this_a => + + def b = new B + class B { def a: this_a.type = this_a } +} +trait A2 { def c = () } + +object Test { + val v1 = new A { def c = () } + val v2 = new A with A2 { } + val v3: A { def c: Unit } = null + def d1 = new A { def c = () } + def d2 = new A with A2 { } + def d3: A { def c: Unit } = null + var x1 = new A { def c = () } + var x2 = new A with A2 { } + var x3: A { def c: Unit } = null + + def main(args: Array[String]): Unit = { + val mv1 = new A { def c = () } + val mv2 = new A with A2 { } + val mv3: A { def c: Unit } = null + def md1 = new A { def c = () } + def md2 = new A with A2 { } + def md3: A { def c: Unit } = null + + v1.b.a.c + v2.b.a.c + v3.b.a.c + d1.b.a.c + d2.b.a.c + d3.b.a.c + x1.b.a.c + x2.b.a.c + x3.b.a.c + mv1.b.a.c + mv2.b.a.c + mv3.b.a.c + md1.b.a.c + md2.b.a.c + md3.b.a.c + } +} diff --git a/test/files/pos/t5604b/T_1.scala b/test/files/pos/t5604b/T_1.scala new file mode 100644 index 0000000000..179dcb10c6 --- /dev/null +++ b/test/files/pos/t5604b/T_1.scala @@ -0,0 +1,6 @@ +// sandbox/t5604/T.scala +package t6504 + +trait T { + def foo: Boolean = false +} diff --git a/test/files/pos/t5604b/T_2.scala b/test/files/pos/t5604b/T_2.scala new file mode 100644 index 0000000000..179dcb10c6 --- /dev/null +++ b/test/files/pos/t5604b/T_2.scala @@ -0,0 +1,6 @@ +// sandbox/t5604/T.scala +package t6504 + +trait T { + def foo: Boolean = false +} diff --git a/test/files/pos/t5604b/Test_1.scala b/test/files/pos/t5604b/Test_1.scala new file mode 100644 index 0000000000..f7c58ebe83 --- /dev/null +++ b/test/files/pos/t5604b/Test_1.scala @@ -0,0 +1,7 @@ +// sandbox/t5604/Test.scala +package t6504 + +object Test { + def blerg1(a: Any): Any = if (foo) blerg1(0) + def blerg2(a: Any): Any = if (t6504.foo) blerg2(0) +} diff --git a/test/files/pos/t5604b/Test_2.scala b/test/files/pos/t5604b/Test_2.scala new file mode 100644 index 0000000000..f7c58ebe83 --- /dev/null +++ b/test/files/pos/t5604b/Test_2.scala @@ -0,0 +1,7 @@ +// sandbox/t5604/Test.scala +package t6504 + +object Test { + def blerg1(a: Any): Any = if (foo) blerg1(0) + def blerg2(a: Any): Any = if (t6504.foo) blerg2(0) +} diff --git a/test/files/pos/t5604b/pack_1.scala b/test/files/pos/t5604b/pack_1.scala new file mode 100644 index 0000000000..f50d568bfa --- /dev/null +++ b/test/files/pos/t5604b/pack_1.scala @@ -0,0 +1,5 @@ +// sandbox/t5604/pack.scala +package t6504 + +object `package` extends T { +} diff --git a/test/files/pos/t5859.scala b/test/files/pos/t5859.scala new file mode 100644 index 0000000000..2a31e68ee5 --- /dev/null +++ b/test/files/pos/t5859.scala @@ -0,0 +1,15 @@ + +class A { + def f(xs: List[Int], ys: AnyRef*) = () + def f(xs: AnyRef*) = () + + f() + f(List[AnyRef](): _*) + f(List(): _*) + f(Nil: _*) + f(Array(): _*) + f(Array[AnyRef](): _*) + f(List(1)) + f(List(1), Nil: _*) + f(List(1), Array(): _*) +} diff --git a/test/files/pos/t6072.scala b/test/files/pos/t6072.scala new file mode 100644 index 0000000000..e25ebbffc5 --- /dev/null +++ b/test/files/pos/t6072.scala @@ -0,0 +1,3 @@ +class A { + object B { def eq(lvl: Int) = ??? } +} diff --git a/test/files/pos/t6595.flags b/test/files/pos/t6595.flags new file mode 100644 index 0000000000..85d8eb2ba2 --- /dev/null +++ b/test/files/pos/t6595.flags @@ -0,0 +1 @@ +-Xfatal-warnings diff --git a/test/files/pos/t6595.scala b/test/files/pos/t6595.scala new file mode 100644 index 0000000000..437c0bcf05 --- /dev/null +++ b/test/files/pos/t6595.scala @@ -0,0 +1,18 @@ +import scala.annotation.switch + +class Foo extends { + final val b0 = 5 +} with AnyRef { + final val b1 = 10 + + // Using the @switch annotation as a means of testing that the + // type inferred for b0 is Int(5) and not Int. Only in the former + // case can a switch be generated. + def f(p: Int) = (p: @switch) match { + case `b0` => 1 + case `b1` => 2 + case 15 => 3 + case 20 => 4 + case _ => 5 + } +} diff --git a/test/files/pos/t6601/PrivateValueClass_1.scala b/test/files/pos/t6601/PrivateValueClass_1.scala new file mode 100644 index 0000000000..85c3687137 --- /dev/null +++ b/test/files/pos/t6601/PrivateValueClass_1.scala @@ -0,0 +1 @@ +class V private (val a: Any) extends AnyVal
\ No newline at end of file diff --git a/test/files/pos/t6601/UsePrivateValueClass_2.scala b/test/files/pos/t6601/UsePrivateValueClass_2.scala new file mode 100644 index 0000000000..461b8397b2 --- /dev/null +++ b/test/files/pos/t6601/UsePrivateValueClass_2.scala @@ -0,0 +1,10 @@ +object Test { + // After the first attempt to make seprately compiled value + // classes respect the privacy of constructors, we got: + // + // exception when typing v.a().==(v.a())/class scala.reflect.internal.Trees$Apply + // constructor V in class V cannot be accessed in object Test in file test/files/pos/t6601/UsePrivateValueClass_2.scala + // scala.reflect.internal.Types$TypeError: constructor V in class V cannot be accessed in object Test + def foo(v: V) = v.a == v.a + def bar(v: V) = v == v +} diff --git a/test/files/pos/t6963c.flags b/test/files/pos/t6963c.flags new file mode 100644 index 0000000000..4d6e04914f --- /dev/null +++ b/test/files/pos/t6963c.flags @@ -0,0 +1 @@ +-Xmigration:2.9 -Xfatal-warnings
\ No newline at end of file diff --git a/test/files/pos/t6963c.scala b/test/files/pos/t6963c.scala new file mode 100644 index 0000000000..0b6b5c757f --- /dev/null +++ b/test/files/pos/t6963c.scala @@ -0,0 +1,25 @@ +object Test { + def f1(x: Any) = x.isInstanceOf[Seq[_]] + def f2(x: Any) = x match { + case _: Seq[_] => true + case _ => false + } + + def f3(x: Any) = x match { + case _: Array[_] => true + case _ => false + } + + def f4(x: Any) = x.isInstanceOf[Traversable[_]] + + def f5(x1: Any, x2: Any, x3: AnyRef) = (x1, x2, x3) match { + case (Some(_: Seq[_]), Nil, _) => 1 + case (None, List(_: List[_], _), _) => 2 + case _ => 3 + } + + def f5: Unit = { + import scala.collection.mutable._ + List(1,2,3,4,5).scanRight(0)(_+_) + } +} diff --git a/test/files/run/reify-staticXXX.scala b/test/files/run/reify-staticXXX.scala index dc861f843e..e80157dd8f 100644 --- a/test/files/run/reify-staticXXX.scala +++ b/test/files/run/reify-staticXXX.scala @@ -4,12 +4,12 @@ import scala.tools.reflect.Eval object B { override def toString = "object" } class C { override def toString = "class" } -package foo { +package foo1 { object B { override def toString = "package > object" } class C { override def toString = "package > class" } } -object foo { +object Foo2 { object B { override def toString = "object > object" } class C { override def toString = "object > class" } } @@ -20,14 +20,14 @@ object packageless { println(reify(B).eval) println(new C) println(reify(new C).eval) - println(foo.B) - println(reify(foo.B).eval) - println(new foo.C) - println(reify(new foo.C).eval) - println(_root_.foo.B) - println(reify(_root_.foo.B).eval) - println(new _root_.foo.C) - println(reify(new _root_.foo.C).eval) + println(Foo2.B) + println(reify(Foo2.B).eval) + println(new Foo2.C) + println(reify(new Foo2.C).eval) + println(_root_.foo1.B) + println(reify(_root_.foo1.B).eval) + println(new _root_.foo1.C) + println(reify(new _root_.foo1.C).eval) } } @@ -38,14 +38,14 @@ package packageful { println(reify(B).eval) println(new C) println(reify(new C).eval) - println(foo.B) - println(reify(foo.B).eval) - println(new foo.C) - println(reify(new foo.C).eval) - println(_root_.foo.B) - println(reify(_root_.foo.B).eval) - println(new _root_.foo.C) - println(reify(new _root_.foo.C).eval) + println(Foo2.B) + println(reify(Foo2.B).eval) + println(new Foo2.C) + println(reify(new Foo2.C).eval) + println(_root_.foo1.B) + println(reify(_root_.foo1.B).eval) + println(new _root_.foo1.C) + println(reify(new _root_.foo1.C).eval) } } } diff --git a/test/files/run/t2418.check b/test/files/run/t2418.check new file mode 100644 index 0000000000..f599e28b8a --- /dev/null +++ b/test/files/run/t2418.check @@ -0,0 +1 @@ +10 diff --git a/test/files/run/t2418.scala b/test/files/run/t2418.scala new file mode 100644 index 0000000000..f330bef60a --- /dev/null +++ b/test/files/run/t2418.scala @@ -0,0 +1,10 @@ +class Foo { + @volatile final var x=10 + override def toString = "" + x +} + +object Test { + def main(args: Array[String]): Unit = { + println((new Foo)) + } +} diff --git a/test/files/run/t2818.check b/test/files/run/t2818.check new file mode 100644 index 0000000000..31286c990b --- /dev/null +++ b/test/files/run/t2818.check @@ -0,0 +1,4 @@ +105 +499999500000 +0 +1 diff --git a/test/files/run/t2818.scala b/test/files/run/t2818.scala new file mode 100644 index 0000000000..19b67cbc88 --- /dev/null +++ b/test/files/run/t2818.scala @@ -0,0 +1,6 @@ +object Test extends App { + println((List.range(1L, 15L) :\ 0L) (_ + _)) + println((List.range(1L, 1000000L) :\ 0L) (_ + _)) + println((List.fill(5)(1) :\ 1) (_ - _)) + println((List.fill(1000000)(1) :\ 1) (_ - _)) +} diff --git a/test/files/run/t3353.check b/test/files/run/t3353.check new file mode 100644 index 0000000000..8b4ae1fe69 --- /dev/null +++ b/test/files/run/t3353.check @@ -0,0 +1 @@ +Got: foo and None diff --git a/test/files/run/t3353.scala b/test/files/run/t3353.scala new file mode 100644 index 0000000000..eeb63c1b05 --- /dev/null +++ b/test/files/run/t3353.scala @@ -0,0 +1,10 @@ +object Test extends App { + + "foo" match { + case Matcher(result) => println(result) + } + + object Matcher{ + def unapply(s: String)(implicit secondParam: Option[String] = None) = Some("Got: " + s + " and " + secondParam) + } +} diff --git a/test/files/run/t4729.check b/test/files/run/t4729.check new file mode 100644 index 0000000000..9a2aa56d99 --- /dev/null +++ b/test/files/run/t4729.check @@ -0,0 +1,4 @@ +WrappedArray(1, 2) +WrappedArray(1, 2) +WrappedArray(1, 2) +WrappedArray(1, 2) diff --git a/test/files/run/t4729/J_1.java b/test/files/run/t4729/J_1.java new file mode 100644 index 0000000000..2ffb5a88d1 --- /dev/null +++ b/test/files/run/t4729/J_1.java @@ -0,0 +1,4 @@ +// Java Interface: +public interface J_1 { + public void method(String... s); +} diff --git a/test/files/run/t4729/S_2.scala b/test/files/run/t4729/S_2.scala new file mode 100644 index 0000000000..e34e3d34d4 --- /dev/null +++ b/test/files/run/t4729/S_2.scala @@ -0,0 +1,29 @@ + // Scala class: +class ScalaVarArgs extends J_1 { + // -- no problem on overriding it using ordinary class + def method(s: String*) { println(s) } +} + +object Test { + def main(args: Array[String]) { + //[1] Ok - no problem using inferred type + val varArgs = new J_1 { + def method(s: String*) { println(s) } + } + varArgs.method("1", "2") + + //[2] Ok -- no problem when explicit set its type after construction + val b: J_1 = varArgs + b.method("1", "2") + + //[3] Ok -- no problem on calling its method + (new ScalaVarArgs).method("1", "2") + (new ScalaVarArgs: J_1).method("1", "2") + + //[4] Not Ok -- error when assigning anonymous class to a explictly typed val + // Compiler error: object creation impossible, since method method in trait VarArgs of type (s: <repeated...>[java.lang.String])Unit is not defined + val tagged: J_1 = new J_1 { + def method(s: String*) { println(s) } + } + } +} diff --git a/test/files/run/t5604.check b/test/files/run/t5604.check new file mode 100644 index 0000000000..53a2fc8894 --- /dev/null +++ b/test/files/run/t5604.check @@ -0,0 +1,8 @@ +long +double +long +double +long +double +long +double diff --git a/test/files/run/t5604.scala b/test/files/run/t5604.scala new file mode 100644 index 0000000000..a06c8aab3e --- /dev/null +++ b/test/files/run/t5604.scala @@ -0,0 +1,50 @@ +// a.scala +// Fri Jan 13 11:31:47 PST 2012 + +package foo { + object regular extends Duh { + def buh(n: Long) = println("long") + def buh(n: Double) = println("double") + } + class regular { + import regular._ + + duh(33L) + duh(3.0d) + foo.regular.duh(33L) + foo.regular.duh(3.0d) + buh(66L) + buh(6.0d) + foo.regular.buh(66L) + foo.regular.buh(6.0d) + } + + trait Duh { + def duh(n: Long) = println("long") + def duh(n: Double) = println("double") + } + package object bar extends Duh { + def buh(n: Long) = println("long") + def buh(n: Double) = println("double") + } + package bar { + object Main { + def main(args:Array[String]) { + duh(33L) + duh(3.0d) + foo.bar.duh(33L) + foo.bar.duh(3.0d) + buh(66L) + buh(6.0d) + foo.bar.buh(66L) + foo.bar.buh(6.0d) + } + } + } +} + +object Test { + def main(args: Array[String]): Unit = { + foo.bar.Main.main(null) + } +} diff --git a/test/files/run/t6206.check b/test/files/run/t6206.check new file mode 100644 index 0000000000..8064573667 --- /dev/null +++ b/test/files/run/t6206.check @@ -0,0 +1,4 @@ +outer +outer +inner +inner diff --git a/test/files/run/t6206.scala b/test/files/run/t6206.scala new file mode 100644 index 0000000000..07ff246d02 --- /dev/null +++ b/test/files/run/t6206.scala @@ -0,0 +1,37 @@ +class Outer { + def apply( position : Inner ) {} + class Inner + + this.apply(new Inner) + this (new Inner) // error, +} + + +class Outer1 { + + self => + + def apply( position : Inner ) : String = "outer" + + class Inner( ) { + + def apply(arg: Inner): String = "inner" + + def testMe = { + List( + self.apply( this ), // a) this works + self( this ), // b) this does not work! + this apply this, + this(this) + ) foreach println + } + } +} + +object Test { + def main(args: Array[String]): Unit = { + val o = new Outer1 + val i = new o.Inner + i.testMe + } +} diff --git a/test/files/run/t6572/bar_1.scala b/test/files/run/t6572/bar_1.scala new file mode 100644 index 0000000000..5518ced7af --- /dev/null +++ b/test/files/run/t6572/bar_1.scala @@ -0,0 +1,19 @@ +package bar + +abstract class IntBase[V] extends Base[Int, V] + +class DefaultIntBase[V <: IntProvider] extends IntBase[V] { + override protected def hashCode(key: Int) = key +} + +trait IntProvider { + def int: Int +} + +abstract class Base[@specialized K, V] { + + protected def hashCode(key: K) = key.hashCode + + def get(key: K): V = throw new RuntimeException + +}
\ No newline at end of file diff --git a/test/files/run/t6572/foo_2.scala b/test/files/run/t6572/foo_2.scala new file mode 100644 index 0000000000..465f0b7c3c --- /dev/null +++ b/test/files/run/t6572/foo_2.scala @@ -0,0 +1,17 @@ +//package foo + +import bar._ + +class FooProvider extends IntProvider { + def int = 3 +} + +class Wrapper(users: DefaultIntBase[FooProvider]) { + final def user(userId: Int) = users.get(userId) +} + +object Test { + def main(args: Array[String]) { + new Wrapper(new DefaultIntBase) + } +}
\ No newline at end of file diff --git a/test/files/run/t6584.check b/test/files/run/t6584.check new file mode 100644 index 0000000000..35c8688751 --- /dev/null +++ b/test/files/run/t6584.check @@ -0,0 +1,8 @@ +Array: 102400 +Vector: 102400 +List: 102400 +Stream: 102400 +Array: 102400 +Vector: 102400 +List: 102400 +Stream: 102400 diff --git a/test/files/run/t6584.scala b/test/files/run/t6584.scala new file mode 100644 index 0000000000..24c236ef35 --- /dev/null +++ b/test/files/run/t6584.scala @@ -0,0 +1,16 @@ +object Test { + def main(args: Array[String]): Unit = { + val size = 100 * 1024 + val doubled = (1 to size) ++ (1 to size) + + println("Array: " + Array.tabulate(size)(x => x).distinct.size) + println("Vector: " + Vector.tabulate(size)(x => x).distinct.size) + println("List: " + List.tabulate(size)(x => x).distinct.size) + println("Stream: " + Stream.tabulate(size)(x => x).distinct.size) + + println("Array: " + doubled.toArray.distinct.size) + println("Vector: " + doubled.toVector.distinct.size) + println("List: " + doubled.toList.distinct.size) + println("Stream: " + doubled.toStream.distinct.size) + } +} diff --git a/test/files/run/t6853.scala b/test/files/run/t6853.scala new file mode 100644 index 0000000000..352375c99c --- /dev/null +++ b/test/files/run/t6853.scala @@ -0,0 +1,18 @@ +// Test cases: the only place we can cut and paste without crying +// ourself to sleep. +object Test { + + def main(args: Array[String]): Unit = { + // First testing the basic operations + val m = collection.mutable.ListMap[String, Int]() + var i = 0 + while(i < 2) { m += ("foo" + i) -> i; i = i+1} + assert(m == Map("foo1"->1,"foo0"->0)) + m-= "foo0" + assert(m == Map("foo1"->1)) + // Now checking if it scales as described in SI-6853 + i = 0 + while(i < 80000) { m += ("foo" + i) -> i; i = i+1} + assert(m.size == 80000) + } +} diff --git a/test/pending/neg/t5378.scala b/test/pending/neg/t5378.scala deleted file mode 100644 index cada29b0a0..0000000000 --- a/test/pending/neg/t5378.scala +++ /dev/null @@ -1,19 +0,0 @@ -import language.reflectiveCalls - -class Coll[+T] { - def contains = new { def apply[T1 <: T](value: T1) = ??? } -} - -object Test { - def main(args: Array[String]): Unit = { - val xs = new Coll[List[String]] - val ys: Coll[Traversable[String]] = xs - - println(ys contains Nil) - // java.lang.NoSuchMethodException: Coll$$anon$1.apply(scala.collection.Traversable) - // at java.lang.Class.getMethod(Class.java:1605) - // at Test$.reflMethod$Method1(a.scala:14) - // at Test$.main(a.scala:14) - // at Test.main(a.scala) - } -} diff --git a/test/scaladoc/run/SI-6017.check b/test/scaladoc/run/SI-6017.check new file mode 100644 index 0000000000..619c56180b --- /dev/null +++ b/test/scaladoc/run/SI-6017.check @@ -0,0 +1 @@ +Done. diff --git a/test/scaladoc/run/SI-6017.scala b/test/scaladoc/run/SI-6017.scala new file mode 100644 index 0000000000..a4950e48d8 --- /dev/null +++ b/test/scaladoc/run/SI-6017.scala @@ -0,0 +1,23 @@ +import scala.tools.nsc.doc +import scala.tools.nsc.doc.model._ +import scala.tools.nsc.doc.html.page.{Index, ReferenceIndex} +import scala.tools.partest.ScaladocModelTest + +object Test extends ScaladocModelTest { + override def scaladocSettings = "" + override def code = """ + class STAR + class Star + """ + + def testModel(rootPackage: Package) { + model match { + case Some(universe) => { + val index = IndexModelFactory.makeIndex(universe) + // Because "STAR" and "Star" are different + assert(index.firstLetterIndex('s').keys.toSeq.length == 2) + } + case _ => assert(false) + } + } +} diff --git a/test/scaladoc/run/SI-6812.check b/test/scaladoc/run/SI-6812.check new file mode 100644 index 0000000000..619c56180b --- /dev/null +++ b/test/scaladoc/run/SI-6812.check @@ -0,0 +1 @@ +Done. diff --git a/test/scaladoc/run/SI-6812.scala b/test/scaladoc/run/SI-6812.scala new file mode 100644 index 0000000000..fbd9588ede --- /dev/null +++ b/test/scaladoc/run/SI-6812.scala @@ -0,0 +1,24 @@ +import scala.tools.nsc.doc.model._ +import scala.tools.partest.ScaladocModelTest +import language._ + +object Test extends ScaladocModelTest { + + override def code = """ + import scala.reflect.macros.Context + import language.experimental.macros + + object Macros { + def impl(c: Context) = c.literalUnit + def foo = macro impl + } + + class C { + def bar = Macros.foo + } + """ + + def scaladocSettings = "" + override def extraSettings = super.extraSettings + " -Ymacro-no-expand" + def testModel(root: Package) = () +} |