diff options
Diffstat (limited to 'test/files/run')
37 files changed, 433 insertions, 58 deletions
diff --git a/test/files/run/elidable-opt.check b/test/files/run/elidable-opt.check index 88cf98e0d1..969b9a420a 100644 --- a/test/files/run/elidable-opt.check +++ b/test/files/run/elidable-opt.check @@ -11,4 +11,4 @@ false 0 0.0 0.0 -null + diff --git a/test/files/run/elidable.check b/test/files/run/elidable.check index 88cf98e0d1..969b9a420a 100644 --- a/test/files/run/elidable.check +++ b/test/files/run/elidable.check @@ -11,4 +11,4 @@ false 0 0.0 0.0 -null + diff --git a/test/files/run/elidable.scala b/test/files/run/elidable.scala index 02785972bb..fed1c7b392 100644 --- a/test/files/run/elidable.scala +++ b/test/files/run/elidable.scala @@ -3,31 +3,36 @@ import elidable._ // runs -Xelide-below WARNING or 900 +object Fail { + def fail(msg: String): Unit = throw new IllegalStateException(s"Expected failure: $msg") +} +import Fail.fail + trait T { @elidable(FINEST) def f1() @elidable(SEVERE) def f2() - @elidable(FINEST) def f3() = assert(false, "Should have been elided.") + @elidable(FINEST) def f3() = fail("Should have been elided.") def f4() } class C extends T { def f1() = println("Good for me, I was not elided. C.f1") def f2() = println("Good for me, I was not elided. C.f2") - @elidable(FINEST) def f4() = assert(false, "Should have been elided.") + @elidable(FINEST) def f4() = fail("Should have been elided.") } object O { - @elidable(FINEST) def f1() = assert(false, "Should have been elided.") - @elidable(INFO) def f2() = assert(false, "Should have been elided.") + @elidable(FINEST) def f1() = fail("Should have been elided.") + @elidable(INFO) def f2() = fail("Should have been elided.") @elidable(SEVERE) def f3() = println("Good for me, I was not elided. O.f3") - @elidable(INFO) def f4 = assert(false, "Should have been elided (no parens).") + @elidable(INFO) def f4 = fail("Should have been elided (no parens).") } object Test { - @elidable(FINEST) def f1() = assert(false, "Should have been elided.") - @elidable(INFO) def f2() = assert(false, "Should have been elided.") + @elidable(FINEST) def f1() = fail("Should have been elided.") + @elidable(INFO) def f2() = fail("Should have been elided.") @elidable(SEVERE) def f3() = println("Good for me, I was not elided. Test.f3") - @elidable(INFO) def f4 = assert(false, "Should have been elided (no parens).") + @elidable(INFO) def f4 = fail("Should have been elided (no parens).") @elidable(FINEST) def f5() = {} @elidable(FINEST) def f6() = true @@ -38,12 +43,12 @@ object Test { @elidable(FINEST) def fb() = 1l @elidable(FINEST) def fc() = 1.0f @elidable(FINEST) def fd() = 1.0 - @elidable(FINEST) def fe() = "s" + @elidable(FINEST) def fe() = { fail("Should have been elided to empty string.") ; "hello, world" } /* variable elisions? see test/files/neg/t10068.scala - @elidable(INFO) val goner1: Int = { assert(false, "Should have been elided.") ; 42 } - @elidable(INFO) lazy val goner2: Int = { assert(false, "Should have been elided.") ; 42 } - @elidable(INFO) var goner3: Int = { assert(false, "Should have been elided.") ; 42 } + @elidable(INFO) val goner1: Int = { fail("Should have been elided.") ; 42 } + @elidable(INFO) lazy val goner2: Int = { fail("Should have been elided.") ; 42 } + @elidable(INFO) var goner3: Int = { fail("Should have been elided.") ; 42 } @elidable(INFO) var goner4: Nothing = _ */ @@ -74,6 +79,19 @@ object Test { println(fc()) println(fd()) println(fe()) + if (!fe().isEmpty) fail(s"Not empty: [${fe()}]") +/* +() +false +0 +0 +0 +0 +0 +0.0 +0.0 + // was: null +*/ // this one won't show up in the output because a call to f1 is elidable when accessed through T (c:T).f1() diff --git a/test/files/run/existentials-in-compiler.check b/test/files/run/existentials-in-compiler.check index b0d852865d..8800df0823 100644 --- a/test/files/run/existentials-in-compiler.check +++ b/test/files/run/existentials-in-compiler.check @@ -2,28 +2,28 @@ abstract trait Bippy[A <: AnyRef, B] extends AnyRef extest.Bippy[_ <: AnyRef, _] abstract trait BippyBud[A <: AnyRef, B, C <: List[A]] extends AnyRef - extest.BippyBud[A,B,C] forSome { A <: AnyRef; B; C <: List[A] } + extest.BippyBud[?0,?1,?2] forSome { type ?0 <: AnyRef; type ?1; type ?2 <: List[?0] } abstract trait BippyLike[A <: AnyRef, B <: List[A], This <: extest.BippyLike[A,B,This] with extest.Bippy[A,B]] extends AnyRef - extest.BippyLike[A,B,This] forSome { A <: AnyRef; B <: List[A]; This <: extest.BippyLike[A,B,This] with extest.Bippy[A,B] } + extest.BippyLike[?0,?1,?2] forSome { type ?0 <: AnyRef; type ?1 <: List[?0]; type ?2 <: extest.BippyLike[?0,?1,?2] with extest.Bippy[?0,?1] } abstract trait Contra[-A >: AnyRef, -B] extends AnyRef - extest.Contra[AnyRef, _] + extest.Contra[_ >: AnyRef, _] abstract trait ContraLike[-A >: AnyRef, -B >: List[A]] extends AnyRef - extest.ContraLike[A,B] forSome { -A >: AnyRef; -B >: List[A] } + extest.ContraLike[?0,?1] forSome { type ?0 >: AnyRef; type ?1 >: List[?0] } abstract trait Cov01[+A <: AnyRef, +B] extends AnyRef - extest.Cov01[AnyRef,Any] + extest.Cov01[_ <: AnyRef, _] abstract trait Cov02[+A <: AnyRef, B] extends AnyRef - extest.Cov02[AnyRef, _] + extest.Cov02[_ <: AnyRef, _] abstract trait Cov03[+A <: AnyRef, -B] extends AnyRef - extest.Cov03[AnyRef, _] + extest.Cov03[_ <: AnyRef, _] abstract trait Cov04[A <: AnyRef, +B] extends AnyRef - extest.Cov04[_ <: AnyRef, Any] + extest.Cov04[_ <: AnyRef, _] abstract trait Cov05[A <: AnyRef, B] extends AnyRef extest.Cov05[_ <: AnyRef, _] @@ -32,7 +32,7 @@ abstract trait Cov06[A <: AnyRef, -B] extends AnyRef extest.Cov06[_ <: AnyRef, _] abstract trait Cov07[-A <: AnyRef, +B] extends AnyRef - extest.Cov07[_ <: AnyRef, Any] + extest.Cov07[_ <: AnyRef, _] abstract trait Cov08[-A <: AnyRef, B] extends AnyRef extest.Cov08[_ <: AnyRef, _] @@ -41,16 +41,16 @@ abstract trait Cov09[-A <: AnyRef, -B] extends AnyRef extest.Cov09[_ <: AnyRef, _] abstract trait Cov11[+A <: AnyRef, +B <: List[_]] extends AnyRef - extest.Cov11[AnyRef,List[_]] + extest.Cov11[_ <: AnyRef, _ <: List[_]] abstract trait Cov12[+A <: AnyRef, B <: List[_]] extends AnyRef - extest.Cov12[AnyRef, _ <: List[_]] + extest.Cov12[_ <: AnyRef, _ <: List[_]] abstract trait Cov13[+A <: AnyRef, -B <: List[_]] extends AnyRef - extest.Cov13[AnyRef, _ <: List[_]] + extest.Cov13[_ <: AnyRef, _ <: List[_]] abstract trait Cov14[A <: AnyRef, +B <: List[_]] extends AnyRef - extest.Cov14[_ <: AnyRef, List[_]] + extest.Cov14[_ <: AnyRef, _ <: List[_]] abstract trait Cov15[A <: AnyRef, B <: List[_]] extends AnyRef extest.Cov15[_ <: AnyRef, _ <: List[_]] @@ -59,7 +59,7 @@ abstract trait Cov16[A <: AnyRef, -B <: List[_]] extends AnyRef extest.Cov16[_ <: AnyRef, _ <: List[_]] abstract trait Cov17[-A <: AnyRef, +B <: List[_]] extends AnyRef - extest.Cov17[_ <: AnyRef, List[_]] + extest.Cov17[_ <: AnyRef, _ <: List[_]] abstract trait Cov18[-A <: AnyRef, B <: List[_]] extends AnyRef extest.Cov18[_ <: AnyRef, _ <: List[_]] @@ -68,16 +68,16 @@ abstract trait Cov19[-A <: AnyRef, -B <: List[_]] extends AnyRef extest.Cov19[_ <: AnyRef, _ <: List[_]] abstract trait Cov21[+A, +B] extends AnyRef - extest.Cov21[Any,Any] + extest.Cov21[_, _] abstract trait Cov22[+A, B] extends AnyRef - extest.Cov22[Any, _] + extest.Cov22[_, _] abstract trait Cov23[+A, -B] extends AnyRef - extest.Cov23[Any, _] + extest.Cov23[_, _] abstract trait Cov24[A, +B] extends AnyRef - extest.Cov24[_, Any] + extest.Cov24[_, _] abstract trait Cov25[A, B] extends AnyRef extest.Cov25[_, _] @@ -86,7 +86,7 @@ abstract trait Cov26[A, -B] extends AnyRef extest.Cov26[_, _] abstract trait Cov27[-A, +B] extends AnyRef - extest.Cov27[_, Any] + extest.Cov27[_, _] abstract trait Cov28[-A, B] extends AnyRef extest.Cov28[_, _] @@ -95,43 +95,43 @@ abstract trait Cov29[-A, -B] extends AnyRef extest.Cov29[_, _] abstract trait Cov31[+A, +B, C <: (A, B)] extends AnyRef - extest.Cov31[A,B,C] forSome { +A; +B; C <: (A, B) } + extest.Cov31[?0,?1,?2] forSome { type ?0; type ?1; type ?2 <: (?0, ?1) } abstract trait Cov32[+A, B, C <: (A, B)] extends AnyRef - extest.Cov32[A,B,C] forSome { +A; B; C <: (A, B) } + extest.Cov32[?0,?1,?2] forSome { type ?0; type ?1; type ?2 <: (?0, ?1) } abstract trait Cov33[+A, -B, C <: Tuple2[A, _]] extends AnyRef - extest.Cov33[A,B,C] forSome { +A; -B; C <: Tuple2[A, _] } + extest.Cov33[?0,?1,?2] forSome { type ?0; type ?1; type ?2 <: Tuple2[?0, _] } abstract trait Cov34[A, +B, C <: (A, B)] extends AnyRef - extest.Cov34[A,B,C] forSome { A; +B; C <: (A, B) } + extest.Cov34[?0,?1,?2] forSome { type ?0; type ?1; type ?2 <: (?0, ?1) } abstract trait Cov35[A, B, C <: (A, B)] extends AnyRef - extest.Cov35[A,B,C] forSome { A; B; C <: (A, B) } + extest.Cov35[?0,?1,?2] forSome { type ?0; type ?1; type ?2 <: (?0, ?1) } abstract trait Cov36[A, -B, C <: Tuple2[A, _]] extends AnyRef - extest.Cov36[A,B,C] forSome { A; -B; C <: Tuple2[A, _] } + extest.Cov36[?0,?1,?2] forSome { type ?0; type ?1; type ?2 <: Tuple2[?0, _] } abstract trait Cov37[-A, +B, C <: Tuple2[_, B]] extends AnyRef - extest.Cov37[A,B,C] forSome { -A; +B; C <: Tuple2[_, B] } + extest.Cov37[?0,?1,?2] forSome { type ?0; type ?1; type ?2 <: Tuple2[_, ?1] } abstract trait Cov38[-A, B, C <: Tuple2[_, B]] extends AnyRef - extest.Cov38[A,B,C] forSome { -A; B; C <: Tuple2[_, B] } + extest.Cov38[?0,?1,?2] forSome { type ?0; type ?1; type ?2 <: Tuple2[_, ?1] } abstract trait Cov39[-A, -B, C <: Tuple2[_, _]] extends AnyRef extest.Cov39[_, _, _ <: Tuple2[_, _]] abstract trait Cov41[+A >: Null, +B] extends AnyRef - extest.Cov41[Any,Any] + extest.Cov41[_ >: Null, _] abstract trait Cov42[+A >: Null, B] extends AnyRef - extest.Cov42[Any, _] + extest.Cov42[_ >: Null, _] abstract trait Cov43[+A >: Null, -B] extends AnyRef - extest.Cov43[Any, _] + extest.Cov43[_ >: Null, _] abstract trait Cov44[A >: Null, +B] extends AnyRef - extest.Cov44[_ >: Null, Any] + extest.Cov44[_ >: Null, _] abstract trait Cov45[A >: Null, B] extends AnyRef extest.Cov45[_ >: Null, _] @@ -140,7 +140,7 @@ abstract trait Cov46[A >: Null, -B] extends AnyRef extest.Cov46[_ >: Null, _] abstract trait Cov47[-A >: Null, +B] extends AnyRef - extest.Cov47[_ >: Null, Any] + extest.Cov47[_ >: Null, _] abstract trait Cov48[-A >: Null, B] extends AnyRef extest.Cov48[_ >: Null, _] @@ -149,8 +149,8 @@ abstract trait Cov49[-A >: Null, -B] extends AnyRef extest.Cov49[_ >: Null, _] abstract trait Covariant[+A <: AnyRef, +B] extends AnyRef - extest.Covariant[AnyRef,Any] + extest.Covariant[_ <: AnyRef, _] abstract trait CovariantLike[+A <: AnyRef, +B <: List[A], +This <: extest.CovariantLike[A,B,This] with extest.Covariant[A,B]] extends AnyRef - extest.CovariantLike[A,B,This] forSome { +A <: AnyRef; +B <: List[A]; +This <: extest.CovariantLike[A,B,This] with extest.Covariant[A,B] } + extest.CovariantLike[?0,?1,?2] forSome { type ?0 <: AnyRef; type ?1 <: List[?0]; type ?2 <: extest.CovariantLike[?0,?1,?2] with extest.Covariant[?0,?1] } diff --git a/test/files/run/existentials-in-compiler.scala b/test/files/run/existentials-in-compiler.scala index e516eddf95..e35b7231c2 100644 --- a/test/files/run/existentials-in-compiler.scala +++ b/test/files/run/existentials-in-compiler.scala @@ -79,7 +79,7 @@ package extest { exitingTyper { clazz.info println(clazz.defString) - println(" " + classExistentialType(clazz) + "\n") + println(" " + classExistentialType(clazz.owner.typeOfThis, clazz) + "\n") } } } diff --git a/test/files/run/hash-hash-hash-hash.scala b/test/files/run/hash-hash-hash-hash.scala new file mode 100644 index 0000000000..08793871a7 --- /dev/null +++ b/test/files/run/hash-hash-hash-hash.scala @@ -0,0 +1,5 @@ +object Test { + def main(args: Array[String]): Unit = { + assert(1.##.## == 1) // was java.lang.NoSuchMethodError: java.lang.Object.$hash$hash()I + } +} diff --git a/test/files/run/iq.scala b/test/files/run/iq.scala index 0ccf67a2e9..9929f0e1a0 100644 --- a/test/files/run/iq.scala +++ b/test/files/run/iq.scala @@ -25,12 +25,18 @@ object iq { assert(q2 == qb) val qc = 42 +: q :+ 0 assert(q2 == qc) + assert(q ++ qa == qa) + val qdr = 1 +: 2 +: 3 +: 4 +: q + val qcon1 = 1 +: 2 +: q + val qcon2 = q :+ 3 :+ 4 + val qd = qcon1 ++ qcon2 + assert(qd == qdr) Console.println("q2: " + q2) Console.println("qa: " + qa) Console.println("qb: " + qb) Console.println("qc: " + qc) - + /* Test is empty and dequeue. * Expected: Head: 42 */ diff --git a/test/files/run/literals.scala b/test/files/run/literals.scala index 13fda05876..a7962e5cd9 100644 --- a/test/files/run/literals.scala +++ b/test/files/run/literals.scala @@ -6,7 +6,7 @@ object Test { - /* I add a couple of Unicode identifier tests here temporarily */ + /* I add a couple of Unicode identifier tests here "temporarily" */ def \u03b1\u03c1\u03b5\u03c4\u03b7 = "alpha rho epsilon tau eta" @@ -80,10 +80,17 @@ object Test { check_success("1e1f == 10.0f", 1e1f, 10.0f) check_success(".3f == 0.3f", .3f, 0.3f) check_success("0f == 0.0f", 0f, 0.0f) + check_success("0f == -0.000000000000000000e+00f", 0f, -0.000000000000000000e+00f) + check_success("0f == -0.000000000000000000e+00F", 0f, -0.000000000000000000e+00F) + check_success("0f == -0.0000000000000000e14f", 0f, -0.0000000000000000e14f) check_success("01.23f == 1.23f", 01.23f, 1.23f) check_success("3.14f == 3.14f", 3.14f, 3.14f) check_success("6.022e23f == 6.022e23f", 6.022e23f, 6.022e23f) check_success("09f == 9.0f", 09f, 9.0f) + check_success("1.00000017881393421514957253748434595763683319091796875001f == 1.0000001f", + 1.00000017881393421514957253748434595763683319091796875001f, + 1.0000001f) + check_success("3.4028235E38f == Float.MaxValue", 3.4028235E38f, Float.MaxValue) check_success("1.asInstanceOf[Float] == 1.0", 1.asInstanceOf[Float], 1.0f) check_success("1l.asInstanceOf[Float] == 1.0", 1l.asInstanceOf[Float], 1.0f) @@ -92,11 +99,17 @@ object Test { check_success(".3 == 0.3", .3, 0.3) check_success("0.0 == 0.0", 0.0, 0.0) check_success("0d == 0.0", 0d, 0.0) + check_success("0d == 0.000000000000000000e+00d", 0d, 0.000000000000000000e+00d) + check_success("0d == -0.000000000000000000e+00d", 0d, -0.000000000000000000e+00d) + check_success("0d == -0.000000000000000000e+00D", 0d, -0.000000000000000000e+00D) + check_success("0.0 == 0.000000000000000000e+00", 0.0, 0.000000000000000000e+00) + check_success("0.0 == -0.000000000000000000e+00", 0.0, -0.000000000000000000e+00) check_success("01.23 == 1.23", 01.23, 1.23) check_success("01.23d == 1.23d", 01.23d, 1.23d) check_success("3.14 == 3.14", 3.14, 3.14) check_success("1e-9d == 1.0e-9", 1e-9d, 1.0e-9) check_success("1e137 == 1.0e137", 1e137, 1.0e137) + check_success("1.7976931348623157e308d == Double.MaxValue", 1.7976931348623157e308d, Double.MaxValue) check_success("1.asInstanceOf[Double] == 1.0", 1.asInstanceOf[Double], 1.0) check_success("1l.asInstanceOf[Double] == 1.0", 1l.asInstanceOf[Double], 1.0) diff --git a/test/files/run/patmat-exprs.scala b/test/files/run/patmat-exprs.scala index 7ca5fd3063..d18df9c714 100644 --- a/test/files/run/patmat-exprs.scala +++ b/test/files/run/patmat-exprs.scala @@ -344,13 +344,13 @@ trait Pattern { } - case class Zero[T] (implicit num: NumericOps[T]) extends Leaf[T] { + case class Zero[T]()(implicit num: NumericOps[T]) extends Leaf[T] { def derivative(variable: Var[T]) = Zero[T] def eval(f: Any => Any) = num.zero override def toString = "0" } - case class One[T] (implicit num: NumericOps[T]) extends Leaf[T] { + case class One[T]()(implicit num: NumericOps[T]) extends Leaf[T] { def derivative(variable: Var[T]) = Zero[T] def eval(f: Any => Any) = num.one override def toString = "1" diff --git a/test/files/run/repl-colon-type.check b/test/files/run/repl-colon-type.check index 1217e8d8c2..5b7a3c7506 100644 --- a/test/files/run/repl-colon-type.check +++ b/test/files/run/repl-colon-type.check @@ -75,7 +75,7 @@ TypeRef( ) TypeRef( TypeSymbol( - sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] with Serializable + sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] with FilteredTraversableInternal[A,List[A]] with Serializable ) args = List( @@ -142,7 +142,7 @@ TypeRef( args = List( TypeRef( TypeSymbol( - sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] with Serializable + sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] with FilteredTraversableInternal[A,List[A]] with Serializable ) args = List( @@ -175,7 +175,7 @@ PolyType( args = List( TypeRef( TypeSymbol( - sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] with Serializable + sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] with FilteredTraversableInternal[A,List[A]] with Serializable ) args = List(TypeParamTypeRef(TypeParam(T <: AnyVal))) @@ -198,7 +198,7 @@ PolyType( params = List(TermSymbol(x: T), TermSymbol(y: List[U])) resultType = TypeRef( TypeSymbol( - sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] with Serializable + sealed abstract class List[+A] extends AbstractSeq[A] with LinearSeq[A] with Product with GenericTraversableTemplate[A,List] with LinearSeqOptimized[A,List[A]] with FilteredTraversableInternal[A,List[A]] with Serializable ) args = List(TypeParamTypeRef(TypeParam(U >: T))) diff --git a/test/files/run/t10026.check b/test/files/run/t10026.check new file mode 100644 index 0000000000..15a62794a9 --- /dev/null +++ b/test/files/run/t10026.check @@ -0,0 +1 @@ +List(1, 2, 3) diff --git a/test/files/run/t10026.scala b/test/files/run/t10026.scala new file mode 100644 index 0000000000..a56840c8c2 --- /dev/null +++ b/test/files/run/t10026.scala @@ -0,0 +1,11 @@ +import scala.reflect.runtime.universe +import scala.tools.reflect.ToolBox + +object Test { + def main(args: Array[String]): Unit = { + val classloader = getClass.getClassLoader + val toolbox = universe.runtimeMirror(classloader).mkToolBox() + println(toolbox.compile(toolbox.parse("Array(1, 2, 3).toList")).apply()) + } +} + diff --git a/test/files/run/t10072.scala b/test/files/run/t10072.scala new file mode 100644 index 0000000000..0f1dca1838 --- /dev/null +++ b/test/files/run/t10072.scala @@ -0,0 +1,18 @@ +trait T[A] { + def a: A + def foldLeft[B](zero: B, op: (B, A) => B): B = op(zero, a) + def sum[B >: A](zero: B): B +} + +class C[@specialized(Int) A](val a: A) extends T[A] { + override def sum[@specialized(Int) B >: A](zero: B): B = foldLeft(zero, (x: B, y: B) => x) +} + +object Test extends App { + def factory[T](a: T): C[T] = new C[T](a) + + assert(new C[Int](1).sum(2) == 2) + assert(new C[String]("ho").sum("hu") == "hu") + assert(factory[Int](1).sum(2) == 2) + assert(factory[String]("ho").sum("hu") == "hu") +} diff --git a/test/files/run/t10097.check b/test/files/run/t10097.check new file mode 100644 index 0000000000..0e8b96061c --- /dev/null +++ b/test/files/run/t10097.check @@ -0,0 +1,3 @@ +t10097.scala:2: warning: case classes should have a non-implicit parameter list; adapting to 'case class C()(...)' +case class C(implicit c: Int) + ^ diff --git a/test/files/run/t10097.flags b/test/files/run/t10097.flags new file mode 100644 index 0000000000..dcc59ebe32 --- /dev/null +++ b/test/files/run/t10097.flags @@ -0,0 +1 @@ +-deprecation diff --git a/test/files/run/t10097.scala b/test/files/run/t10097.scala new file mode 100644 index 0000000000..a16be897cc --- /dev/null +++ b/test/files/run/t10097.scala @@ -0,0 +1,6 @@ + +case class C(implicit c: Int) + +object Test extends App { + assert(C()(42).productArity == 0) +} diff --git a/test/files/run/t1459.check b/test/files/run/t1459.check new file mode 100644 index 0000000000..93b4c5a810 --- /dev/null +++ b/test/files/run/t1459.check @@ -0,0 +1,3 @@ +JavaPrinter: one two three +InheritingPrinter extends JavaPrinter: one two three +ScalaPrinter: onetwothree diff --git a/test/files/run/t1459/InheritingPrinter.scala b/test/files/run/t1459/InheritingPrinter.scala new file mode 100644 index 0000000000..70301307f5 --- /dev/null +++ b/test/files/run/t1459/InheritingPrinter.scala @@ -0,0 +1,6 @@ +class InheritingPrinter extends JavaPrinter { + override def doit(s: String*) { + print("InheritingPrinter extends ") + super.doit(s: _*); + } +}
\ No newline at end of file diff --git a/test/files/run/t1459/JavaPrinter.java b/test/files/run/t1459/JavaPrinter.java new file mode 100644 index 0000000000..3912ea613a --- /dev/null +++ b/test/files/run/t1459/JavaPrinter.java @@ -0,0 +1,7 @@ +public class JavaPrinter implements VarArg { + public void doit(String... s) { + System.out.print("JavaPrinter: "); + for(String str : s) + System.out.print(str + " "); + } +} diff --git a/test/files/run/t1459/ScalaPrinter.scala b/test/files/run/t1459/ScalaPrinter.scala new file mode 100644 index 0000000000..46305804c2 --- /dev/null +++ b/test/files/run/t1459/ScalaPrinter.scala @@ -0,0 +1,6 @@ +class ScalaPrinter extends VarArg { + override def doit(s: String*) = { + print("ScalaPrinter: ") + s.foreach(print _) + } +}
\ No newline at end of file diff --git a/test/files/run/t1459/Test.java b/test/files/run/t1459/Test.java new file mode 100644 index 0000000000..3cf91e2e8b --- /dev/null +++ b/test/files/run/t1459/Test.java @@ -0,0 +1,15 @@ +public class Test { + public static void main(String[] args) { + VarArg jp = new JavaPrinter(); + VarArg ip = new InheritingPrinter(); + VarArg sp = new ScalaPrinter(); + doYourThing(jp); + doYourThing(ip); + doYourThing(sp); + } + + public static void doYourThing(VarArg va) { + va.doit("one", "two", "three"); + System.out.println(); + } +} diff --git a/test/files/run/t1459/VarArg.java b/test/files/run/t1459/VarArg.java new file mode 100644 index 0000000000..7039f99e7b --- /dev/null +++ b/test/files/run/t1459/VarArg.java @@ -0,0 +1,3 @@ +public interface VarArg { + void doit(String... s); +} diff --git a/test/files/run/t1459generic.check b/test/files/run/t1459generic.check new file mode 100644 index 0000000000..346fadbc0d --- /dev/null +++ b/test/files/run/t1459generic.check @@ -0,0 +1,4 @@ +Note: t1459generic/Test.java uses unchecked or unsafe operations. +Note: Recompile with -Xlint:unchecked for details. +ab +ab diff --git a/test/files/run/t1459generic/Impl.scala b/test/files/run/t1459generic/Impl.scala new file mode 100644 index 0000000000..9234e70456 --- /dev/null +++ b/test/files/run/t1459generic/Impl.scala @@ -0,0 +1,4 @@ +class Impl extends VarargGeneric[String] { + def genericOne(x: String, arg: String): String = x + arg + def genericVar(x: String, args: String*): String = x + args.head +} diff --git a/test/files/run/t1459generic/Test.java b/test/files/run/t1459generic/Test.java new file mode 100644 index 0000000000..a97158796b --- /dev/null +++ b/test/files/run/t1459generic/Test.java @@ -0,0 +1,10 @@ +public class Test { + public static void main(String[] args) throws Exception { + VarargGeneric vg = new Impl(); + System.out.println(vg.genericOne("a", "b")); + System.out.println(vg.genericVar("a", "b")); + // should not result in java.lang.AbstractMethodError: Impl.genericVar(Ljava/lang/Object;[Ljava/lang/String;)Ljava/lang/String; + // --> genericVar needs a varargs bridge (scala -> java varargs) and a standard generics bridge + // (for comparison, including genericOne, which needs only a generics bridge) + } +} diff --git a/test/files/run/t1459generic/VarargGeneric.java b/test/files/run/t1459generic/VarargGeneric.java new file mode 100644 index 0000000000..9b37a0fe3f --- /dev/null +++ b/test/files/run/t1459generic/VarargGeneric.java @@ -0,0 +1,7 @@ +public interface VarargGeneric<T> { + String genericOne(T x, String args); + // we cannot annotate this with @SafeVarargs, because + // it's in an interface. so that's why a warning from + // javac appears in the checkfile. + String genericVar(T x, String... args); +} diff --git a/test/files/run/t4700.check b/test/files/run/t4700.check new file mode 100644 index 0000000000..ae854b959d --- /dev/null +++ b/test/files/run/t4700.check @@ -0,0 +1,44 @@ + +scala> import scala.annotation.showAsInfix +import scala.annotation.showAsInfix + +scala> class &&[T,U] +defined class $amp$amp + +scala> def foo: Int && Boolean = ??? +foo: Int && Boolean + +scala> def foo: Int && Boolean && String = ??? +foo: Int && Boolean && String + +scala> def foo: Int && (Boolean && String) = ??? +foo: Int && (Boolean && String) + +scala> @showAsInfix type Mappy[T, U] = Map[T, U] +defined type alias Mappy + +scala> def foo: Int Mappy (Boolean && String) = ??? +foo: Int Mappy (Boolean && String) + +scala> @showAsInfix(false) class ||[T,U] +defined class $bar$bar + +scala> def foo: Int || Boolean = ??? +foo: ||[Int,Boolean] + +scala> class &:[L, R] +defined class $amp$colon + +scala> def foo: Int &: String = ??? +foo: Int &: String + +scala> def foo: Int &: Boolean &: String = ??? +foo: Int &: Boolean &: String + +scala> def foo: (Int && String) &: Boolean = ??? +foo: (Int && String) &: Boolean + +scala> def foo: Int && (Boolean &: String) = ??? +foo: Int && (Boolean &: String) + +scala> :quit diff --git a/test/files/run/t4700.scala b/test/files/run/t4700.scala new file mode 100644 index 0000000000..7c02676e89 --- /dev/null +++ b/test/files/run/t4700.scala @@ -0,0 +1,22 @@ +import scala.tools.nsc.interpreter._ +import scala.tools.partest.ReplTest + +object Test extends ReplTest { + def code = """ + |import scala.annotation.showAsInfix + |class &&[T,U] + |def foo: Int && Boolean = ??? + |def foo: Int && Boolean && String = ??? + |def foo: Int && (Boolean && String) = ??? + |@showAsInfix type Mappy[T, U] = Map[T, U] + |def foo: Int Mappy (Boolean && String) = ??? + |@showAsInfix(false) class ||[T,U] + |def foo: Int || Boolean = ??? + |class &:[L, R] + |def foo: Int &: String = ??? + |def foo: Int &: Boolean &: String = ??? + |def foo: (Int && String) &: Boolean = ??? + |def foo: Int && (Boolean &: String) = ??? + |""".stripMargin +} + diff --git a/test/files/run/t5907.scala b/test/files/run/t5907.scala index a005e9fbd3..81fc43e3f5 100644 --- a/test/files/run/t5907.scala +++ b/test/files/run/t5907.scala @@ -86,7 +86,7 @@ object Test extends App { } } -case class C1(implicit x: Int) { +case class C1()(implicit x: Int) { override def toString = s"c1: $x" } case class C2()(y: Int) { diff --git a/test/files/run/t9013/Test.java b/test/files/run/t9013/Test.java new file mode 100644 index 0000000000..14152b16ac --- /dev/null +++ b/test/files/run/t9013/Test.java @@ -0,0 +1,20 @@ +import java.util.Comparator; + +public class Test { + public static void main(String[] args) { + ClassImplementsClass c = new ClassImplementsClass(); + + c.x("a", "b", "c"); + c.y("a", "b", "c"); + c.z("a", "b", "c"); + + VarargAbstractClass i = new ClassImplementsClass(); + + i.x("a", "b", "c"); + i.y("a", "b", "c"); + // System.out.println(i.z("a", "b", "c")); // still incurs a LinkageError. + // Perhaps due to Uncurry: + // > for every repeated Java parameter `x: T...' --> x: Array[T], except: + // > if T is an unbounded abstract type, replace --> x: Array[Object] + } +} diff --git a/test/files/run/t9013/test.scala b/test/files/run/t9013/test.scala new file mode 100644 index 0000000000..073f8d086f --- /dev/null +++ b/test/files/run/t9013/test.scala @@ -0,0 +1,18 @@ +import scala.annotation.varargs + +abstract class VarargAbstractClass[T] { + @varargs + def x(els: String*): Int + + @varargs + def y(els: String*): Int + + @varargs + def z(els: T*): Int +} +class ClassImplementsClass extends VarargAbstractClass[String] { + + override def x(els: String*): Int = els.length + override def y(els: String*): Int = els.length + override def z(els: String*): Int = els.length +} diff --git a/test/files/run/t9114.scala b/test/files/run/t9114.scala new file mode 100644 index 0000000000..656a5c7d8d --- /dev/null +++ b/test/files/run/t9114.scala @@ -0,0 +1,31 @@ +import annotation.unchecked + +class Test { + trait Two[A, B] + type One[A] = Two[A,A] + class View extends One[Any] + + def checkAny(x: Some[One[Any]]) = x match { // okay + case Some(_: View) => true + case _ => false + } + def checkAbstract[A](x: Some[One[A]]) = x match { // okay + case Some(_: View) => true + case _ => false + } + + def checkExistential(x: Some[One[_]]) = x match { + case Some(_: View) => true // compiler crash + case _ => false + } +} + +object Test { + def main(args: Array[String]): Unit = { + val t1 = new Test + val t2 = new Test + assert(t1.checkAny(Some(new t1.View))) + assert(t1.checkAbstract(Some(new t1.View))) + assert(t1.checkExistential(Some(new t1.View))) + } +} diff --git a/test/files/run/t9880-9881.check b/test/files/run/t9880-9881.check new file mode 100644 index 0000000000..36513e249a --- /dev/null +++ b/test/files/run/t9880-9881.check @@ -0,0 +1,36 @@ + +scala> // import in various ways + +scala> import java.util.Date +import java.util.Date + +scala> import scala.util._ +import scala.util._ + +scala> import scala.reflect.runtime.{universe => ru} +import scala.reflect.runtime.{universe=>ru} + +scala> import ru.TypeTag +import ru.TypeTag + +scala> + +scala> // show the imports + +scala> :imports + 1) import java.lang._ (...) + 2) import scala._ (...) + 3) import scala.Predef._ (...) + 4) import java.util.Date (...) + 5) import scala.util._ (...) + 6) import scala.reflect.runtime.{universe=>ru} (...) + 7) import ru.TypeTag (...) + +scala> + +scala> // should be able to define this class with the imports above + +scala> class C[T](date: Date, rand: Random, typeTag: TypeTag[T]) +defined class C + +scala> :quit diff --git a/test/files/run/t9880-9881.scala b/test/files/run/t9880-9881.scala new file mode 100644 index 0000000000..0268c8c32c --- /dev/null +++ b/test/files/run/t9880-9881.scala @@ -0,0 +1,29 @@ +import scala.tools.partest.ReplTest +import scala.tools.nsc.Settings + +object Test extends ReplTest { + + override def transformSettings(s: Settings): Settings = { + s.Yreplclassbased.value = true + s + } + + lazy val normalizeRegex = """(import\s.*)\(.*\)""".r + + override def normalize(s: String): String = normalizeRegex.replaceFirstIn(s, "$1(...)") + + def code = + """ + |// import in various ways + |import java.util.Date + |import scala.util._ + |import scala.reflect.runtime.{universe => ru} + |import ru.TypeTag + | + |// show the imports + |:imports + | + |// should be able to define this class with the imports above + |class C[T](date: Date, rand: Random, typeTag: TypeTag[T]) + """.stripMargin +} diff --git a/test/files/run/trailing-commas.check b/test/files/run/trailing-commas.check new file mode 100644 index 0000000000..0dc4335ccd --- /dev/null +++ b/test/files/run/trailing-commas.check @@ -0,0 +1,9 @@ + +scala> // test varargs in patterns + +scala> val List(x, y, _*, +) = 42 :: 17 :: Nil +x: Int = 42 +y: Int = 17 + +scala> :quit diff --git a/test/files/run/trailing-commas.scala b/test/files/run/trailing-commas.scala new file mode 100644 index 0000000000..6a7f1bb55f --- /dev/null +++ b/test/files/run/trailing-commas.scala @@ -0,0 +1,7 @@ +object Test extends scala.tools.partest.ReplTest { + def code = """ +// test varargs in patterns +val List(x, y, _*, +) = 42 :: 17 :: Nil +""" +} diff --git a/test/files/run/unit-block-hash-hash.scala b/test/files/run/unit-block-hash-hash.scala new file mode 100644 index 0000000000..2708810a71 --- /dev/null +++ b/test/files/run/unit-block-hash-hash.scala @@ -0,0 +1,12 @@ +object Ex extends Exception +object Test { + def ex: Any = throw Ex + def main(args: Array[String]): Unit = { + try { + { ex; () }.## + sys.error("no exception was thrown") + } catch { + case `Ex` => + } + } +}
\ No newline at end of file |