summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/files/neg/javac-error.check10
-rw-r--r--test/files/neg/quasiquotes-syntax-error-position.check32
-rw-r--r--test/files/neg/quasiquotes-syntax-error-position.scala15
-rw-r--r--test/files/neg/t6289.check10
-rw-r--r--test/files/neg/t6289.flags (renamed from test/files/neg/javac-error.flags)0
-rw-r--r--test/files/neg/t6289/J.java (renamed from test/files/neg/javac-error/J.java)0
-rw-r--r--test/files/neg/t6289/SUT_5.scala (renamed from test/files/neg/javac-error/SUT_5.scala)0
-rw-r--r--test/files/neg/t7325.check10
-rw-r--r--test/files/neg/t7715.check13
-rw-r--r--test/files/neg/t7715.scala18
-rw-r--r--test/files/neg/t7757a.check4
-rw-r--r--test/files/neg/t7757a.scala1
-rw-r--r--test/files/neg/t7757b.check4
-rw-r--r--test/files/neg/t7757b.scala2
-rw-r--r--test/files/run/interpolation.flags1
-rw-r--r--test/files/run/interpolationArgs.check4
-rw-r--r--test/files/run/interpolationArgs.flags1
-rw-r--r--test/files/run/interpolationMultiline1.flags1
-rw-r--r--test/files/run/interpolationMultiline2.flags1
-rw-r--r--test/files/run/macro-expand-unapply-b.check2
-rw-r--r--test/files/run/macro-expand-unapply-b.flags1
-rw-r--r--test/files/run/macro-expand-unapply-b/Impls_Macros_1.scala37
-rw-r--r--test/files/run/macro-expand-unapply-b/Test_2.scala8
-rw-r--r--test/files/run/macro-toplevel-companion-a.flags1
-rw-r--r--test/files/run/macro-toplevel-companion-a/Impls_Macros_1.scala14
-rw-r--r--test/files/run/macro-toplevel-companion-a/Test_2.scala8
-rw-r--r--test/files/run/macro-toplevel-companion-b.check4
-rw-r--r--test/files/run/macro-toplevel-companion-b.flags1
-rw-r--r--test/files/run/macro-toplevel-companion-b/Impls_Macros_1.scala15
-rw-r--r--test/files/run/macro-toplevel-companion-b/Test_2.scala11
-rw-r--r--test/files/run/macro-toplevel-companion-c.check3
-rw-r--r--test/files/run/macro-toplevel-companion-c.flags1
-rw-r--r--test/files/run/macro-toplevel-companion-c.scala51
-rw-r--r--test/files/run/macro-toplevel.check2
-rw-r--r--test/files/run/macro-toplevel/Macros_1.scala15
-rw-r--r--test/files/run/macro-toplevel/Test_2.scala6
-rw-r--r--test/files/run/repl-javap-outdir-funs/run-repl_7.scala13
-rw-r--r--test/files/run/t5923a/Macros_1.scala42
-rw-r--r--test/files/run/t5923c.check1
-rw-r--r--test/files/run/t5923c/Macros_1.scala39
-rw-r--r--test/files/run/t5923c/Test_2.scala12
-rw-r--r--test/files/run/t5923d.check (renamed from test/files/run/macro-toplevel-companion-a.check)0
-rw-r--r--test/files/run/t5923d/Macros_1.scala9
-rw-r--r--test/files/run/t5923d/Test_2.scala7
-rw-r--r--test/files/run/t6507.check26
-rw-r--r--test/files/run/t6507.scala14
-rw-r--r--test/files/run/t7265.scala27
-rw-r--r--test/files/run/t7331a.check2
-rw-r--r--test/files/run/t7331a.scala10
-rw-r--r--test/files/run/t7331b.check3
-rw-r--r--test/files/run/t7331b.scala11
-rw-r--r--test/files/run/t7331c.check3
-rw-r--r--test/files/run/t7331c.scala11
-rw-r--r--test/files/run/t7715.check3
-rw-r--r--test/files/run/t7715.scala24
-rw-r--r--test/files/run/tailcalls.check36
-rw-r--r--test/files/scalacheck/quasiquotes/ErrorProps.scala6
-rw-r--r--test/files/scalap/abstractClass.check2
-rw-r--r--test/files/scalap/abstractMethod.check6
-rw-r--r--test/files/scalap/caseClass.check32
-rw-r--r--test/files/scalap/caseObject.check16
-rw-r--r--test/files/scalap/cbnParam.check2
-rw-r--r--test/files/scalap/classPrivate.check8
-rw-r--r--test/files/scalap/classWithExistential.check2
-rw-r--r--test/files/scalap/classWithSelfAnnotation.check4
-rw-r--r--test/files/scalap/covariantParam.check2
-rw-r--r--test/files/scalap/defaultParameter.check2
-rw-r--r--test/files/scalap/implicitParam.check2
-rw-r--r--test/files/scalap/packageObject.check2
-rw-r--r--test/files/scalap/paramClauses.check2
-rw-r--r--test/files/scalap/paramNames.check2
-rw-r--r--test/files/scalap/sequenceParam.check2
-rw-r--r--test/files/scalap/simpleClass.check2
-rw-r--r--test/files/scalap/traitObject.check6
-rw-r--r--test/files/scalap/typeAnnotations.check4
-rw-r--r--test/files/scalap/valAndVar.check4
-rw-r--r--test/files/scalap/wildcardType.check2
-rw-r--r--test/junit/scala/tools/nsc/symtab/CannotHaveAttrsTest.scala67
-rw-r--r--test/junit/scala/tools/nsc/symtab/SymbolTableTest.scala5
-rw-r--r--test/junit/scala/tools/testing/AssertThrowsTest.scala34
-rw-r--r--test/junit/scala/tools/testing/AssertUtil.scala19
-rw-r--r--test/junit/scala/util/matching/regextract-char.scala58
-rw-r--r--test/junit/scala/util/t7265.scala (renamed from test/pending/junit/scala/util/t7265.scala)13
-rwxr-xr-xtest/partest5
84 files changed, 596 insertions, 315 deletions
diff --git a/test/files/neg/javac-error.check b/test/files/neg/javac-error.check
deleted file mode 100644
index e7d1ccc1a1..0000000000
--- a/test/files/neg/javac-error.check
+++ /dev/null
@@ -1,10 +0,0 @@
-#partest java6
-javac-error/J.java:2: method does not override or implement a method from a supertype
- @Override public void foo() { }
- ^
-1 error
-#partest java7
-javac-error/J.java:2: error: method does not override or implement a method from a supertype
- @Override public void foo() { }
- ^
-1 error
diff --git a/test/files/neg/quasiquotes-syntax-error-position.check b/test/files/neg/quasiquotes-syntax-error-position.check
new file mode 100644
index 0000000000..3bd813b1bb
--- /dev/null
+++ b/test/files/neg/quasiquotes-syntax-error-position.check
@@ -0,0 +1,32 @@
+quasiquotes-syntax-error-position.scala:5: error: '=' expected but identifier found.
+ q"def $a f"
+ ^
+quasiquotes-syntax-error-position.scala:6: error: illegal start of simple expression
+ q"$a("
+ ^
+quasiquotes-syntax-error-position.scala:7: error: '}' expected but end of quote found.
+ q"class $t { def foo = $a"
+ ^
+quasiquotes-syntax-error-position.scala:8: error: '.' expected but splicee found.
+ q"import $t $t"
+ ^
+quasiquotes-syntax-error-position.scala:9: error: illegal start of definition
+ q"package p"
+ ^
+quasiquotes-syntax-error-position.scala:10: error: ';' expected but '@' found.
+ q"foo@$a"
+ ^
+quasiquotes-syntax-error-position.scala:11: error: case classes without a parameter list are not allowed;
+use either case objects or case classes with an explicit `()' as a parameter list.
+ q"case class A"
+ ^
+quasiquotes-syntax-error-position.scala:12: error: identifier expected but ']' found.
+ tq"$t => $t $t]"
+ ^
+quasiquotes-syntax-error-position.scala:13: error: end of quote expected but 'case' found.
+ cq"pattern => body ; case pattern2 =>"
+ ^
+quasiquotes-syntax-error-position.scala:14: error: ')' expected but end of quote found.
+ pq"$a(bar"
+ ^
+10 errors found
diff --git a/test/files/neg/quasiquotes-syntax-error-position.scala b/test/files/neg/quasiquotes-syntax-error-position.scala
new file mode 100644
index 0000000000..b97af52cfc
--- /dev/null
+++ b/test/files/neg/quasiquotes-syntax-error-position.scala
@@ -0,0 +1,15 @@
+import scala.reflect.runtime.universe._
+object test extends App {
+ val a = TermName("a")
+ val t = TypeName("t")
+ q"def $a f"
+ q"$a("
+ q"class $t { def foo = $a"
+ q"import $t $t"
+ q"package p"
+ q"foo@$a"
+ q"case class A"
+ tq"$t => $t $t]"
+ cq"pattern => body ; case pattern2 =>"
+ pq"$a(bar"
+} \ No newline at end of file
diff --git a/test/files/neg/t6289.check b/test/files/neg/t6289.check
new file mode 100644
index 0000000000..f6f43cabd3
--- /dev/null
+++ b/test/files/neg/t6289.check
@@ -0,0 +1,10 @@
+#partest java6
+t6289/J.java:2: method does not override or implement a method from a supertype
+ @Override public void foo() { }
+ ^
+1 error
+#partest java7
+t6289/J.java:2: error: method does not override or implement a method from a supertype
+ @Override public void foo() { }
+ ^
+1 error
diff --git a/test/files/neg/javac-error.flags b/test/files/neg/t6289.flags
index 85d8eb2ba2..85d8eb2ba2 100644
--- a/test/files/neg/javac-error.flags
+++ b/test/files/neg/t6289.flags
diff --git a/test/files/neg/javac-error/J.java b/test/files/neg/t6289/J.java
index 83f50c9ae2..83f50c9ae2 100644
--- a/test/files/neg/javac-error/J.java
+++ b/test/files/neg/t6289/J.java
diff --git a/test/files/neg/javac-error/SUT_5.scala b/test/files/neg/t6289/SUT_5.scala
index 0a996352c0..0a996352c0 100644
--- a/test/files/neg/javac-error/SUT_5.scala
+++ b/test/files/neg/t6289/SUT_5.scala
diff --git a/test/files/neg/t7325.check b/test/files/neg/t7325.check
index 709ab6db3e..d2c40f4df8 100644
--- a/test/files/neg/t7325.check
+++ b/test/files/neg/t7325.check
@@ -1,19 +1,19 @@
-t7325.scala:2: error: percent signs not directly following splicees must be escaped
+t7325.scala:2: error: conversions must follow a splice; use %% for literal %, %n for newline
println(f"%")
^
-t7325.scala:4: error: percent signs not directly following splicees must be escaped
+t7325.scala:4: error: conversions must follow a splice; use %% for literal %, %n for newline
println(f"%%%")
^
-t7325.scala:6: error: percent signs not directly following splicees must be escaped
+t7325.scala:6: error: conversions must follow a splice; use %% for literal %, %n for newline
println(f"%%%%%")
^
t7325.scala:16: error: wrong conversion string
println(f"${0}%")
^
-t7325.scala:19: error: percent signs not directly following splicees must be escaped
+t7325.scala:19: error: conversions must follow a splice; use %% for literal %, %n for newline
println(f"${0}%%%d")
^
-t7325.scala:21: error: percent signs not directly following splicees must be escaped
+t7325.scala:21: error: conversions must follow a splice; use %% for literal %, %n for newline
println(f"${0}%%%%%d")
^
6 errors found
diff --git a/test/files/neg/t7715.check b/test/files/neg/t7715.check
new file mode 100644
index 0000000000..4ee6b6c95d
--- /dev/null
+++ b/test/files/neg/t7715.check
@@ -0,0 +1,13 @@
+t7715.scala:8: error: error in interpolated string: identifier or block expected
+ days map s"On the $_th day of Christmas" foreach println
+ ^
+t7715.scala:10: error: error in interpolated string: identifier or block expected
+ val rf = (n: Int) => s"\\*{$_}"(n).r
+ ^
+t7715.scala:17: error: unbound placeholder parameter
+ days zip days map s"${_: Int} by ${_: Int}".tupled foreach println
+ ^
+t7715.scala:17: error: unbound placeholder parameter
+ days zip days map s"${_: Int} by ${_: Int}".tupled foreach println
+ ^
+four errors found
diff --git a/test/files/neg/t7715.scala b/test/files/neg/t7715.scala
new file mode 100644
index 0000000000..637ab8df6d
--- /dev/null
+++ b/test/files/neg/t7715.scala
@@ -0,0 +1,18 @@
+
+import PartialFunction.cond
+import util._
+
+object Test extends App {
+ val days = (1 to 12).toList
+
+ days map s"On the $_th day of Christmas" foreach println
+
+ val rf = (n: Int) => s"\\*{$_}"(n).r
+ def stars(n: Int)(s: String) = {
+ val r = rf(n)
+ cond(s) { case r(_*) => true }
+ }
+ Console println stars(5)("*****")
+
+ days zip days map s"${_: Int} by ${_: Int}".tupled foreach println
+}
diff --git a/test/files/neg/t7757a.check b/test/files/neg/t7757a.check
new file mode 100644
index 0000000000..de24e23004
--- /dev/null
+++ b/test/files/neg/t7757a.check
@@ -0,0 +1,4 @@
+t7757a.scala:1: error: ';' expected but '@' found.
+trait Foo @annot
+ ^
+one error found
diff --git a/test/files/neg/t7757a.scala b/test/files/neg/t7757a.scala
new file mode 100644
index 0000000000..24f6c16cb4
--- /dev/null
+++ b/test/files/neg/t7757a.scala
@@ -0,0 +1 @@
+trait Foo @annot \ No newline at end of file
diff --git a/test/files/neg/t7757b.check b/test/files/neg/t7757b.check
new file mode 100644
index 0000000000..3e5a0f1fa6
--- /dev/null
+++ b/test/files/neg/t7757b.check
@@ -0,0 +1,4 @@
+t7757b.scala:2: error: expected start of definition
+@annot2
+ ^
+one error found
diff --git a/test/files/neg/t7757b.scala b/test/files/neg/t7757b.scala
new file mode 100644
index 0000000000..e9a537dba1
--- /dev/null
+++ b/test/files/neg/t7757b.scala
@@ -0,0 +1,2 @@
+trait Foo2
+@annot2 \ No newline at end of file
diff --git a/test/files/run/interpolation.flags b/test/files/run/interpolation.flags
deleted file mode 100644
index 48fd867160..0000000000
--- a/test/files/run/interpolation.flags
+++ /dev/null
@@ -1 +0,0 @@
--Xexperimental
diff --git a/test/files/run/interpolationArgs.check b/test/files/run/interpolationArgs.check
index 155991e618..983214cbee 100644
--- a/test/files/run/interpolationArgs.check
+++ b/test/files/run/interpolationArgs.check
@@ -1,2 +1,2 @@
-java.lang.IllegalArgumentException: wrong number of arguments for interpolated string
-java.lang.IllegalArgumentException: wrong number of arguments for interpolated string
+java.lang.IllegalArgumentException: wrong number of arguments (1) for interpolated string with 3 parts
+java.lang.IllegalArgumentException: wrong number of arguments (1) for interpolated string with 1 parts
diff --git a/test/files/run/interpolationArgs.flags b/test/files/run/interpolationArgs.flags
deleted file mode 100644
index e1b37447c9..0000000000
--- a/test/files/run/interpolationArgs.flags
+++ /dev/null
@@ -1 +0,0 @@
--Xexperimental \ No newline at end of file
diff --git a/test/files/run/interpolationMultiline1.flags b/test/files/run/interpolationMultiline1.flags
deleted file mode 100644
index 48fd867160..0000000000
--- a/test/files/run/interpolationMultiline1.flags
+++ /dev/null
@@ -1 +0,0 @@
--Xexperimental
diff --git a/test/files/run/interpolationMultiline2.flags b/test/files/run/interpolationMultiline2.flags
deleted file mode 100644
index e1b37447c9..0000000000
--- a/test/files/run/interpolationMultiline2.flags
+++ /dev/null
@@ -1 +0,0 @@
--Xexperimental \ No newline at end of file
diff --git a/test/files/run/macro-expand-unapply-b.check b/test/files/run/macro-expand-unapply-b.check
deleted file mode 100644
index 5272f0d00a..0000000000
--- a/test/files/run/macro-expand-unapply-b.check
+++ /dev/null
@@ -1,2 +0,0 @@
-(1,List(2))
-List(1)
diff --git a/test/files/run/macro-expand-unapply-b.flags b/test/files/run/macro-expand-unapply-b.flags
deleted file mode 100644
index cd66464f2f..0000000000
--- a/test/files/run/macro-expand-unapply-b.flags
+++ /dev/null
@@ -1 +0,0 @@
--language:experimental.macros \ No newline at end of file
diff --git a/test/files/run/macro-expand-unapply-b/Impls_Macros_1.scala b/test/files/run/macro-expand-unapply-b/Impls_Macros_1.scala
deleted file mode 100644
index d0300bdf7e..0000000000
--- a/test/files/run/macro-expand-unapply-b/Impls_Macros_1.scala
+++ /dev/null
@@ -1,37 +0,0 @@
-import language.experimental.macros
-import scala.reflect.macros.Context
-
-object Macros {
- implicit class ContextExtensions(c: StringContext) {
- object q {
- def unapply(x: Any): Option[Any] = macro impl
- }
- }
-
- def impl(c: Context)(x: c.Expr[Any]): c.Expr[Option[Any]] = {
- import c.universe._
- import Flag._
-
- // parts here will be string literals - static parts of the string interpolation
- // e.g. for q"$x, $y" parts will be Literal(Constant("")), Literal(Constant(", ")) and Literal(Constant(""))
- val Apply(Select(Select(Apply(_, List(Apply(_, parts))), _), _), _) = c.macroApplication
- val nresults = parts.length - 1
-
- def results() =
- ((1 to (nresults - 1)).toList map (i => Literal(Constant(i)))) :+ // (n - 1) results of type Int
- Apply(Ident(TermName("List")), List(Literal(Constant(nresults)))) // and also one result of a different type
- def extractorBody() =
- if (nresults == 0) Literal(Constant(true))
- else if (nresults == 1) Apply(Ident(TermName("Some")), results())
- else Apply(Ident(TermName("Some")), List(Apply(Ident(TermName("Tuple" + nresults)), results())))
-
- val name = TermName(java.util.UUID.randomUUID().toString.replace("-", ""))
- val mdef = ModuleDef(NoMods, name, Template(List(Select(Ident(TermName("scala")), TypeName("AnyRef"))), emptyValDef, List(
- DefDef(Modifiers(), nme.CONSTRUCTOR, List(), List(List()), TypeTree(),
- Block(List(pendingSuperCall), Literal(Constant(())))),
- DefDef(Modifiers(), TermName("unapply"), List(), List(List(ValDef(Modifiers(PARAM), TermName("x"), Ident(TypeName("Any")), EmptyTree))), TypeTree(),
- extractorBody()))))
- c.introduceTopLevel(nme.EMPTY_PACKAGE_NAME.toString, mdef)
- c.Expr[Option[Any]](Apply(Select(Ident(name), TermName("unapply")), List(x.tree)))
- }
-} \ No newline at end of file
diff --git a/test/files/run/macro-expand-unapply-b/Test_2.scala b/test/files/run/macro-expand-unapply-b/Test_2.scala
deleted file mode 100644
index 5352160dfe..0000000000
--- a/test/files/run/macro-expand-unapply-b/Test_2.scala
+++ /dev/null
@@ -1,8 +0,0 @@
-object Test extends App {
- import Macros._
- def whatever() = null
- val q"$x1, $y1" = whatever()
- println(x1, y1)
- val q"$x2" = whatever()
- println(x2)
-}
diff --git a/test/files/run/macro-toplevel-companion-a.flags b/test/files/run/macro-toplevel-companion-a.flags
deleted file mode 100644
index cd66464f2f..0000000000
--- a/test/files/run/macro-toplevel-companion-a.flags
+++ /dev/null
@@ -1 +0,0 @@
--language:experimental.macros \ No newline at end of file
diff --git a/test/files/run/macro-toplevel-companion-a/Impls_Macros_1.scala b/test/files/run/macro-toplevel-companion-a/Impls_Macros_1.scala
deleted file mode 100644
index 23e8694ddc..0000000000
--- a/test/files/run/macro-toplevel-companion-a/Impls_Macros_1.scala
+++ /dev/null
@@ -1,14 +0,0 @@
-import scala.reflect.macros.Context
-import language.experimental.macros
-
-object Macros {
- def impl(c: Context) = {
- import c.universe._
- val synthetic = reify{ class C { override def toString = "C" }; object C { implicit val c = new C } }.tree
- val defs = synthetic.asInstanceOf[Block].stats.asInstanceOf[List[ImplDef]]
- if (c.topLevelRef(TypeName("C")).isEmpty) c.introduceTopLevel(nme.EMPTY_PACKAGE_NAME.toString, defs: _*)
- c.literalUnit
- }
-
- def foo = macro impl
-} \ No newline at end of file
diff --git a/test/files/run/macro-toplevel-companion-a/Test_2.scala b/test/files/run/macro-toplevel-companion-a/Test_2.scala
deleted file mode 100644
index 78b65b5b1f..0000000000
--- a/test/files/run/macro-toplevel-companion-a/Test_2.scala
+++ /dev/null
@@ -1,8 +0,0 @@
-import Macros._
-
-object Test extends App {
- foo;
- implicitly[C];
- foo;
- implicitly[C];
-} \ No newline at end of file
diff --git a/test/files/run/macro-toplevel-companion-b.check b/test/files/run/macro-toplevel-companion-b.check
deleted file mode 100644
index bd30dc75d3..0000000000
--- a/test/files/run/macro-toplevel-companion-b.check
+++ /dev/null
@@ -1,4 +0,0 @@
-reflective compilation has failed:
-
-Companions 'class C' and 'object C' must be defined in same file:
- Found in <synthetic file name> and <synthetic file name>
diff --git a/test/files/run/macro-toplevel-companion-b.flags b/test/files/run/macro-toplevel-companion-b.flags
deleted file mode 100644
index cd66464f2f..0000000000
--- a/test/files/run/macro-toplevel-companion-b.flags
+++ /dev/null
@@ -1 +0,0 @@
--language:experimental.macros \ No newline at end of file
diff --git a/test/files/run/macro-toplevel-companion-b/Impls_Macros_1.scala b/test/files/run/macro-toplevel-companion-b/Impls_Macros_1.scala
deleted file mode 100644
index f30adc2965..0000000000
--- a/test/files/run/macro-toplevel-companion-b/Impls_Macros_1.scala
+++ /dev/null
@@ -1,15 +0,0 @@
-import scala.reflect.macros.Context
-import language.experimental.macros
-
-object Macros {
- def impl(c: Context) = {
- import c.universe._
- val Block(List(cdef: ClassDef), _) = reify{ class C }.tree
- val classRef = c.topLevelRef(TypeName("C")) orElse c.introduceTopLevel(nme.EMPTY_PACKAGE_NAME.toString, cdef)
- val Block(List(mdef: ModuleDef), _) = reify{ object C }.tree
- val moduleRef = c.topLevelRef(TermName("C")) orElse c.introduceTopLevel(nme.EMPTY_PACKAGE_NAME.toString, mdef)
- c.literalUnit
- }
-
- def foo = macro impl
-} \ No newline at end of file
diff --git a/test/files/run/macro-toplevel-companion-b/Test_2.scala b/test/files/run/macro-toplevel-companion-b/Test_2.scala
deleted file mode 100644
index 4e766bde89..0000000000
--- a/test/files/run/macro-toplevel-companion-b/Test_2.scala
+++ /dev/null
@@ -1,11 +0,0 @@
-import scala.reflect.runtime.universe._
-import scala.reflect.runtime.{universe => ru}
-import scala.reflect.runtime.{currentMirror => cm}
-import scala.tools.reflect.{ToolBox, ToolBoxError}
-import Macros._
-
-object Test extends App {
- val tb = cm.mkToolBox()
- try tb.compile(Select(Ident(TermName("Macros")), TermName("foo")))
- catch { case ToolBoxError(message, _) => println("""(Found in|and) .*?compileLateSynthetic-.*?\.scala""".r.replaceAllIn(message, m => m.group(1) + " <synthetic file name>")) }
-} \ No newline at end of file
diff --git a/test/files/run/macro-toplevel-companion-c.check b/test/files/run/macro-toplevel-companion-c.check
deleted file mode 100644
index 4052c472f8..0000000000
--- a/test/files/run/macro-toplevel-companion-c.check
+++ /dev/null
@@ -1,3 +0,0 @@
-error: Companions 'class C' and 'object C' must be defined in same file:
- Found in <synthetic file name> and newSource1.scala
-
diff --git a/test/files/run/macro-toplevel-companion-c.flags b/test/files/run/macro-toplevel-companion-c.flags
deleted file mode 100644
index cd66464f2f..0000000000
--- a/test/files/run/macro-toplevel-companion-c.flags
+++ /dev/null
@@ -1 +0,0 @@
--language:experimental.macros \ No newline at end of file
diff --git a/test/files/run/macro-toplevel-companion-c.scala b/test/files/run/macro-toplevel-companion-c.scala
deleted file mode 100644
index c315f8b942..0000000000
--- a/test/files/run/macro-toplevel-companion-c.scala
+++ /dev/null
@@ -1,51 +0,0 @@
-import scala.tools.partest._
-import java.io._
-
-object Test extends DirectTest {
- def code = ???
-
- def macros_1 = """
- package test
-
- import scala.reflect.macros.Context
- import language.experimental.macros
-
- object Macros {
- def impl(c: Context) = {
- import c.universe._
- val Block(List(cdef: ClassDef), _) = reify{ class C }.tree
- val ref = c.topLevelRef(TypeName("test.C")) orElse c.introduceTopLevel("test", cdef)
- c.literalUnit
- }
-
- def foo = macro impl
- }
- """
- def compileMacros() = {
- val classpath = List(sys.props("partest.lib"), sys.props("partest.reflect")) mkString sys.props("path.separator")
- compileString(newCompiler("-language:experimental.macros", "-cp", classpath, "-d", testOutput.path))(macros_1)
- }
-
- def test_2 = """
- package test
- object C { Macros.foo }
- """
- def compileTest() = {
- val classpath = List(sys.props("partest.lib"), testOutput.path) mkString sys.props("path.separator")
- compileString(newCompiler("-cp", classpath, "-d", testOutput.path))(test_2)
- }
-
- def show(): Unit = {
- // redirect err to string, for logging
- val prevErr = System.err
- val baos = new ByteArrayOutputStream()
- System.setErr(new PrintStream(baos))
- log("Compiling Macros_1...")
- if (compileMacros()) {
- log("Compiling Test_2...")
- if (compileTest()) log("Success!") else log("Failed...")
- }
- println("""(Found in|and) .*?compileLateSynthetic-.*?\.scala""".r.replaceAllIn(baos.toString, m => m.group(1) + " <synthetic file name>"))
- System.setErr(prevErr)
- }
-} \ No newline at end of file
diff --git a/test/files/run/macro-toplevel.check b/test/files/run/macro-toplevel.check
deleted file mode 100644
index 257c3764fd..0000000000
--- a/test/files/run/macro-toplevel.check
+++ /dev/null
@@ -1,2 +0,0 @@
-I've been created from Macros.foo
-I've been created from Macros.foo
diff --git a/test/files/run/macro-toplevel/Macros_1.scala b/test/files/run/macro-toplevel/Macros_1.scala
deleted file mode 100644
index f681c86735..0000000000
--- a/test/files/run/macro-toplevel/Macros_1.scala
+++ /dev/null
@@ -1,15 +0,0 @@
-import scala.reflect.macros.Context
-import language.experimental.macros
-
-object Macros {
- def impl(c: Context) = {
- import c.universe._
- val msg = "I've been created from " + c.macroApplication
- val Block(List(synthetic: ClassDef), _) = reify{ class SomeUniqueName { def hello = c.literal(msg).splice } }.tree
- val ref = c.topLevelRef(synthetic.name) orElse c.introduceTopLevel(nme.EMPTY_PACKAGE_NAME.toString, synthetic)
- c.Expr[String](Select(Apply(Select(New(ref), nme.CONSTRUCTOR), List()), TermName("hello")))
- }
-
- def foo = macro impl
- def foo2 = macro impl
-}
diff --git a/test/files/run/macro-toplevel/Test_2.scala b/test/files/run/macro-toplevel/Test_2.scala
deleted file mode 100644
index eee2d6ae13..0000000000
--- a/test/files/run/macro-toplevel/Test_2.scala
+++ /dev/null
@@ -1,6 +0,0 @@
-import Macros._
-
-object Test extends App {
- println(Macros.foo)
- println(Macros.foo2)
-} \ No newline at end of file
diff --git a/test/files/run/repl-javap-outdir-funs/run-repl_7.scala b/test/files/run/repl-javap-outdir-funs/run-repl_7.scala
index dfe3dae270..6c6fe2d515 100644
--- a/test/files/run/repl-javap-outdir-funs/run-repl_7.scala
+++ b/test/files/run/repl-javap-outdir-funs/run-repl_7.scala
@@ -5,8 +5,13 @@ object Test extends JavapTest {
|:javap -fun disktest/Foo.class
""".stripMargin
- override def yah(res: Seq[String]) = {
- def filtered = res filter (_ contains "public final class disktest.Foo")
- 1 == filtered.size
- }
+ override def yah(res: Seq[String]) =
+ // It's currently unknown why this test fails on Avian with
+ // “Failed: No anonfuns found.”, skip it for now. See SI-7630.
+ if (scala.tools.partest.utils.Properties.isAvian)
+ true
+ else {
+ def filtered = res filter (_ contains "public final class disktest.Foo")
+ 1 == filtered.size
+ }
}
diff --git a/test/files/run/t5923a/Macros_1.scala b/test/files/run/t5923a/Macros_1.scala
index 6d21362c4d..97076eb102 100644
--- a/test/files/run/t5923a/Macros_1.scala
+++ b/test/files/run/t5923a/Macros_1.scala
@@ -7,8 +7,46 @@ object C {
}
object Macros {
- def impl[T: c.WeakTypeTag](c: Context) = {
+ def impl[T](c: Context)(ttag: c.WeakTypeTag[T]) = {
import c.universe._
- reify(C[T](c.literal(weakTypeOf[T].toString).splice))
+ val ttag0 = ttag;
+ {
+ // When we're expanding implicitly[C[Nothing]], the type inferencer will see
+ // that foo[T] returns C[T] and that we request an implicit of type C[Nothing].
+ //
+ // Then the type inferencer will try to match C[T] against C[Nothing] and infer everything it can infer
+ // from that match, but not more (e.g. if we were returning Iso[T, U] and the type we were looking at was Iso[Foo, L],
+ // we wouldn't want U to be auto-inferred to Nothing, as it usually happens with normal methods,
+ // but would rather want it to remain unknown, so that our macro could take a stab at inferring it:
+ // see the comments in this commit for more information).
+ //
+ // Equipped with common sense, in our case of C[T] and C[Nothing] we would expect T to be inferred as Nothing, and then we
+ // would expect T in the corresponding macro invocation to be Nothing. Unfortunately it is not that simple.
+ //
+ // Internally the type inferencer uses Nothing as a dummy value, which stands for "don't know how to
+ // infer this type parameter". In the Iso example, matching Iso[T, U] against Iso[Foo, L] would result in
+ // T being inferred as Foo and U being inferred as Nothing (!!). Then the type inferencer will think:
+ // "Aha! U ended up being Nothing. This means that I failed to infer it,
+ // therefore the result of my work is: T -> Foo, U -> still unknown".
+ //
+ // That's all very good and works very well until Nothing is a genuine result of type inference,
+ // as in our original example of inferring T in C[T] from C[Nothing]. In that case, the inferencer becomes confused
+ // and here in the macro implementation we get weakTypeOf[T] equal to some dummy type carrying a type parameter
+ // instead of Nothing.
+ //
+ // This eccentric behavior of the type inferencer is a long-standing problem in scalac,
+ // so the best one can do for now until it's fixed is to work around, manually converting
+ // suspicious T's into Nothings. Of course, this means that we would have to approximate,
+ // because there's no way to know whether having T here stands for a failed attempt to infer Nothing
+ // or for a failed attempt to infer anything, but at least we're in full control of making the best
+ // of this sad situation.
+ implicit def ttag: WeakTypeTag[T] = {
+ val tpe = ttag0.tpe
+ val sym = tpe.typeSymbol.asType
+ if (sym.isParameter && !sym.isSkolem) TypeTag.Nothing.asInstanceOf[TypeTag[T]]
+ else ttag0
+ }
+ reify(C[T](c.literal(weakTypeOf[T].toString).splice))
+ }
}
} \ No newline at end of file
diff --git a/test/files/run/t5923c.check b/test/files/run/t5923c.check
new file mode 100644
index 0000000000..bed7429108
--- /dev/null
+++ b/test/files/run/t5923c.check
@@ -0,0 +1 @@
+(23,foo,true)
diff --git a/test/files/run/t5923c/Macros_1.scala b/test/files/run/t5923c/Macros_1.scala
new file mode 100644
index 0000000000..0b7a3399e2
--- /dev/null
+++ b/test/files/run/t5923c/Macros_1.scala
@@ -0,0 +1,39 @@
+import language.experimental.macros
+import scala.reflect.macros.Context
+
+trait Iso[T, U] {
+ def to(t : T) : U
+ // def from(u : U) : T
+}
+
+object Iso {
+ implicit def materializeIso[T, U]: Iso[T, U] = macro impl[T, U]
+ def impl[T: c.WeakTypeTag, U: c.WeakTypeTag](c: Context): c.Expr[Iso[T, U]] = {
+ import c.universe._
+ import definitions._
+ import Flag._
+
+ val sym = c.weakTypeOf[T].typeSymbol
+ if (!sym.isClass || !sym.asClass.isCaseClass) c.abort(c.enclosingPosition, s"$sym is not a case class")
+ val fields = sym.typeSignature.declarations.toList.collect{ case x: TermSymbol if x.isVal && x.isCaseAccessor => x }
+
+ def mkTpt() = {
+ val core = Ident(TupleClass(fields.length) orElse UnitClass)
+ if (fields.length == 0) core
+ else AppliedTypeTree(core, fields map (f => TypeTree(f.typeSignature)))
+ }
+
+ def mkFrom() = {
+ if (fields.length == 0) Literal(Constant(Unit))
+ else Apply(Ident(newTermName("Tuple" + fields.length)), fields map (f => Select(Ident(newTermName("f")), newTermName(f.name.toString.trim))))
+ }
+
+ val evidenceClass = ClassDef(Modifiers(FINAL), newTypeName("$anon"), List(), Template(
+ List(AppliedTypeTree(Ident(newTypeName("Iso")), List(Ident(sym), mkTpt()))),
+ emptyValDef,
+ List(
+ DefDef(Modifiers(), nme.CONSTRUCTOR, List(), List(List()), TypeTree(), Block(List(Apply(Select(Super(This(tpnme.EMPTY), tpnme.EMPTY), nme.CONSTRUCTOR), List())), Literal(Constant(())))),
+ DefDef(Modifiers(), newTermName("to"), List(), List(List(ValDef(Modifiers(PARAM), newTermName("f"), Ident(sym), EmptyTree))), TypeTree(), mkFrom()))))
+ c.Expr[Iso[T, U]](Block(List(evidenceClass), Apply(Select(New(Ident(newTypeName("$anon"))), nme.CONSTRUCTOR), List())))
+ }
+}
diff --git a/test/files/run/t5923c/Test_2.scala b/test/files/run/t5923c/Test_2.scala
new file mode 100644
index 0000000000..a00f4ed7db
--- /dev/null
+++ b/test/files/run/t5923c/Test_2.scala
@@ -0,0 +1,12 @@
+// see the comments for macroExpandApply.onDelayed for an explanation of what's tested here
+object Test extends App {
+ case class Foo(i: Int, s: String, b: Boolean)
+ def foo[C, L](c: C)(implicit iso: Iso[C, L]): L = iso.to(c)
+
+ {
+ val equiv = foo(Foo(23, "foo", true))
+ def typed[T](t: => T) {}
+ typed[(Int, String, Boolean)](equiv)
+ println(equiv)
+ }
+} \ No newline at end of file
diff --git a/test/files/run/macro-toplevel-companion-a.check b/test/files/run/t5923d.check
index e69de29bb2..e69de29bb2 100644
--- a/test/files/run/macro-toplevel-companion-a.check
+++ b/test/files/run/t5923d.check
diff --git a/test/files/run/t5923d/Macros_1.scala b/test/files/run/t5923d/Macros_1.scala
new file mode 100644
index 0000000000..f32d1af704
--- /dev/null
+++ b/test/files/run/t5923d/Macros_1.scala
@@ -0,0 +1,9 @@
+import scala.language.experimental.macros
+import scala.reflect.macros.Context
+
+trait MappedRow
+trait RowMapper[T <: MappedRow]
+object RowMapper {
+ implicit def mapper[T <: MappedRow]: RowMapper[T] = macro impl[T]
+ def impl[T <: MappedRow : c.WeakTypeTag](c: Context) = c.universe.reify(new RowMapper[T]{})
+} \ No newline at end of file
diff --git a/test/files/run/t5923d/Test_2.scala b/test/files/run/t5923d/Test_2.scala
new file mode 100644
index 0000000000..6be10227c2
--- /dev/null
+++ b/test/files/run/t5923d/Test_2.scala
@@ -0,0 +1,7 @@
+class RowA extends MappedRow
+class RowB extends MappedRow
+
+object Test extends App {
+ implicitly[RowMapper[RowA]]
+ implicitly[RowMapper[RowB]]
+} \ No newline at end of file
diff --git a/test/files/run/t6507.check b/test/files/run/t6507.check
new file mode 100644
index 0000000000..336db0aeaf
--- /dev/null
+++ b/test/files/run/t6507.check
@@ -0,0 +1,26 @@
+Type in expressions to have them evaluated.
+Type :help for more information.
+
+scala>
+
+scala> :silent
+Switched off result printing.
+
+scala> class A { override def toString() = { println("!"); "A" } }
+
+scala> val a = new A
+
+scala> var b: A = new A
+
+scala> b = new A
+
+scala> new A
+
+scala> :silent
+Switched on result printing.
+
+scala> res0
+!
+res1: A = A
+
+scala>
diff --git a/test/files/run/t6507.scala b/test/files/run/t6507.scala
new file mode 100644
index 0000000000..25f0a73e04
--- /dev/null
+++ b/test/files/run/t6507.scala
@@ -0,0 +1,14 @@
+import scala.tools.partest.ReplTest
+
+object Test extends ReplTest {
+ def code = """
+:silent
+class A { override def toString() = { println("!"); "A" } }
+val a = new A
+var b: A = new A
+b = new A
+new A
+:silent
+res0
+"""
+}
diff --git a/test/files/run/t7265.scala b/test/files/run/t7265.scala
deleted file mode 100644
index c556930303..0000000000
--- a/test/files/run/t7265.scala
+++ /dev/null
@@ -1,27 +0,0 @@
-
-import scala.util.Properties._
-
-object Test extends App {
-
- setProp("java.specification.version", "1.7")
-
- assert( isJavaAtLeast("1.5"))
- assert( isJavaAtLeast("1.6"))
- assert( isJavaAtLeast("1.7"))
- assert(!isJavaAtLeast("1.8"))
- assert(!isJavaAtLeast("1.71"))
-
- failing(isJavaAtLeast("1.a"))
- failing(isJavaAtLeast("1"))
- failing(isJavaAtLeast(""))
- failing(isJavaAtLeast("."))
- failing(isJavaAtLeast(".5"))
- failing(isJavaAtLeast("1.7.1"))
-
- def failing(u: =>Unit) = try {
- u
- assert(false, "Expected Exception")
- } catch {
- case _: NumberFormatException =>
- }
-}
diff --git a/test/files/run/t7331a.check b/test/files/run/t7331a.check
new file mode 100644
index 0000000000..a59b400344
--- /dev/null
+++ b/test/files/run/t7331a.check
@@ -0,0 +1,2 @@
+source-<toolbox>,line-1,offset=0
+2 \ No newline at end of file
diff --git a/test/files/run/t7331a.scala b/test/files/run/t7331a.scala
new file mode 100644
index 0000000000..1851945e63
--- /dev/null
+++ b/test/files/run/t7331a.scala
@@ -0,0 +1,10 @@
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
+
+object Test extends App {
+ val tb = cm.mkToolBox()
+ val tree = tb.parse("x")
+ println(tree.pos)
+ println(tree.pos.source.content.length)
+} \ No newline at end of file
diff --git a/test/files/run/t7331b.check b/test/files/run/t7331b.check
new file mode 100644
index 0000000000..7034a95a3f
--- /dev/null
+++ b/test/files/run/t7331b.check
@@ -0,0 +1,3 @@
+reflective compilation has failed:
+
+')' expected but eof found.
diff --git a/test/files/run/t7331b.scala b/test/files/run/t7331b.scala
new file mode 100644
index 0000000000..052656d11b
--- /dev/null
+++ b/test/files/run/t7331b.scala
@@ -0,0 +1,11 @@
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.{ToolBox, ToolBoxError}
+
+object Test extends App {
+ val tb = cm.mkToolBox()
+ try tb.parse("f(x")
+ catch {
+ case ToolBoxError(msg, _) => println(msg)
+ }
+} \ No newline at end of file
diff --git a/test/files/run/t7331c.check b/test/files/run/t7331c.check
new file mode 100644
index 0000000000..fd3ac1d9ef
--- /dev/null
+++ b/test/files/run/t7331c.check
@@ -0,0 +1,3 @@
+ClassDef(Modifiers(), TypeName("C"), List(), Template(List(Select(Ident(scala), TypeName("AnyRef"))), emptyValDef, List(DefDef(Modifiers(), nme.CONSTRUCTOR, List(), List(List()), TypeTree(), Block(List(pendingSuperCall), Literal(Constant(())))))))
+source-<toolbox>,line-1,offset=6
+NoPosition
diff --git a/test/files/run/t7331c.scala b/test/files/run/t7331c.scala
new file mode 100644
index 0000000000..75873afcd0
--- /dev/null
+++ b/test/files/run/t7331c.scala
@@ -0,0 +1,11 @@
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{currentMirror => cm}
+import scala.tools.reflect.ToolBox
+
+object Test extends App {
+ val tb = cm.mkToolBox()
+ val tree = tb.parse("class C").asInstanceOf[ClassDef]
+ println(showRaw(tree))
+ println(tree.pos)
+ println(tree.impl.self.pos)
+} \ No newline at end of file
diff --git a/test/files/run/t7715.check b/test/files/run/t7715.check
new file mode 100644
index 0000000000..592d7fe2ea
--- /dev/null
+++ b/test/files/run/t7715.check
@@ -0,0 +1,3 @@
+6
+4
+4
diff --git a/test/files/run/t7715.scala b/test/files/run/t7715.scala
new file mode 100644
index 0000000000..0ad3913016
--- /dev/null
+++ b/test/files/run/t7715.scala
@@ -0,0 +1,24 @@
+
+import PartialFunction.cond
+import util._
+
+object Test extends App {
+
+ object I { def unapply(x: String): Option[Int] = Try(x.toInt).toOption }
+ implicit class RX(val sc: StringContext) {
+ def rx = sc.parts.mkString("(.+)").r
+ }
+
+ Console println ("2 by 4" match {
+ case rx"${I(a)} by ${I(b)}" => a+b
+ case _ => -1
+ })
+ Console println ("2 by 4" match {
+ case rx"${_} by ${I(b)}" => b // pattern placeholder
+ case _ => -1
+ })
+ Console println ("2 by 4" match {
+ case rx"$_ by ${I(b)}" => b // is permitted this way, too
+ case _ => -1
+ })
+}
diff --git a/test/files/run/tailcalls.check b/test/files/run/tailcalls.check
index ab54d528ab..7607921856 100644
--- a/test/files/run/tailcalls.check
+++ b/test/files/run/tailcalls.check
@@ -53,27 +53,27 @@ test FancyTailCalls.tcTryLocal was successful
test FancyTailCalls.differentInstance was successful
test PolyObject.tramp was successful
#partest avian
-test Object .f was successful
-test Final .f was successful
-test Class .f was successful
+test Object .f was successful
+test Final .f was successful
+test Class .f was successful
test SubClass .f was successful
-test Sealed .f was successful
+test Sealed .f was successful
test SubSealed.f was successful
-test O .f was successful
-test c .f was successful
-test O.O .f was successful
-test O.c .f was successful
-test c.O .f was successful
-test c.c .f was successful
-test O.O.O .f was successful
-test O.O.c .f was successful
-test O.c.O .f was successful
-test O.c.c .f was successful
-test c.O.O .f was successful
-test c.O.c .f was successful
-test c.c.O .f was successful
-test c.c.c .f was successful
+test O .f was successful
+test c .f was successful
+test O.O .f was successful
+test O.c .f was successful
+test c.O .f was successful
+test c.c .f was successful
+test O.O.O .f was successful
+test O.O.c .f was successful
+test O.c.O .f was successful
+test O.c.c .f was successful
+test c.O.O .f was successful
+test c.O.c .f was successful
+test c.c.O .f was successful
+test c.c.c .f was successful
test O.O.O.O.f was successful
test O.O.O.c.f was successful
test O.O.c.O.f was successful
diff --git a/test/files/scalacheck/quasiquotes/ErrorProps.scala b/test/files/scalacheck/quasiquotes/ErrorProps.scala
index 044a332a04..b9e69e0e88 100644
--- a/test/files/scalacheck/quasiquotes/ErrorProps.scala
+++ b/test/files/scalacheck/quasiquotes/ErrorProps.scala
@@ -188,12 +188,6 @@ object ErrorProps extends QuasiquoteProperties("errors") {
val q"$m1 $m2 def foo" = EmptyTree
""")
- property("can't parse more than one casedef") = fails(
- "Can't parse more than one casedef, consider generating a match tree instead",
- """
- cq"1 => 2 case 3 => 5"
- """)
-
// // Make sure a nice error is reported in this case
// { import Flag._; val mods = NoMods; q"lazy $mods val x: Int" }
} \ No newline at end of file
diff --git a/test/files/scalap/abstractClass.check b/test/files/scalap/abstractClass.check
index ef1daac23d..95e80ac3c9 100644
--- a/test/files/scalap/abstractClass.check
+++ b/test/files/scalap/abstractClass.check
@@ -1,4 +1,4 @@
abstract class AbstractClass extends scala.AnyRef {
def this() = { /* compiled code */ }
- def foo : scala.Predef.String
+ def foo: scala.Predef.String
}
diff --git a/test/files/scalap/abstractMethod.check b/test/files/scalap/abstractMethod.check
index 40fa02d408..0d0b1b7421 100644
--- a/test/files/scalap/abstractMethod.check
+++ b/test/files/scalap/abstractMethod.check
@@ -1,5 +1,5 @@
trait AbstractMethod extends scala.AnyRef {
- def $init$() : scala.Unit = { /* compiled code */ }
- def arity : scala.Int
- def isCool : scala.Boolean = { /* compiled code */ }
+ def $init$(): scala.Unit = { /* compiled code */ }
+ def arity: scala.Int
+ def isCool: scala.Boolean = { /* compiled code */ }
}
diff --git a/test/files/scalap/caseClass.check b/test/files/scalap/caseClass.check
index 7d7aa4fd8f..51ad90d9b2 100644
--- a/test/files/scalap/caseClass.check
+++ b/test/files/scalap/caseClass.check
@@ -1,20 +1,20 @@
-case class CaseClass[A <: scala.Seq[scala.Int]](i : A, s : scala.Predef.String) extends scala.AnyRef with scala.Product with scala.Serializable {
- val i : A = { /* compiled code */ }
- val s : scala.Predef.String = { /* compiled code */ }
- def foo : scala.Int = { /* compiled code */ }
- def copy[A <: scala.Seq[scala.Int]](i : A, s : scala.Predef.String) : CaseClass[A] = { /* compiled code */ }
- override def productPrefix : java.lang.String = { /* compiled code */ }
- def productArity : scala.Int = { /* compiled code */ }
- def productElement(x$1 : scala.Int) : scala.Any = { /* compiled code */ }
- override def productIterator : scala.collection.Iterator[scala.Any] = { /* compiled code */ }
- def canEqual(x$1 : scala.Any) : scala.Boolean = { /* compiled code */ }
- override def hashCode() : scala.Int = { /* compiled code */ }
- override def toString() : java.lang.String = { /* compiled code */ }
- override def equals(x$1 : scala.Any) : scala.Boolean = { /* compiled code */ }
+case class CaseClass[A <: scala.Seq[scala.Int]](i: A, s: scala.Predef.String) extends scala.AnyRef with scala.Product with scala.Serializable {
+ val i: A = { /* compiled code */ }
+ val s: scala.Predef.String = { /* compiled code */ }
+ def foo: scala.Int = { /* compiled code */ }
+ def copy[A <: scala.Seq[scala.Int]](i: A, s: scala.Predef.String): CaseClass[A] = { /* compiled code */ }
+ override def productPrefix: java.lang.String = { /* compiled code */ }
+ def productArity: scala.Int = { /* compiled code */ }
+ def productElement(x$1: scala.Int): scala.Any = { /* compiled code */ }
+ override def productIterator: scala.collection.Iterator[scala.Any] = { /* compiled code */ }
+ def canEqual(x$1: scala.Any): scala.Boolean = { /* compiled code */ }
+ override def hashCode(): scala.Int = { /* compiled code */ }
+ override def toString(): java.lang.String = { /* compiled code */ }
+ override def equals(x$1: scala.Any): scala.Boolean = { /* compiled code */ }
}
object CaseClass extends scala.AnyRef with scala.Serializable {
def this() = { /* compiled code */ }
- final override def toString() : java.lang.String = { /* compiled code */ }
- def apply[A <: scala.Seq[scala.Int]](i : A, s : scala.Predef.String) : CaseClass[A] = { /* compiled code */ }
- def unapply[A <: scala.Seq[scala.Int]](x$0 : CaseClass[A]) : scala.Option[scala.Tuple2[A, scala.Predef.String]] = { /* compiled code */ }
+ final override def toString(): java.lang.String = { /* compiled code */ }
+ def apply[A <: scala.Seq[scala.Int]](i: A, s: scala.Predef.String): CaseClass[A] = { /* compiled code */ }
+ def unapply[A <: scala.Seq[scala.Int]](x$0: CaseClass[A]): scala.Option[scala.Tuple2[A, scala.Predef.String]] = { /* compiled code */ }
}
diff --git a/test/files/scalap/caseObject.check b/test/files/scalap/caseObject.check
index 867a4b2162..a342e5ff1a 100644
--- a/test/files/scalap/caseObject.check
+++ b/test/files/scalap/caseObject.check
@@ -1,10 +1,10 @@
case object CaseObject extends scala.AnyRef with scala.Product with scala.Serializable {
- def bar : scala.Int = { /* compiled code */ }
- override def productPrefix : java.lang.String = { /* compiled code */ }
- def productArity : scala.Int = { /* compiled code */ }
- def productElement(x$1 : scala.Int) : scala.Any = { /* compiled code */ }
- override def productIterator : scala.collection.Iterator[scala.Any] = { /* compiled code */ }
- def canEqual(x$1 : scala.Any) : scala.Boolean = { /* compiled code */ }
- override def hashCode() : scala.Int = { /* compiled code */ }
- override def toString() : java.lang.String = { /* compiled code */ }
+ def bar: scala.Int = { /* compiled code */ }
+ override def productPrefix: java.lang.String = { /* compiled code */ }
+ def productArity: scala.Int = { /* compiled code */ }
+ def productElement(x$1: scala.Int): scala.Any = { /* compiled code */ }
+ override def productIterator: scala.collection.Iterator[scala.Any] = { /* compiled code */ }
+ def canEqual(x$1: scala.Any): scala.Boolean = { /* compiled code */ }
+ override def hashCode(): scala.Int = { /* compiled code */ }
+ override def toString(): java.lang.String = { /* compiled code */ }
}
diff --git a/test/files/scalap/cbnParam.check b/test/files/scalap/cbnParam.check
index 52ecb6ae66..abe01297b9 100644
--- a/test/files/scalap/cbnParam.check
+++ b/test/files/scalap/cbnParam.check
@@ -1,3 +1,3 @@
class CbnParam extends scala.AnyRef {
- def this(s : => scala.Predef.String) = { /* compiled code */ }
+ def this(s: => scala.Predef.String) = { /* compiled code */ }
}
diff --git a/test/files/scalap/classPrivate.check b/test/files/scalap/classPrivate.check
index ab2d40cdaf..cf0ffe0cb2 100644
--- a/test/files/scalap/classPrivate.check
+++ b/test/files/scalap/classPrivate.check
@@ -1,10 +1,10 @@
class ClassPrivate extends scala.AnyRef {
def this() = { /* compiled code */ }
- def baz : scala.Int = { /* compiled code */ }
+ def baz: scala.Int = { /* compiled code */ }
class Outer extends scala.AnyRef {
def this() = { /* compiled code */ }
- private[ClassPrivate] def qux : scala.Int = { /* compiled code */ }
+ private[ClassPrivate] def qux: scala.Int = { /* compiled code */ }
}
- protected def quux : scala.Int = { /* compiled code */ }
- private[ClassPrivate] def bar : scala.Int = { /* compiled code */ }
+ protected def quux: scala.Int = { /* compiled code */ }
+ private[ClassPrivate] def bar: scala.Int = { /* compiled code */ }
}
diff --git a/test/files/scalap/classWithExistential.check b/test/files/scalap/classWithExistential.check
index caee3fd6de..7df6bfb765 100644
--- a/test/files/scalap/classWithExistential.check
+++ b/test/files/scalap/classWithExistential.check
@@ -1,4 +1,4 @@
class ClassWithExistential extends scala.AnyRef {
def this() = { /* compiled code */ }
- def foo[A, B] : scala.Function1[A, B forSome {type A <: scala.Seq[scala.Int]; type B >: scala.Predef.String}] = { /* compiled code */ }
+ def foo[A, B]: scala.Function1[A, B forSome {type A <: scala.Seq[scala.Int]; type B >: scala.Predef.String}] = { /* compiled code */ }
}
diff --git a/test/files/scalap/classWithSelfAnnotation.check b/test/files/scalap/classWithSelfAnnotation.check
index 82bbd9e8df..7a1c206e33 100644
--- a/test/files/scalap/classWithSelfAnnotation.check
+++ b/test/files/scalap/classWithSelfAnnotation.check
@@ -1,5 +1,5 @@
class ClassWithSelfAnnotation extends scala.AnyRef {
- this : ClassWithSelfAnnotation with java.lang.CharSequence =>
+ this: ClassWithSelfAnnotation with java.lang.CharSequence =>
def this() = { /* compiled code */ }
- def foo : scala.Int = { /* compiled code */ }
+ def foo: scala.Int = { /* compiled code */ }
}
diff --git a/test/files/scalap/covariantParam.check b/test/files/scalap/covariantParam.check
index f7a3c98966..85b1400fce 100644
--- a/test/files/scalap/covariantParam.check
+++ b/test/files/scalap/covariantParam.check
@@ -1,4 +1,4 @@
class CovariantParam[+A] extends scala.AnyRef {
def this() = { /* compiled code */ }
- def foo[A](a : A) : scala.Int = { /* compiled code */ }
+ def foo[A](a: A): scala.Int = { /* compiled code */ }
}
diff --git a/test/files/scalap/defaultParameter.check b/test/files/scalap/defaultParameter.check
index 0c775ea7b5..4e244d18f1 100644
--- a/test/files/scalap/defaultParameter.check
+++ b/test/files/scalap/defaultParameter.check
@@ -1,3 +1,3 @@
trait DefaultParameter extends scala.AnyRef {
- def foo(s : scala.Predef.String) : scala.Unit
+ def foo(s: scala.Predef.String): scala.Unit
}
diff --git a/test/files/scalap/implicitParam.check b/test/files/scalap/implicitParam.check
index a2cfd6092d..46e995652e 100644
--- a/test/files/scalap/implicitParam.check
+++ b/test/files/scalap/implicitParam.check
@@ -1,4 +1,4 @@
class ImplicitParam extends scala.AnyRef {
def this() = { /* compiled code */ }
- def foo(i : scala.Int)(implicit f : scala.Float, d : scala.Double) : scala.Int = { /* compiled code */ }
+ def foo(i: scala.Int)(implicit f: scala.Float, d: scala.Double): scala.Int = { /* compiled code */ }
}
diff --git a/test/files/scalap/packageObject.check b/test/files/scalap/packageObject.check
index 5732d92958..d1d0bbf122 100644
--- a/test/files/scalap/packageObject.check
+++ b/test/files/scalap/packageObject.check
@@ -1,5 +1,5 @@
package object PackageObject extends scala.AnyRef {
def this() = { /* compiled code */ }
type A = scala.Predef.String
- def foo(i : scala.Int) : scala.Int = { /* compiled code */ }
+ def foo(i: scala.Int): scala.Int = { /* compiled code */ }
}
diff --git a/test/files/scalap/paramClauses.check b/test/files/scalap/paramClauses.check
index 3a141e8faf..11c5e4bbd6 100644
--- a/test/files/scalap/paramClauses.check
+++ b/test/files/scalap/paramClauses.check
@@ -1,4 +1,4 @@
class ParamClauses extends scala.AnyRef {
def this() = { /* compiled code */ }
- def foo(i : scala.Int)(s : scala.Predef.String)(t : scala.Double) : scala.Int = { /* compiled code */ }
+ def foo(i: scala.Int)(s: scala.Predef.String)(t: scala.Double): scala.Int = { /* compiled code */ }
}
diff --git a/test/files/scalap/paramNames.check b/test/files/scalap/paramNames.check
index 85e37f858d..836b3d0e7b 100644
--- a/test/files/scalap/paramNames.check
+++ b/test/files/scalap/paramNames.check
@@ -1,4 +1,4 @@
class ParamNames extends scala.AnyRef {
def this() = { /* compiled code */ }
- def foo(s : => scala.Seq[scala.Int], s2 : => scala.Seq[scala.Any]) : scala.Unit = { /* compiled code */ }
+ def foo(s: => scala.Seq[scala.Int], s2: => scala.Seq[scala.Any]): scala.Unit = { /* compiled code */ }
}
diff --git a/test/files/scalap/sequenceParam.check b/test/files/scalap/sequenceParam.check
index 142d92fea3..f7bf83f6b2 100644
--- a/test/files/scalap/sequenceParam.check
+++ b/test/files/scalap/sequenceParam.check
@@ -1,3 +1,3 @@
class SequenceParam extends scala.AnyRef {
- def this(s : scala.Predef.String, i : scala.Int*) = { /* compiled code */ }
+ def this(s: scala.Predef.String, i: scala.Int*) = { /* compiled code */ }
}
diff --git a/test/files/scalap/simpleClass.check b/test/files/scalap/simpleClass.check
index 4fdf25d1cf..4675cbf665 100644
--- a/test/files/scalap/simpleClass.check
+++ b/test/files/scalap/simpleClass.check
@@ -1,4 +1,4 @@
class SimpleClass extends scala.AnyRef {
def this() = { /* compiled code */ }
- def foo : scala.Int = { /* compiled code */ }
+ def foo: scala.Int = { /* compiled code */ }
}
diff --git a/test/files/scalap/traitObject.check b/test/files/scalap/traitObject.check
index 104ba14f1a..f7ae4fd2f4 100644
--- a/test/files/scalap/traitObject.check
+++ b/test/files/scalap/traitObject.check
@@ -1,8 +1,8 @@
trait TraitObject extends scala.AnyRef {
- def $init$() : scala.Unit = { /* compiled code */ }
- def foo : scala.Int = { /* compiled code */ }
+ def $init$(): scala.Unit = { /* compiled code */ }
+ def foo: scala.Int = { /* compiled code */ }
}
object TraitObject extends scala.AnyRef {
def this() = { /* compiled code */ }
- def bar : scala.Int = { /* compiled code */ }
+ def bar: scala.Int = { /* compiled code */ }
}
diff --git a/test/files/scalap/typeAnnotations.check b/test/files/scalap/typeAnnotations.check
index 407b0235c6..cba69f8e41 100644
--- a/test/files/scalap/typeAnnotations.check
+++ b/test/files/scalap/typeAnnotations.check
@@ -1,8 +1,8 @@
abstract class TypeAnnotations[@scala.specialized R] extends scala.AnyRef {
def this() = { /* compiled code */ }
@scala.specialized
- val x : scala.Int = { /* compiled code */ }
+ val x: scala.Int = { /* compiled code */ }
@scala.specialized
type T
- def compose[@scala.specialized A](x : A, y : R) : A = { /* compiled code */ }
+ def compose[@scala.specialized A](x: A, y: R): A = { /* compiled code */ }
}
diff --git a/test/files/scalap/valAndVar.check b/test/files/scalap/valAndVar.check
index e940da9801..98eae5192d 100644
--- a/test/files/scalap/valAndVar.check
+++ b/test/files/scalap/valAndVar.check
@@ -1,5 +1,5 @@
class ValAndVar extends scala.AnyRef {
def this() = { /* compiled code */ }
- val foo : java.lang.String = { /* compiled code */ }
- var bar : scala.Int = { /* compiled code */ }
+ val foo: java.lang.String = { /* compiled code */ }
+ var bar: scala.Int = { /* compiled code */ }
}
diff --git a/test/files/scalap/wildcardType.check b/test/files/scalap/wildcardType.check
index e43261db32..6ea696647e 100644
--- a/test/files/scalap/wildcardType.check
+++ b/test/files/scalap/wildcardType.check
@@ -1,3 +1,3 @@
class WildcardType extends scala.AnyRef {
- def this(f : scala.Function1[scala.Int, _]) = { /* compiled code */ }
+ def this(f: scala.Function1[scala.Int, _]) = { /* compiled code */ }
}
diff --git a/test/junit/scala/tools/nsc/symtab/CannotHaveAttrsTest.scala b/test/junit/scala/tools/nsc/symtab/CannotHaveAttrsTest.scala
new file mode 100644
index 0000000000..355771bf04
--- /dev/null
+++ b/test/junit/scala/tools/nsc/symtab/CannotHaveAttrsTest.scala
@@ -0,0 +1,67 @@
+package scala.tools.nsc
+package symtab
+
+import org.junit.Assert._
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+
+import scala.tools.testing.AssertUtil.assertThrows
+import scala.reflect.internal.util.OffsetPosition
+
+@RunWith(classOf[JUnit4])
+class CannotHaveAttrsTest {
+ object symbolTable extends SymbolTableForUnitTesting {
+ object CHA extends CannotHaveAttrs {
+ def canEqual(that: Any): Boolean = ???
+ def productArity: Int = ???
+ def productElement(n: Int): Any = ???
+ }
+ val attrlessTrees = List(CHA, EmptyTree, emptyValDef, pendingSuperCall)
+ }
+ import symbolTable._
+
+ @Test
+ def canHaveAttrsIsFalse =
+ attrlessTrees.foreach { t =>
+ assertFalse(t.canHaveAttrs)
+ }
+
+ @Test
+ def defaultPosAssignment =
+ attrlessTrees.foreach { t =>
+ assertEquals(t.pos, NoPosition)
+ t.pos = NoPosition
+ assertEquals(t.pos, NoPosition)
+ t.setPos(NoPosition)
+ assertEquals(t.pos, NoPosition)
+ }
+
+ @Test
+ def defaultTpeAssignment =
+ attrlessTrees.foreach { t =>
+ assertEquals(t.tpe, NoType)
+ t.tpe = NoType
+ assertEquals(t.tpe, NoType)
+ t.setType(NoType)
+ assertEquals(t.tpe, NoType)
+ }
+
+ @Test
+ def nonDefaultPosAssignmentFails = {
+ val pos = new OffsetPosition(null, 0)
+ attrlessTrees.foreach { t =>
+ assertThrows[IllegalArgumentException] { t.pos = pos }
+ assertThrows[IllegalArgumentException] { t.setPos(pos) }
+ }
+ }
+
+ @Test
+ def nonDefaultTpeAssignmentFails = {
+ val tpe = typeOf[Int]
+ attrlessTrees.foreach { t =>
+ assertThrows[IllegalArgumentException] { t.tpe = tpe }
+ assertThrows[IllegalArgumentException] { t.setType(tpe) }
+ }
+ }
+}
diff --git a/test/junit/scala/tools/nsc/symtab/SymbolTableTest.scala b/test/junit/scala/tools/nsc/symtab/SymbolTableTest.scala
index 537cb93ef3..11e955a4bb 100644
--- a/test/junit/scala/tools/nsc/symtab/SymbolTableTest.scala
+++ b/test/junit/scala/tools/nsc/symtab/SymbolTableTest.scala
@@ -9,17 +9,15 @@ import org.junit.runners.JUnit4
@RunWith(classOf[JUnit4])
class SymbolTableTest {
- private def createSymbolTable: SymbolTable = new SymbolTableForUnitTesting
+ object symbolTable extends SymbolTableForUnitTesting
@Test
def initDefinitions = {
- val symbolTable = createSymbolTable
symbolTable.definitions.init()
}
@Test
def basicSubTypeCheck = {
- val symbolTable = createSymbolTable
symbolTable.definitions.init()
val listClassTpe = symbolTable.definitions.ListClass.tpe
val seqClassTpe = symbolTable.definitions.SeqClass.tpe
@@ -32,7 +30,6 @@ class SymbolTableTest {
*/
@Test
def customClassesSubTypeCheck: Unit = {
- val symbolTable = createSymbolTable
import symbolTable._
symbolTable.definitions.init()
val rootClass = symbolTable.rootMirror.RootClass
diff --git a/test/junit/scala/tools/testing/AssertThrowsTest.scala b/test/junit/scala/tools/testing/AssertThrowsTest.scala
new file mode 100644
index 0000000000..a70519e63c
--- /dev/null
+++ b/test/junit/scala/tools/testing/AssertThrowsTest.scala
@@ -0,0 +1,34 @@
+package scala.tools
+package testing
+
+import org.junit.Assert._
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+import AssertUtil.assertThrows
+
+@RunWith(classOf[JUnit4])
+class AssertThrowsTest {
+ class Foo extends Exception
+ class SubFoo extends Foo
+ class Bar extends Exception
+
+ @Test
+ def catchFoo = assertThrows[Foo] { throw new Foo }
+
+ @Test
+ def catchSubclass = assertThrows[Foo] { throw new SubFoo }
+
+ @Test
+ def rethrowBar =
+ assertTrue("exception wasn't rethrown", {
+ try {
+ assertThrows[Foo] { throw new Bar }
+ false
+ } catch {
+ case bar: Bar => true
+ case e: Throwable => fail(s"expected Bar but got $e"); false
+ }
+ })
+
+} \ No newline at end of file
diff --git a/test/junit/scala/tools/testing/AssertUtil.scala b/test/junit/scala/tools/testing/AssertUtil.scala
new file mode 100644
index 0000000000..9efac64a97
--- /dev/null
+++ b/test/junit/scala/tools/testing/AssertUtil.scala
@@ -0,0 +1,19 @@
+package scala.tools
+package testing
+
+/** This module contains additional higher-level assert statements
+ * that are ultimately based on junit.Assert primitives.
+ */
+object AssertUtil {
+ /** Check if exception T (or a subclass) was thrown during evaluation of f.
+ * If any other exception or throwable is found instead it will be re-thrown.
+ */
+ def assertThrows[T <: Exception](f: => Any)(implicit manifest: Manifest[T]): Unit =
+ try f
+ catch {
+ case e: Exception =>
+ val clazz = manifest.erasure.asInstanceOf[Class[T]]
+ if (!clazz.isAssignableFrom(e.getClass))
+ throw e
+ }
+} \ No newline at end of file
diff --git a/test/junit/scala/util/matching/regextract-char.scala b/test/junit/scala/util/matching/regextract-char.scala
new file mode 100644
index 0000000000..50fdcd9d46
--- /dev/null
+++ b/test/junit/scala/util/matching/regextract-char.scala
@@ -0,0 +1,58 @@
+
+package scala.util.matching
+
+import org.junit.Assert._
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+
+import PartialFunction._
+
+/** Regex can match a Char.
+ * If the pattern includes a group,
+ * always return a single char.
+ */
+@RunWith(classOf[JUnit4])
+class CharRegexTest {
+ implicit class Averrable(val b: Boolean) /*extends AnyVal*/ {
+ def yes = assert(b)
+ def no = assert(!b)
+ }
+ val c: Char = 'c' // "cat"(0)
+ val d: Char = 'D' // "Dog"(0)
+
+ @Test def comparesGroupCorrectly(): Unit = {
+ val r = """(\p{Lower})""".r
+ cond(c) { case r(x) => true } .yes
+ cond(c) { case r(_) => true } .yes
+ cond(c) { case r(_*) => true } .yes
+ cond(c) { case r() => true } .no
+
+ cond(d) { case r(x) => true } .no
+ cond(d) { case r(_) => true } .no
+ cond(d) { case r(_*) => true } .no
+ cond(d) { case r() => true } .no
+ }
+
+ @Test def comparesNoGroupCorrectly(): Unit = {
+ val rnc = """\p{Lower}""".r
+ cond(c) { case rnc(x) => true } .no
+ cond(c) { case rnc(_) => true } .no
+ cond(c) { case rnc(_*) => true } .yes
+ cond(c) { case rnc() => true } .yes
+
+ cond(d) { case rnc(x) => true } .no
+ cond(d) { case rnc(_) => true } .no
+ cond(d) { case rnc(_*) => true } .no
+ cond(d) { case rnc() => true } .no
+ }
+
+ @Test(expected = classOf[MatchError])
+ def failCorrectly(): Unit = {
+ val headAndTail = """(\p{Lower})([a-z]+)""".r
+ val n = "cat"(0) match {
+ case headAndTail(ht @ _*) => ht.size
+ }
+ assert(false, s"Match size $n")
+ }
+}
diff --git a/test/pending/junit/scala/util/t7265.scala b/test/junit/scala/util/t7265.scala
index 3b8fa80dbe..71f085d21d 100644
--- a/test/pending/junit/scala/util/t7265.scala
+++ b/test/junit/scala/util/t7265.scala
@@ -30,6 +30,7 @@ class SpecVersionTest {
assert(sut isJavaAtLeast "1.6")
assert(sut isJavaAtLeast "1.7")
assert(!(sut isJavaAtLeast "1.8"))
+ assert(!(sut isJavaAtLeast "1.71"))
}
@Test(expected = classOf[NumberFormatException])
def badVersion(): Unit = {
@@ -40,6 +41,18 @@ class SpecVersionTest {
sut isJavaAtLeast "1"
}
@Test(expected = classOf[NumberFormatException])
+ def noVersion(): Unit = {
+ sut isJavaAtLeast ""
+ }
+ @Test(expected = classOf[NumberFormatException])
+ def dotOnly(): Unit = {
+ sut isJavaAtLeast "."
+ }
+ @Test(expected = classOf[NumberFormatException])
+ def leadingDot(): Unit = {
+ sut isJavaAtLeast ".5"
+ }
+ @Test(expected = classOf[NumberFormatException])
def notASpec(): Unit = {
sut isJavaAtLeast "1.7.1"
}
diff --git a/test/partest b/test/partest
index b74e04a208..8d94facba3 100755
--- a/test/partest
+++ b/test/partest
@@ -119,10 +119,13 @@ if [ ! -z "${PARTEST_DEBUG}" ] ; then
partestDebugStr="-Dpartest.debug=${PARTEST_DEBUG}"
fi
+# note that variables which may intentionally be empty must not
+# be quoted: otherwise an empty string will appear as a command line
+# argument, and java will think that is the program to run.
"${JAVACMD:=java}" \
$JAVA_OPTS -cp "$EXT_CLASSPATH" \
${partestDebugStr} \
- "$color_opts" \
+ ${color_opts} \
-Dfile.encoding=UTF-8 \
-Dscala.home="${SCALA_HOME}" \
-Dpartest.javacmd="${JAVACMD}" \