summaryrefslogtreecommitdiff
path: root/test/files
diff options
context:
space:
mode:
Diffstat (limited to 'test/files')
-rw-r--r--test/files/jvm/future-spec/PromiseTests.scala75
-rw-r--r--test/files/jvm/innerClassAttribute.check34
-rw-r--r--test/files/jvm/innerClassAttribute/Classes_1.scala110
-rw-r--r--test/files/jvm/innerClassAttribute/Test.scala259
-rw-r--r--test/files/jvm/innerClassEnclMethodJavaReflection.scala65
-rw-r--r--test/files/jvm/javaReflection.check2
-rw-r--r--test/files/jvm/serialization-new.check2
-rw-r--r--test/files/jvm/serialization.check2
-rw-r--r--test/files/jvm/t8689.check1
-rw-r--r--test/files/jvm/t8689.scala13
-rw-r--r--test/files/jvm/t9105.check18
-rw-r--r--test/files/jvm/t9105.scala22
-rw-r--r--test/files/neg/names-defaults-neg.check12
-rw-r--r--test/files/neg/t5044.check4
-rw-r--r--test/files/neg/t5091.check4
-rw-r--r--test/files/neg/t7623.check21
-rw-r--r--test/files/neg/t7623.flags1
-rw-r--r--test/files/neg/t7623.scala38
-rw-r--r--test/files/neg/t8463.check19
-rw-r--r--test/files/neg/t8841.check9
-rw-r--r--test/files/neg/t8841.scala15
-rw-r--r--test/files/neg/t9041.check4
-rw-r--r--test/files/neg/t9041.scala17
-rw-r--r--test/files/neg/t9093.check6
-rw-r--r--test/files/neg/t9093.scala5
-rw-r--r--test/files/pos/jesper.scala30
-rw-r--r--test/files/pos/t8801.scala21
-rw-r--r--test/files/pos/t9050.scala13
-rw-r--r--test/files/pos/t9086.scala8
-rw-r--r--test/files/pos/t9111-inliner-workaround.flags1
-rw-r--r--test/files/pos/t9111-inliner-workaround/A_1.java13
-rw-r--r--test/files/pos/t9111-inliner-workaround/Test_1.scala10
-rw-r--r--test/files/pos/t9116.scala7
-rw-r--r--test/files/pos/t9123.flags1
-rw-r--r--test/files/pos/t9123.scala10
-rw-r--r--test/files/pos/t9135.scala16
-rw-r--r--test/files/pos/t9157.scala13
-rw-r--r--test/files/presentation/infix-completion.check193
-rw-r--r--test/files/presentation/infix-completion/Runner.scala3
-rw-r--r--test/files/presentation/infix-completion/src/Snippet.scala1
-rw-r--r--test/files/presentation/infix-completion2.check211
-rw-r--r--test/files/presentation/infix-completion2/Runner.scala3
-rw-r--r--test/files/presentation/infix-completion2/src/Snippet.scala1
-rw-r--r--test/files/run/bcodeInlinerMixed.flags1
-rw-r--r--test/files/run/bcodeInlinerMixed/A_1.java3
-rw-r--r--test/files/run/bcodeInlinerMixed/B_1.scala20
-rw-r--r--test/files/run/bcodeInlinerMixed/Test.scala16
-rw-r--r--test/files/run/bitsets.check1
-rw-r--r--test/files/run/colltest1.scala2
-rw-r--r--test/files/run/compiler-asSeenFrom.scala2
-rw-r--r--test/files/run/existentials-in-compiler.scala2
-rw-r--r--test/files/run/is-valid-num.scala2
-rw-r--r--test/files/run/iterator-from.scala2
-rw-r--r--test/files/run/macroPlugins-enterStats.check30
-rw-r--r--test/files/run/macroPlugins-enterStats.scala50
-rw-r--r--test/files/run/mapConserve.scala2
-rw-r--r--test/files/run/pc-conversions.scala2
-rw-r--r--test/files/run/settings-parse.scala5
-rw-r--r--test/files/run/stringinterpolation_macro-run.scala2
-rw-r--r--test/files/run/synchronized.check4
-rw-r--r--test/files/run/t6502.check8
-rw-r--r--test/files/run/t6502.scala70
-rw-r--r--test/files/run/t7096.scala2
-rw-r--r--test/files/run/t7582.check4
-rw-r--r--test/files/run/t7582b.check4
-rw-r--r--test/files/run/t7974.check23
-rw-r--r--test/files/run/t7974/Test.scala14
-rw-r--r--test/files/run/t9097.scala34
-rw-r--r--test/files/run/t9102.scala81
-rw-r--r--test/files/run/t9219.check3
-rw-r--r--test/files/run/t9219.scala11
-rw-r--r--test/files/run/t9223.scala8
-rw-r--r--test/files/run/t9223b.scala8
-rw-r--r--test/files/scalacheck/Ctrie.scala19
74 files changed, 1633 insertions, 115 deletions
diff --git a/test/files/jvm/future-spec/PromiseTests.scala b/test/files/jvm/future-spec/PromiseTests.scala
index 12b9168c5d..67c8c542ba 100644
--- a/test/files/jvm/future-spec/PromiseTests.scala
+++ b/test/files/jvm/future-spec/PromiseTests.scala
@@ -44,20 +44,79 @@ class PromiseTests extends MinimalScalaTest {
}.getMessage mustBe ("br0ken")
}
+ "be completable with a completed Promise" in {
+ {
+ val p = Promise[String]()
+ p.tryCompleteWith(Promise[String]().success("foo").future)
+ Await.result(p.future, defaultTimeout) mustBe ("foo")
+ }
+ {
+ val p = Promise[String]()
+ p.completeWith(Promise[String]().success("foo").future)
+ Await.result(p.future, defaultTimeout) mustBe ("foo")
+ }
+ {
+ val p = Promise[String]()
+ p.tryCompleteWith(Promise[String]().failure(new RuntimeException("br0ken")).future)
+ intercept[RuntimeException] {
+ Await.result(p.future, defaultTimeout)
+ }.getMessage mustBe ("br0ken")
+ }
+ {
+ val p = Promise[String]()
+ p.tryCompleteWith(Promise[String]().failure(new RuntimeException("br0ken")).future)
+ intercept[RuntimeException] {
+ Await.result(p.future, defaultTimeout)
+ }.getMessage mustBe ("br0ken")
+ }
+ }
}
"A successful Promise" should {
- val result = "test value"
- val promise = Promise[String]().complete(Success(result))
- promise.isCompleted mustBe (true)
- futureWithResult(_(promise.future, result))
+ "be completed" in {
+ val result = "test value"
+ val promise = Promise[String]().complete(Success(result))
+ promise.isCompleted mustBe (true)
+ futureWithResult(_(promise.future, result))
+ }
+
+ "not be completable with a completed Promise" in {
+ {
+ val p = Promise.successful("bar")
+ p.tryCompleteWith(Promise[String]().success("foo").future)
+ Await.result(p.future, defaultTimeout) mustBe ("bar")
+ }
+ {
+ val p = Promise.successful("bar")
+ p.completeWith(Promise[String]().success("foo").future)
+ Await.result(p.future, defaultTimeout) mustBe ("bar")
+ }
+ }
}
"A failed Promise" should {
- val message = "Expected Exception"
- val promise = Promise[String]().complete(Failure(new RuntimeException(message)))
- promise.isCompleted mustBe (true)
- futureWithException[RuntimeException](_(promise.future, message))
+ "be completed" in {
+ val message = "Expected Exception"
+ val promise = Promise[String]().complete(Failure(new RuntimeException(message)))
+ promise.isCompleted mustBe (true)
+ futureWithException[RuntimeException](_(promise.future, message))
+ }
+ "not be completable with a completed Promise" in {
+ {
+ val p = Promise[String]().failure(new RuntimeException("unbr0ken"))
+ p.tryCompleteWith(Promise[String].failure(new Exception("br0ken")).future)
+ intercept[RuntimeException] {
+ Await.result(p.future, defaultTimeout)
+ }.getMessage mustBe ("unbr0ken")
+ }
+ {
+ val p = Promise[String]().failure(new RuntimeException("unbr0ken"))
+ p.completeWith(Promise[String]().failure(new Exception("br0ken")).future)
+ intercept[RuntimeException] {
+ Await.result(p.future, defaultTimeout)
+ }.getMessage mustBe ("unbr0ken")
+ }
+ }
}
"An interrupted Promise" should {
diff --git a/test/files/jvm/innerClassAttribute.check b/test/files/jvm/innerClassAttribute.check
index 20518aa49e..bb532e4f36 100644
--- a/test/files/jvm/innerClassAttribute.check
+++ b/test/files/jvm/innerClassAttribute.check
@@ -14,27 +14,27 @@ A19 / null / null
A19 / null / null
A19 / null / null
-- A20 --
-A20$$anonfun$4 / null / null / 17
+A20$$anonfun$6 / null / null / 17
fun1: attribute for itself and the two child closures `() => ()` and `() => () => 1`
-A20$$anonfun$4 / null / null / 17
-A20$$anonfun$4$$anonfun$apply$1 / null / null / 17
-A20$$anonfun$4$$anonfun$apply$3 / null / null / 17
+A20$$anonfun$6 / null / null / 17
+A20$$anonfun$6$$anonfun$apply$1 / null / null / 17
+A20$$anonfun$6$$anonfun$apply$3 / null / null / 17
fun2 () => (): itself and the outer closure
-A20$$anonfun$4 / null / null / 17
-A20$$anonfun$4$$anonfun$apply$1 / null / null / 17
+A20$$anonfun$6 / null / null / 17
+A20$$anonfun$6$$anonfun$apply$1 / null / null / 17
fun3 () => () => (): itself, the outer closure and its child closure
-A20$$anonfun$4 / null / null / 17
-A20$$anonfun$4$$anonfun$apply$3 / null / null / 17
-A20$$anonfun$4$$anonfun$apply$3$$anonfun$apply$2 / null / null / 17
+A20$$anonfun$6 / null / null / 17
+A20$$anonfun$6$$anonfun$apply$3 / null / null / 17
+A20$$anonfun$6$$anonfun$apply$3$$anonfun$apply$2 / null / null / 17
fun4: () => 1: itself and the two outer closures
-A20$$anonfun$4 / null / null / 17
-A20$$anonfun$4$$anonfun$apply$3 / null / null / 17
-A20$$anonfun$4$$anonfun$apply$3$$anonfun$apply$2 / null / null / 17
-enclosing: nested closures have the apply method of the outer closure
+A20$$anonfun$6 / null / null / 17
+A20$$anonfun$6$$anonfun$apply$3 / null / null / 17
+A20$$anonfun$6$$anonfun$apply$3$$anonfun$apply$2 / null / null / 17
+enclosing: nested closures have outer class defined, but no outer method
A20 / null / null
-A20$$anonfun$4 / apply / ()Lscala/Function0;
-A20$$anonfun$4 / apply / ()Lscala/Function0;
-A20$$anonfun$4$$anonfun$apply$3 / apply / ()Lscala/Function0;
+A20$$anonfun$6 / null / null
+A20$$anonfun$6 / null / null
+A20$$anonfun$6$$anonfun$apply$3 / null / null
#partest -Ydelambdafy:method
-- A4 --
null / null / null
@@ -47,7 +47,7 @@ fun1: attribute for itself and the two child closures `() => ()` and `() => () =
fun2 () => (): itself and the outer closure
fun3 () => () => (): itself, the outer closure and its child closure
fun4: () => 1: itself and the two outer closures
-enclosing: nested closures have the apply method of the outer closure
+enclosing: nested closures have outer class defined, but no outer method
null / null / null
null / null / null
null / null / null
diff --git a/test/files/jvm/innerClassAttribute/Classes_1.scala b/test/files/jvm/innerClassAttribute/Classes_1.scala
index 9c3ea7f013..fb1f32aa3d 100644
--- a/test/files/jvm/innerClassAttribute/Classes_1.scala
+++ b/test/files/jvm/innerClassAttribute/Classes_1.scala
@@ -185,3 +185,113 @@ trait A24 extends A24Base {
override object Conc extends A24Sym
}
}
+
+class SI_9105 {
+ // the EnclosingMethod attributes depend on the delambdafy strategy (inline vs method)
+
+ // outerClass-inline enclMeth-inline outerClass-method enclMeth-method
+ val fun = () => {
+ class A // closure null (*) SI_9105 null
+ def m: Object = { class B; new B } // closure m$1 SI_9105 m$1
+ val f: Object = { class C; new C } // closure null (*) SI_9105 null
+ }
+ def met = () => {
+ class D // closure null (*) SI_9105 met
+ def m: Object = { class E; new E } // closure m$1 SI_9105 m$1
+ val f: Object = { class F; new F } // closure null (*) SI_9105 met
+ }
+
+ // (*) the originalOwner chain of A (similar for D) is: SI_9105.fun.$anonfun-value.A
+ // we can get to the anonfun-class (created by uncurry), but not to the apply method.
+ //
+ // for C and F, the originalOwner chain is fun.$anonfun-value.f.C. at later phases, the rawowner of f is
+ // an apply$sp method of the closure class. we could use that as enclosing method, but it would be unsystematic
+ // (A / D don't have an encl meth either), and also strange to use the $sp, which is a compilation artifact.
+ // So using `null` looks more like the situation in the source code: C / F are nested classes of the anon-fun, and
+ // there's no method in between.
+
+ def byName[T](op: => T) = 0
+
+ val bnV = byName {
+ class G // closure null (*) SI_9105 null
+ def m: Object = { class H; new H } // closure m$1 SI_9105 m$1
+ val f: Object = { class I; new I } // closure null (*) SI_9105 null
+ }
+ def bnM = byName {
+ class J // closure null (*) SI_9105 bnM
+ def m: Object = { class K; new K } // closure m$1 SI_9105 m$1
+ val f: Object = { class L; new L } // closure null (*) SI_9105 bnM
+ }
+}
+
+trait SI_9124 {
+ trait A // member class, no enclosing method attribute
+
+ new A { def f1 = 0 } // nested class, enclosing class SI_9124, no encl meth
+
+ def f = new A { def f2 = 0 } // enclosing method is f in the interface SI_9124
+
+ private def g = new A { def f3 = 0 } // only encl class (SI_9124), encl meth is null because the interface SI_9124 doesn't have a method g
+
+ object O { // member, no encl meth attribute
+ new A { def f4 = 0 } // enclosing class is O$, no enclosing method
+ }
+
+ val f1 = { new A { def f5 = 0 }; 1 } // encl class SI_9124, no encl meth
+ private val f2 = { new A { def f6 = 0 }; 1 } // like above
+}
+
+trait ImplClassesAreTopLevel {
+ // all impl classes are top-level, so they don't appear in any InnerClass entry, and none of them have an EnclosingMethod attr
+ trait B1 { def f = 1 }
+ { trait B2 { def f = 1 }; new B2 {} }
+ val m = {
+ trait B3 { def f = 1 }
+ new B3 {}
+ }
+ def n = {
+ trait B4 { def f = 1 }
+ new B4 {}
+ }
+}
+
+class SpecializedClassesAreTopLevel {
+ // all specialized classes are top-level
+ class A[@specialized(Int) T]; new A[Int]
+
+ object T {
+ class B[@specialized(Int) T]; new B[Int]
+ }
+
+ // these crash the compiler, SI-7625
+
+ // { class B[@specialized(Int) T]; new B[Int] }
+
+ // val m: Object = {
+ // class C[@specialized(Int) T]
+ // new C[Int]
+ // }
+
+ // def n: Object = {
+ // class D[@specialized(Int) T]
+ // new D[Int]
+ // }
+}
+
+object NestedInValueClass {
+ // note that we can only test anonymous functions, nested classes are not allowed inside value classes
+ class A(val arg: String) extends AnyVal {
+ // A has InnerClass entries for the two closures (and for A and A$). not for B / C
+ def f = {
+ def g = List().map(x => (() => x)) // outer class A, no outer method (g is moved to the companion, doesn't exist in A)
+ g.map(x => (() => x)) // outer class A, outer method f
+ }
+ // statements and field declarations are not allowed in value classes
+ }
+
+ object A {
+ // A$ has InnerClass entries for B, C, A, A$. Also for the closures above, because they are referenced in A$'s bytecode.
+ class B // member class of A$
+ def f = { class C; new C } // outer class A$, outer method f
+ }
+}
diff --git a/test/files/jvm/innerClassAttribute/Test.scala b/test/files/jvm/innerClassAttribute/Test.scala
index 3820048cb4..bc9aa2376a 100644
--- a/test/files/jvm/innerClassAttribute/Test.scala
+++ b/test/files/jvm/innerClassAttribute/Test.scala
@@ -16,6 +16,16 @@ object Test extends BytecodeTest {
loadClassNode(className).innerClasses.asScala.toList.sortBy(_.name)
}
+ def ownInnerClassNode(n: String) = innerClassNodes(n).filter(_.name == n).head
+
+ def testInner(cls: String, fs: (InnerClassNode => Unit)*) = {
+ val ns = innerClassNodes(cls)
+ assert(ns.length == fs.length, ns)
+ (ns zip fs.toList) foreach { case (n, f) => f(n) }
+ }
+
+
+
final case class EnclosingMethod(name: String, descriptor: String, outerClass: String)
def enclosingMethod(className: String) = {
val n = loadClassNode(className)
@@ -215,7 +225,7 @@ object Test extends BytecodeTest {
assertAnonymous(anon1, "A18$$anon$5")
assertAnonymous(anon2, "A18$$anon$6")
- assertLocal(a, "A18$A$1", "A$1")
+ assertLocal(a, "A18$A$2", "A$2")
assertLocal(b, "A18$B$4", "B$4")
assertEnclosingMethod(
@@ -226,7 +236,7 @@ object Test extends BytecodeTest {
"A18", "g$1", "()V")
assertEnclosingMethod(
- "A18$A$1",
+ "A18$A$2",
"A18", "g$1", "()V")
assertEnclosingMethod(
"A18$B$4",
@@ -256,10 +266,10 @@ object Test extends BytecodeTest {
printInnerClassNodes("A20")
- val fun1 = lambdaClass("A20$$anonfun$4", "A20$lambda$1")
- val fun2 = lambdaClass("A20$$anonfun$4$$anonfun$apply$1", "A20$lambda$$$nestedInAnonfun$5$1")
- val fun3 = lambdaClass("A20$$anonfun$4$$anonfun$apply$3", "A20$lambda$$$nestedInAnonfun$5$2")
- val fun4 = lambdaClass("A20$$anonfun$4$$anonfun$apply$3$$anonfun$apply$2", "A20$lambda$$$nestedInAnonfun$7$1")
+ val fun1 = lambdaClass("A20$$anonfun$6", "A20$lambda$1")
+ val fun2 = lambdaClass("A20$$anonfun$6$$anonfun$apply$1", "A20$lambda$$$nestedInAnonfun$5$1")
+ val fun3 = lambdaClass("A20$$anonfun$6$$anonfun$apply$3", "A20$lambda$$$nestedInAnonfun$5$2")
+ val fun4 = lambdaClass("A20$$anonfun$6$$anonfun$apply$3$$anonfun$apply$2", "A20$lambda$$$nestedInAnonfun$7$1")
println("fun1: attribute for itself and the two child closures `() => ()` and `() => () => 1`")
printInnerClassNodes(fun1)
@@ -270,7 +280,7 @@ object Test extends BytecodeTest {
println("fun4: () => 1: itself and the two outer closures")
printInnerClassNodes(fun4)
- println("enclosing: nested closures have the apply method of the outer closure")
+ println("enclosing: nested closures have outer class defined, but no outer method")
printEnclosingMethod(fun1)
printEnclosingMethod(fun2)
printEnclosingMethod(fun3)
@@ -316,12 +326,238 @@ object Test extends BytecodeTest {
}
def testA24() {
- val List(defsCls, abs, conc, defsApi, defsApiImpl) = innerClassNodes("A24$DefinitionsClass")
+ val List(defsCls, abs, conc, defsApi) = innerClassNodes("A24$DefinitionsClass")
assertMember(defsCls, "A24", "DefinitionsClass")
assertMember(abs, "A24$DefinitionsClass", "Abs$")
assertMember(conc, "A24$DefinitionsClass", "Conc$")
assertMember(defsApi, "A24Base", "DefinitionsApi", flags = publicAbstractInterface)
- assertMember(defsApiImpl, "A24Base", "DefinitionsApi$class", flags = Flags.ACC_PUBLIC | Flags.ACC_ABSTRACT)
+ }
+
+ def testSI_9105() {
+ val isDelambdafyMethod = classpath.findClass("SI_9105$lambda$1").isDefined
+ if (isDelambdafyMethod) {
+ assertEnclosingMethod ("SI_9105$A$3" , "SI_9105", null , null)
+ assertEnclosingMethod ("SI_9105$B$5" , "SI_9105", "m$1", "()Ljava/lang/Object;")
+ assertEnclosingMethod ("SI_9105$C$1" , "SI_9105", null , null)
+ assertEnclosingMethod ("SI_9105$D$1" , "SI_9105", "met", "()Lscala/Function0;")
+ assertEnclosingMethod ("SI_9105$E$1" , "SI_9105", "m$3", "()Ljava/lang/Object;")
+ assertEnclosingMethod ("SI_9105$F$1" , "SI_9105", "met", "()Lscala/Function0;")
+ assertNoEnclosingMethod("SI_9105$lambda$$met$1")
+ assertNoEnclosingMethod("SI_9105$lambda$1")
+ assertNoEnclosingMethod("SI_9105")
+
+ assertLocal(innerClassNodes("SI_9105$A$3").head, "SI_9105$A$3", "A$3")
+ assertLocal(innerClassNodes("SI_9105$B$5").head, "SI_9105$B$5", "B$5")
+ assertLocal(innerClassNodes("SI_9105$C$1").head, "SI_9105$C$1", "C$1")
+ assertLocal(innerClassNodes("SI_9105$D$1").head, "SI_9105$D$1", "D$1")
+ assertLocal(innerClassNodes("SI_9105$E$1").head, "SI_9105$E$1", "E$1")
+ assertLocal(innerClassNodes("SI_9105$F$1").head, "SI_9105$F$1", "F$1")
+
+ // by-name
+ assertEnclosingMethod("SI_9105$G$1", "SI_9105", null , null)
+ assertEnclosingMethod("SI_9105$H$1", "SI_9105", "m$2", "()Ljava/lang/Object;")
+ assertEnclosingMethod("SI_9105$I$1", "SI_9105", null , null)
+ assertEnclosingMethod("SI_9105$J$1", "SI_9105", "bnM", "()I")
+ assertEnclosingMethod("SI_9105$K$2", "SI_9105", "m$4", "()Ljava/lang/Object;")
+ assertEnclosingMethod("SI_9105$L$1", "SI_9105", "bnM", "()I")
+
+ assert(innerClassNodes("SI_9105$lambda$$met$1").isEmpty)
+ assert(innerClassNodes("SI_9105$lambda$1").isEmpty)
+ assert(innerClassNodes("SI_9105").length == 12) // the 12 local classes
+ } else {
+ // comment in innerClassAttribute/Classes_1.scala explains the difference between A / C and D / F.
+ assertEnclosingMethod ("SI_9105$$anonfun$4$A$3" , "SI_9105$$anonfun$4" , null , null)
+ assertEnclosingMethod ("SI_9105$$anonfun$4$B$5" , "SI_9105$$anonfun$4" , "m$1" , "()Ljava/lang/Object;")
+ assertEnclosingMethod ("SI_9105$$anonfun$4$C$1" , "SI_9105$$anonfun$4" , null , null)
+ assertEnclosingMethod ("SI_9105$$anonfun$met$1$D$1", "SI_9105$$anonfun$met$1", null , null)
+ assertEnclosingMethod ("SI_9105$$anonfun$met$1$E$1", "SI_9105$$anonfun$met$1", "m$3" , "()Ljava/lang/Object;")
+ assertEnclosingMethod ("SI_9105$$anonfun$met$1$F$1", "SI_9105$$anonfun$met$1", null , null)
+ assertEnclosingMethod ("SI_9105$$anonfun$4" , "SI_9105" , null , null)
+ assertEnclosingMethod ("SI_9105$$anonfun$met$1" , "SI_9105" , "met" , "()Lscala/Function0;")
+ assertNoEnclosingMethod("SI_9105")
+
+ assertLocal(ownInnerClassNode("SI_9105$$anonfun$4$A$3"), "SI_9105$$anonfun$4$A$3" , "A$3")
+ assertLocal(ownInnerClassNode("SI_9105$$anonfun$4$B$5"), "SI_9105$$anonfun$4$B$5" , "B$5")
+ assertLocal(ownInnerClassNode("SI_9105$$anonfun$4$C$1"), "SI_9105$$anonfun$4$C$1" , "C$1")
+ assertLocal(ownInnerClassNode("SI_9105$$anonfun$met$1$D$1"), "SI_9105$$anonfun$met$1$D$1", "D$1")
+ assertLocal(ownInnerClassNode("SI_9105$$anonfun$met$1$E$1"), "SI_9105$$anonfun$met$1$E$1", "E$1")
+ assertLocal(ownInnerClassNode("SI_9105$$anonfun$met$1$F$1"), "SI_9105$$anonfun$met$1$F$1", "F$1")
+
+ // by-name
+ assertEnclosingMethod("SI_9105$$anonfun$5$G$1", "SI_9105$$anonfun$5", null, null)
+ assertEnclosingMethod("SI_9105$$anonfun$5$H$1", "SI_9105$$anonfun$5", "m$2", "()Ljava/lang/Object;")
+ assertEnclosingMethod("SI_9105$$anonfun$5$I$1", "SI_9105$$anonfun$5", null, null)
+ assertEnclosingMethod("SI_9105$$anonfun$bnM$1$J$1", "SI_9105$$anonfun$bnM$1", null, null)
+ assertEnclosingMethod("SI_9105$$anonfun$bnM$1$K$2", "SI_9105$$anonfun$bnM$1", "m$4", "()Ljava/lang/Object;")
+ assertEnclosingMethod("SI_9105$$anonfun$bnM$1$L$1", "SI_9105$$anonfun$bnM$1", null, null)
+
+ assertAnonymous(ownInnerClassNode("SI_9105$$anonfun$4"), "SI_9105$$anonfun$4")
+ assertAnonymous(ownInnerClassNode("SI_9105$$anonfun$met$1"), "SI_9105$$anonfun$met$1")
+
+ assert(innerClassNodes("SI_9105$$anonfun$4").length == 4) // itself and three of the local classes
+ assert(innerClassNodes("SI_9105$$anonfun$met$1").length == 4) // itself and three of the local classes
+ assert(innerClassNodes("SI_9105").length == 4) // the four anon funs
+ }
+ }
+
+ def testSI_9124() {
+ val classes: Map[String, String] = {
+ List("SI_9124$$anon$10",
+ "SI_9124$$anon$11",
+ "SI_9124$$anon$12",
+ "SI_9124$$anon$8",
+ "SI_9124$$anon$9",
+ "SI_9124$O$$anon$13").map({ name =>
+ val node = loadClassNode(name)
+ val fMethod = node.methods.asScala.find(_.name.startsWith("f")).get.name
+ (fMethod, node.name)
+ }).toMap
+ }
+
+ // println(classes)
+
+ assertNoEnclosingMethod("SI_9124$A")
+ assertEnclosingMethod(classes("f1"), "SI_9124", null, null)
+ assertEnclosingMethod(classes("f2"), "SI_9124", "f", "()LSI_9124$A;")
+ assertEnclosingMethod(classes("f3"), "SI_9124", null, null)
+ assertEnclosingMethod(classes("f4"), "SI_9124$O$", null, null)
+ assertEnclosingMethod(classes("f5"), "SI_9124", null, null)
+ assertEnclosingMethod(classes("f6"), "SI_9124", null, null)
+ assertNoEnclosingMethod("SI_9124$O$")
+
+ assertMember(ownInnerClassNode("SI_9124$A"), "SI_9124", "A", flags = publicAbstractInterface)
+ classes.values.foreach(n => assertAnonymous(ownInnerClassNode(n), n))
+ assertMember(ownInnerClassNode("SI_9124$O$"), "SI_9124", "O$")
+ }
+
+ def testImplClassesTopLevel() {
+ val classes = List(
+ "ImplClassesAreTopLevel$$anon$14",
+ "ImplClassesAreTopLevel$$anon$15",
+ "ImplClassesAreTopLevel$$anon$16",
+ "ImplClassesAreTopLevel$B1$class",
+ "ImplClassesAreTopLevel$B1",
+ "ImplClassesAreTopLevel$B2$1$class",
+ "ImplClassesAreTopLevel$B2$1",
+ "ImplClassesAreTopLevel$B3$1$class",
+ "ImplClassesAreTopLevel$B3$1",
+ "ImplClassesAreTopLevel$B4$class",
+ "ImplClassesAreTopLevel$B4$1",
+ "ImplClassesAreTopLevel$class",
+ "ImplClassesAreTopLevel")
+
+ classes.filter(_.endsWith("$class")).foreach(assertNoEnclosingMethod)
+ classes.flatMap(innerClassNodes).foreach(icn => assert(!icn.name.endsWith("$class"), icn))
+
+ assertNoEnclosingMethod("ImplClassesAreTopLevel$B1") // member, no encl meth attr
+
+ // no encl meth, but encl class
+ List("ImplClassesAreTopLevel$B2$1", "ImplClassesAreTopLevel$B3$1",
+ "ImplClassesAreTopLevel$$anon$14", "ImplClassesAreTopLevel$$anon$15").foreach(assertEnclosingMethod(_, "ImplClassesAreTopLevel", null, null))
+
+ // encl meth n
+ List("ImplClassesAreTopLevel$B4$1", "ImplClassesAreTopLevel$$anon$16").foreach(assertEnclosingMethod(_, "ImplClassesAreTopLevel", "n", "()Ljava/lang/Object;"))
+
+ val an14 = assertAnonymous(_: InnerClassNode, "ImplClassesAreTopLevel$$anon$14")
+ val an15 = assertAnonymous(_: InnerClassNode, "ImplClassesAreTopLevel$$anon$15")
+ val an16 = assertAnonymous(_: InnerClassNode, "ImplClassesAreTopLevel$$anon$16")
+ val b1 = assertMember(_: InnerClassNode, "ImplClassesAreTopLevel", "B1", flags = publicAbstractInterface)
+ val b2 = assertLocal(_ : InnerClassNode, "ImplClassesAreTopLevel$B2$1", "B2$1", flags = publicAbstractInterface)
+ val b3 = assertLocal(_ : InnerClassNode, "ImplClassesAreTopLevel$B3$1", "B3$1", flags = publicAbstractInterface)
+ val b4 = assertLocal(_ : InnerClassNode, "ImplClassesAreTopLevel$B4$1", "B4$1", flags = publicAbstractInterface)
+
+ testInner("ImplClassesAreTopLevel$$anon$14", an14, b3)
+ testInner("ImplClassesAreTopLevel$$anon$15", an15, b2)
+ testInner("ImplClassesAreTopLevel$$anon$16", an16, b4)
+
+ testInner("ImplClassesAreTopLevel$B1$class", b1)
+ testInner("ImplClassesAreTopLevel$B2$1$class", b2)
+ testInner("ImplClassesAreTopLevel$B3$1$class", b3)
+ testInner("ImplClassesAreTopLevel$B4$class", b4)
+
+ testInner("ImplClassesAreTopLevel$B1", b1)
+ testInner("ImplClassesAreTopLevel$B2$1", b2)
+ testInner("ImplClassesAreTopLevel$B3$1", b3)
+ testInner("ImplClassesAreTopLevel$B4$1", b4)
+
+ testInner("ImplClassesAreTopLevel$class", an14, an15, an16)
+ testInner("ImplClassesAreTopLevel", an14, an15, an16, b1, b2, b3, b4)
+ }
+
+ def testSpecializedClassesTopLevel() {
+ val cls = List(
+ "SpecializedClassesAreTopLevel$A$mcI$sp",
+ "SpecializedClassesAreTopLevel$A",
+ "SpecializedClassesAreTopLevel$T$",
+ "SpecializedClassesAreTopLevel$T$B$mcI$sp",
+ "SpecializedClassesAreTopLevel$T$B",
+ "SpecializedClassesAreTopLevel")
+
+ // all classes are members, no local (can't test local, they crash in specialize)
+ cls.foreach(assertNoEnclosingMethod)
+ cls.flatMap(innerClassNodes).foreach(icn => assert(!icn.name.endsWith("$sp"), icn))
+
+ val a = assertMember(_: InnerClassNode, "SpecializedClassesAreTopLevel", "A")
+ val t = assertMember(_: InnerClassNode, "SpecializedClassesAreTopLevel", "T$")
+ val b = assertMember(_: InnerClassNode, "SpecializedClassesAreTopLevel$T$", "B", Some("SpecializedClassesAreTopLevel$T$B"))
+
+ List("SpecializedClassesAreTopLevel$A$mcI$sp", "SpecializedClassesAreTopLevel$A").foreach(testInner(_, a))
+ testInner("SpecializedClassesAreTopLevel", a, t)
+ List("SpecializedClassesAreTopLevel$T$", "SpecializedClassesAreTopLevel$T$B$mcI$sp", "SpecializedClassesAreTopLevel$T$B").foreach(testInner(_, t, b))
+ }
+
+ def testNestedInValueClass() {
+ List(
+ "NestedInValueClass",
+ "NestedInValueClass$",
+ "NestedInValueClass$A",
+ "NestedInValueClass$A$",
+ "NestedInValueClass$A$B").foreach(assertNoEnclosingMethod)
+
+ assertEnclosingMethod("NestedInValueClass$A$C$2", "NestedInValueClass$A$", "f", "()Ljava/lang/Object;")
+
+ type I = InnerClassNode
+ val a = assertMember(_: I, "NestedInValueClass", "A", flags = publicStatic | Flags.ACC_FINAL)
+ val am = assertMember(_: I, "NestedInValueClass", "A$", flags = publicStatic)
+ val b = assertMember(_: I, "NestedInValueClass$A$", "B", Some("NestedInValueClass$A$B"), flags = publicStatic)
+ val c = assertLocal(_: I, "NestedInValueClass$A$C$2", "C$2")
+
+ testInner("NestedInValueClass$")
+ testInner("NestedInValueClass", a, am)
+ testInner("NestedInValueClass$A$B", am, b)
+ testInner("NestedInValueClass$A$C$2", am, c)
+
+ val isDelambdafyMethod = classpath.findClass("NestedInValueClass$A$lambda$$f$extension$1").isDefined
+ if (isDelambdafyMethod) {
+ List(
+ "NestedInValueClass$A$lambda$$g$2$1",
+ "NestedInValueClass$A$lambda$$f$extension$1",
+ "NestedInValueClass$A$lambda$$$nestedInAnonfun$13$1",
+ "NestedInValueClass$A$lambda$$$nestedInAnonfun$15$1").foreach(assertNoEnclosingMethod)
+ testInner("NestedInValueClass$A", a, am)
+ testInner("NestedInValueClass$A$", a, am, b, c)
+ testInner("NestedInValueClass$A$lambda$$g$2$1", am)
+ testInner("NestedInValueClass$A$lambda$$f$extension$1", am)
+ testInner("NestedInValueClass$A$lambda$$$nestedInAnonfun$13$1", am)
+ testInner("NestedInValueClass$A$lambda$$$nestedInAnonfun$15$1", am)
+ } else {
+ assertEnclosingMethod("NestedInValueClass$A$$anonfun$g$2$1" , "NestedInValueClass$A" , null, null)
+ assertEnclosingMethod("NestedInValueClass$A$$anonfun$g$2$1$$anonfun$apply$4" , "NestedInValueClass$A$$anonfun$g$2$1" , null, null)
+ assertEnclosingMethod("NestedInValueClass$A$$anonfun$f$extension$1" , "NestedInValueClass$A" , "f", "()Lscala/collection/immutable/List;")
+ assertEnclosingMethod("NestedInValueClass$A$$anonfun$f$extension$1$$anonfun$apply$5", "NestedInValueClass$A$$anonfun$f$extension$1", null, null)
+
+ val gfun = assertAnonymous(_: I, "NestedInValueClass$A$$anonfun$g$2$1")
+ val ffun = assertAnonymous(_: I, "NestedInValueClass$A$$anonfun$f$extension$1")
+ val gfunfun = assertAnonymous(_: I, "NestedInValueClass$A$$anonfun$g$2$1$$anonfun$apply$4")
+ val ffunfun = assertAnonymous(_: I, "NestedInValueClass$A$$anonfun$f$extension$1$$anonfun$apply$5")
+
+ testInner("NestedInValueClass$A", a, am, ffun, gfun)
+ testInner("NestedInValueClass$A$", a, am, ffun, gfun, b, c)
+ testInner("NestedInValueClass$A$$anonfun$g$2$1", a, am, gfun, gfunfun)
+ testInner("NestedInValueClass$A$$anonfun$g$2$1$$anonfun$apply$4", am, gfun, gfunfun)
+ testInner("NestedInValueClass$A$$anonfun$f$extension$1", a, am, ffun, ffunfun)
+ testInner("NestedInValueClass$A$$anonfun$f$extension$1$$anonfun$apply$5", am, ffun, ffunfun)
+ }
}
def show(): Unit = {
@@ -347,5 +583,10 @@ object Test extends BytecodeTest {
testA22()
testA23()
testA24()
+ testSI_9105()
+ testSI_9124()
+ testImplClassesTopLevel()
+ testSpecializedClassesTopLevel()
+ testNestedInValueClass()
}
}
diff --git a/test/files/jvm/innerClassEnclMethodJavaReflection.scala b/test/files/jvm/innerClassEnclMethodJavaReflection.scala
new file mode 100644
index 0000000000..ee39cb43bf
--- /dev/null
+++ b/test/files/jvm/innerClassEnclMethodJavaReflection.scala
@@ -0,0 +1,65 @@
+import scala.reflect.io._
+import java.net.URLClassLoader
+
+object Test extends App {
+ val jarsOrDirectories = Set("partest.lib", "partest.reflect", "partest.comp") map sys.props
+
+ object AllowedMissingClass {
+ // Some classes in scala-compiler.jar have references to jline / ant classes, which seem to be
+ // not on the classpath. We just skip over those classes.
+ // PENDING: for now we also allow missing $anonfun classes: the optimizer may eliminate some closures
+ // that are refferred to in EnclosingClass attributes. SI-9136
+ val allowedMissingPackages = Set("jline", "org.apache.tools.ant", "$anonfun")
+
+ def ok(t: Throwable) = {
+ allowedMissingPackages.exists(p => t.getMessage.replace('/', '.').contains(p))
+ }
+
+ def unapply(t: Throwable): Option[Throwable] = t match {
+ case _: NoClassDefFoundError | _: ClassNotFoundException | _: TypeNotPresentException if ok(t) => Some(t)
+ case _ => None
+ }
+ }
+
+ jarsOrDirectories foreach testClasses
+
+ def testClasses(jarOrDirectory: String): Unit = {
+ val classPath = AbstractFile.getDirectory(new java.io.File(jarOrDirectory))
+
+ def flatten(f: AbstractFile): Iterator[AbstractFile] =
+ if (f.isClassContainer) f.iterator.flatMap(flatten)
+ else Iterator(f)
+
+ val classFullNames = flatten(classPath).filter(_.hasExtension("class")).map(_.path.replace("/", ".").replaceAll(".class$", ""))
+
+ // it seems that Class objects can only be GC'd together with their class loader
+ // (http://stackoverflow.com/questions/2433261/when-and-how-are-classes-garbage-collected-in-java)
+ // if we just use the same class loader for the entire test (Class.forName), we run out of PermGen
+ // even with that, we still neeed a PermGen of 90M or so, the default 64 is not enough. I tried
+ // using one class loader per 100 classes, but that didn't help, the classes didn't get GC'd.
+ val classLoader = new URLClassLoader(Array(classPath.toURL))
+
+ val faulty = new collection.mutable.ListBuffer[(String, Throwable)]
+
+ def tryGetClass(name: String) = try {
+ Some[Class[_]](classLoader.loadClass(name))
+ } catch {
+ case AllowedMissingClass(_) => None
+ }
+
+ for (name <- classFullNames; cls <- tryGetClass(name)) {
+ try {
+ cls.getEnclosingMethod
+ cls.getEnclosingClass
+ cls.getEnclosingConstructor
+ cls.getDeclaredClasses
+ } catch {
+ case AllowedMissingClass(_) =>
+ case t: Throwable => faulty += ((name, t))
+ }
+ }
+
+ if (faulty.nonEmpty)
+ println(faulty.toList mkString "\n")
+ }
+}
diff --git a/test/files/jvm/javaReflection.check b/test/files/jvm/javaReflection.check
index d40599507d..8180ecff8a 100644
--- a/test/files/jvm/javaReflection.check
+++ b/test/files/jvm/javaReflection.check
@@ -5,7 +5,7 @@ A$$anonfun$$lessinit$greater$1 / null (canon) / $anonfun$$lessinit$greater$1 (si
- properties : true (local) / false (member)
A$$anonfun$$lessinit$greater$1$$anonfun$apply$1 / null (canon) / $anonfun$apply$1 (simple)
- declared cls: List()
-- enclosing : null (declaring cls) / class A$$anonfun$$lessinit$greater$1 (cls) / null (constr) / public final scala.Function0 A$$anonfun$$lessinit$greater$1.apply() (meth)
+- enclosing : null (declaring cls) / class A$$anonfun$$lessinit$greater$1 (cls) / null (constr) / null (meth)
- properties : true (local) / false (member)
A$$anonfun$2 / null (canon) / $anonfun$2 (simple)
- declared cls: List()
diff --git a/test/files/jvm/serialization-new.check b/test/files/jvm/serialization-new.check
index 1555135926..cb26446f40 100644
--- a/test/files/jvm/serialization-new.check
+++ b/test/files/jvm/serialization-new.check
@@ -1,4 +1,4 @@
-warning: there were two deprecation warnings; re-run with -deprecation for details
+warning: there were three deprecation warnings; re-run with -deprecation for details
a1 = Array[1,2,3]
_a1 = Array[1,2,3]
arrayEquals(a1, _a1): true
diff --git a/test/files/jvm/serialization.check b/test/files/jvm/serialization.check
index 1555135926..cb26446f40 100644
--- a/test/files/jvm/serialization.check
+++ b/test/files/jvm/serialization.check
@@ -1,4 +1,4 @@
-warning: there were two deprecation warnings; re-run with -deprecation for details
+warning: there were three deprecation warnings; re-run with -deprecation for details
a1 = Array[1,2,3]
_a1 = Array[1,2,3]
arrayEquals(a1, _a1): true
diff --git a/test/files/jvm/t8689.check b/test/files/jvm/t8689.check
new file mode 100644
index 0000000000..2e9ba477f8
--- /dev/null
+++ b/test/files/jvm/t8689.check
@@ -0,0 +1 @@
+success
diff --git a/test/files/jvm/t8689.scala b/test/files/jvm/t8689.scala
new file mode 100644
index 0000000000..ef43a1df63
--- /dev/null
+++ b/test/files/jvm/t8689.scala
@@ -0,0 +1,13 @@
+object Test {
+ def main(args: Array[String]): Unit = {
+ import scala.concurrent._
+ import ExecutionContext.Implicits.global
+ val source1 = Promise[Int]()
+ val source2 = Promise[Int]()
+ source2.completeWith(source1.future).future.onComplete {
+ case _ => print("success")
+ }
+ source2.tryFailure(new TimeoutException)
+ source1.success(123)
+ }
+} \ No newline at end of file
diff --git a/test/files/jvm/t9105.check b/test/files/jvm/t9105.check
new file mode 100644
index 0000000000..34750833f1
--- /dev/null
+++ b/test/files/jvm/t9105.check
@@ -0,0 +1,18 @@
+#partest !-Ydelambdafy:method
+(class C$$anonfun$1$A$1,class C$$anonfun$1,null)
+(class C$$anonfun$1$B$1,class C$$anonfun$1,private final java.lang.Object C$$anonfun$1.m$1())
+(class C$$anonfun$1$C$1,class C$$anonfun$1,null)
+(class C$$anonfun$1$$anonfun$2$D$1,class C$$anonfun$1$$anonfun$2,null)
+(class C$$anonfun$met$1$E$1,class C$$anonfun$met$1,null)
+(class C$$anonfun$met$1$F$1,class C$$anonfun$met$1,private final java.lang.Object C$$anonfun$met$1.m$2())
+(class C$$anonfun$met$1$G$1,class C$$anonfun$met$1,null)
+(class C$$anonfun$met$1$$anonfun$3$H$1,class C$$anonfun$met$1$$anonfun$3,null)
+#partest -Ydelambdafy:method
+(class C$A$1,class C,null)
+(class C$B$1,class C,private final java.lang.Object C.m$1())
+(class C$C$1,class C,null)
+(class C$D$1,class C,null)
+(class C$E$1,class C,public scala.Function0 C.met())
+(class C$F$1,class C,private final java.lang.Object C.m$2())
+(class C$G$1,class C,public scala.Function0 C.met())
+(class C$H$1,class C,public scala.Function0 C.met())
diff --git a/test/files/jvm/t9105.scala b/test/files/jvm/t9105.scala
new file mode 100644
index 0000000000..636ee8a768
--- /dev/null
+++ b/test/files/jvm/t9105.scala
@@ -0,0 +1,22 @@
+class C {
+ val fun = () => {
+ class A
+ def m: Object = { class B; new B }
+ val f: Object = { class C; new C }
+ val g = () => { class D; new D }
+ List[Object](new A, m, f, g())
+ }
+ def met = () => {
+ class E
+ def m: Object = { class F; new F }
+ val f: Object = { class G; new G }
+ val g = () => { class H; new H }
+ List[Object](new E, m, f, g())
+ }
+}
+
+object Test extends App {
+ val x = new C().fun.apply() ::: new C().met.apply()
+ val results = x.map(_.getClass).map(cls => (cls, cls.getEnclosingClass, cls.getEnclosingMethod))
+ println(results.mkString("\n"))
+}
diff --git a/test/files/neg/names-defaults-neg.check b/test/files/neg/names-defaults-neg.check
index d929cf23ec..194be72250 100644
--- a/test/files/neg/names-defaults-neg.check
+++ b/test/files/neg/names-defaults-neg.check
@@ -157,15 +157,15 @@ names-defaults-neg.scala:148: error: variable definition needs type because 'x'
names-defaults-neg.scala:151: error: variable definition needs type because 'x' is used as a named argument in its body.
object t6 { var x = t.f(x = 1) }
^
-names-defaults-neg.scala:151: warning: type-checking the invocation of method f checks if the named argument expression 'x = ...' is a valid assignment
-in the current scope. The resulting type inference error (see above) can be fixed by providing an explicit type in the local definition for x.
+names-defaults-neg.scala:151: warning: failed to determine if 'x = ...' is a named argument or an assignment expression.
+an explicit type is required for the definition mentioned in the error message above.
object t6 { var x = t.f(x = 1) }
^
names-defaults-neg.scala:154: error: variable definition needs type because 'x' is used as a named argument in its body.
class t9 { var x = t.f(x = 1) }
^
-names-defaults-neg.scala:154: warning: type-checking the invocation of method f checks if the named argument expression 'x = ...' is a valid assignment
-in the current scope. The resulting type inference error (see above) can be fixed by providing an explicit type in the local definition for x.
+names-defaults-neg.scala:154: warning: failed to determine if 'x = ...' is a named argument or an assignment expression.
+an explicit type is required for the definition mentioned in the error message above.
class t9 { var x = t.f(x = 1) }
^
names-defaults-neg.scala:168: error: variable definition needs type because 'x' is used as a named argument in its body.
@@ -180,8 +180,8 @@ names-defaults-neg.scala:174: error: reference to x is ambiguous; it is both a m
names-defaults-neg.scala:181: error: variable definition needs type because 'x' is used as a named argument in its body.
class u15 { var x = u.f(x = 1) }
^
-names-defaults-neg.scala:181: warning: type-checking the invocation of method f checks if the named argument expression 'x = ...' is a valid assignment
-in the current scope. The resulting type inference error (see above) can be fixed by providing an explicit type in the local definition for x.
+names-defaults-neg.scala:181: warning: failed to determine if 'x = ...' is a named argument or an assignment expression.
+an explicit type is required for the definition mentioned in the error message above.
class u15 { var x = u.f(x = 1) }
^
names-defaults-neg.scala:184: error: reference to x is ambiguous; it is both a method parameter and a variable in scope.
diff --git a/test/files/neg/t5044.check b/test/files/neg/t5044.check
index 197da2a4e8..dc3708123f 100644
--- a/test/files/neg/t5044.check
+++ b/test/files/neg/t5044.check
@@ -1,8 +1,8 @@
t5044.scala:7: error: recursive value a needs type
val id = m(a)
^
-t5044.scala:6: warning: type-checking the invocation of method foo checks if the named argument expression 'id = ...' is a valid assignment
-in the current scope. The resulting type inference error (see above) can be fixed by providing an explicit type in the local definition for id.
+t5044.scala:6: warning: failed to determine if 'id = ...' is a named argument or an assignment expression.
+an explicit type is required for the definition mentioned in the error message above.
val a = foo(id = 1)
^
one warning found
diff --git a/test/files/neg/t5091.check b/test/files/neg/t5091.check
index abd24e3145..156f695f41 100644
--- a/test/files/neg/t5091.check
+++ b/test/files/neg/t5091.check
@@ -1,8 +1,8 @@
t5091.scala:8: error: recursive value xxx needs type
val param = bar(xxx)
^
-t5091.scala:7: warning: type-checking the invocation of method foo checks if the named argument expression 'param = ...' is a valid assignment
-in the current scope. The resulting type inference error (see above) can be fixed by providing an explicit type in the local definition for param.
+t5091.scala:7: warning: failed to determine if 'param = ...' is a named argument or an assignment expression.
+an explicit type is required for the definition mentioned in the error message above.
val xxx = foo(param = null)
^
one warning found
diff --git a/test/files/neg/t7623.check b/test/files/neg/t7623.check
new file mode 100644
index 0000000000..db368dd369
--- /dev/null
+++ b/test/files/neg/t7623.check
@@ -0,0 +1,21 @@
+t7623.scala:19: warning: A repeated case parameter or extracted sequence should be matched only by a sequence wildcard (_*).
+ def f = "" match { case X(s) => }
+ ^
+t7623.scala:21: warning: A repeated case parameter or extracted sequence should be matched only by a sequence wildcard (_*).
+ def g = "" match { case X(s, t) => }
+ ^
+t7623.scala:23: warning: A repeated case parameter or extracted sequence should be matched only by a sequence wildcard (_*).
+ def h = "" match { case X(s, t, u @ _*) => }
+ ^
+t7623.scala:9: warning: A repeated case parameter or extracted sequence should be matched only by a sequence wildcard (_*).
+ def f = C("") match { case C(s) => }
+ ^
+t7623.scala:11: warning: A repeated case parameter or extracted sequence should be matched only by a sequence wildcard (_*).
+ def g = C("") match { case C(s, t) => }
+ ^
+t7623.scala:13: warning: A repeated case parameter or extracted sequence should be matched only by a sequence wildcard (_*).
+ def h = C("") match { case C(s, t, u @ _*) => }
+ ^
+error: No warnings can be incurred under -Xfatal-warnings.
+6 warnings found
+one error found
diff --git a/test/files/neg/t7623.flags b/test/files/neg/t7623.flags
new file mode 100644
index 0000000000..74c9e38323
--- /dev/null
+++ b/test/files/neg/t7623.flags
@@ -0,0 +1 @@
+-Xlint:stars-align -Xfatal-warnings
diff --git a/test/files/neg/t7623.scala b/test/files/neg/t7623.scala
new file mode 100644
index 0000000000..5c40f37bc1
--- /dev/null
+++ b/test/files/neg/t7623.scala
@@ -0,0 +1,38 @@
+
+
+case class C(s: String, xs: Int*)
+
+object X { def unapplySeq(a: Any): Option[(String, Seq[Int])] = Some("", List(1,2,3)) }
+
+// for case classes with varargs, avoid misaligned patterns
+trait Ctest {
+ def f = C("") match { case C(s) => }
+
+ def g = C("") match { case C(s, t) => }
+
+ def h = C("") match { case C(s, t, u @ _*) => }
+
+ def ok = C("") match { case C(s, u @ _*) => }
+}
+// for extractors that unapplySeq: Option[(Something, Seq[_])], avoid misaligned patterns
+trait Xtest {
+ def f = "" match { case X(s) => }
+
+ def g = "" match { case X(s, t) => }
+
+ def h = "" match { case X(s, t, u @ _*) => }
+
+ def ok = "" match { case X(s, u @ _*) => }
+}
+// for extractors that unapplySeq: Option[Seq[_]], anything goes
+trait Rtest {
+ val r = "(a+)".r
+
+ def f = "" match { case r(s) => }
+
+ def g = "" match { case r(s, t) => }
+
+ def h = "" match { case r(s, t, u @ _*) => }
+
+ def whatever = "" match { case r(u @ _*) => }
+}
diff --git a/test/files/neg/t8463.check b/test/files/neg/t8463.check
index 1a3eea2870..9aaacf8391 100644
--- a/test/files/neg/t8463.check
+++ b/test/files/neg/t8463.check
@@ -7,4 +7,21 @@ Note that implicit conversions are not applicable because they are ambiguous:
are possible conversion functions from Long to ?T[Long]
insertCell(Foo(5))
^
-one error found
+t8463.scala:5: error: no type parameters for method apply: (activity: T[Long])Test.Foo[T] in object Foo exist so that it can be applied to arguments (Long)
+ --- because ---
+argument expression's type is not compatible with formal parameter type;
+ found : Long
+ required: ?T[Long]
+ insertCell(Foo(5))
+ ^
+t8463.scala:5: error: type mismatch;
+ found : Long(5L)
+ required: T[Long]
+ insertCell(Foo(5))
+ ^
+t8463.scala:5: error: type mismatch;
+ found : Test.Foo[T]
+ required: Test.Foo[Test.Cell]
+ insertCell(Foo(5))
+ ^
+four errors found
diff --git a/test/files/neg/t8841.check b/test/files/neg/t8841.check
new file mode 100644
index 0000000000..ad525dc3f8
--- /dev/null
+++ b/test/files/neg/t8841.check
@@ -0,0 +1,9 @@
+t8841.scala:13: error: recursive value c needs type
+ val ambiguousName = c.ambiguousName
+ ^
+t8841.scala:12: warning: failed to determine if 'ambiguousName = ...' is a named argument or an assignment expression.
+an explicit type is required for the definition mentioned in the error message above.
+ val c = new Cell(ambiguousName = Some("bla"))
+ ^
+one warning found
+one error found
diff --git a/test/files/neg/t8841.scala b/test/files/neg/t8841.scala
new file mode 100644
index 0000000000..80430d997e
--- /dev/null
+++ b/test/files/neg/t8841.scala
@@ -0,0 +1,15 @@
+class Cell(val ambiguousName: Option[String])
+
+class Test {
+ def wrap(f: Any): Nothing = ???
+
+ wrap {
+ // the namer for these two ValDefs is created when typing the argument expression
+ // of wrap. This happens to be in a silent context (tryTypedApply). Therefore, the
+ // cyclic reference will not be thrown, but transformed into a NormalTypeError by
+ // `silent`. This requires different handling in NamesDefaults.
+
+ val c = new Cell(ambiguousName = Some("bla"))
+ val ambiguousName = c.ambiguousName
+ }
+}
diff --git a/test/files/neg/t9041.check b/test/files/neg/t9041.check
new file mode 100644
index 0000000000..669e9434e0
--- /dev/null
+++ b/test/files/neg/t9041.check
@@ -0,0 +1,4 @@
+t9041.scala:11: error: could not find implicit value for parameter cellSetter: CellSetter[scala.math.BigDecimal]
+ def setCell(cell: Cell, data: math.BigDecimal) { cell.setCellValue(data) }
+ ^
+one error found
diff --git a/test/files/neg/t9041.scala b/test/files/neg/t9041.scala
new file mode 100644
index 0000000000..2bdef0d3ae
--- /dev/null
+++ b/test/files/neg/t9041.scala
@@ -0,0 +1,17 @@
+// False negative test, requires overloading in Cell.
+
+trait Cell { def setCellValue(i: Int) = () ; def setCellValue(d: Double) = () }
+
+trait Nope {
+ def f = {
+ trait CellSetter[A] {
+ def setCell(cell: Cell, data: A): Unit
+ }
+ implicit val bigDecimalCellSetter = new CellSetter[math.BigDecimal]() {
+ def setCell(cell: Cell, data: math.BigDecimal) { cell.setCellValue(data) }
+ }
+ implicit class RichCell(cell: Cell) {
+ def setCellValue[A](data: A)(implicit cellSetter: CellSetter[A]) = cellSetter.setCell(cell, data)
+ }
+ }
+}
diff --git a/test/files/neg/t9093.check b/test/files/neg/t9093.check
new file mode 100644
index 0000000000..085a433f0b
--- /dev/null
+++ b/test/files/neg/t9093.check
@@ -0,0 +1,6 @@
+t9093.scala:3: error: polymorphic expression cannot be instantiated to expected type;
+ found : [C](f: C)Null
+ required: Unit
+ val x: Unit = apply2(0)/*(0)*/
+ ^
+one error found
diff --git a/test/files/neg/t9093.scala b/test/files/neg/t9093.scala
new file mode 100644
index 0000000000..d9922ad70e
--- /dev/null
+++ b/test/files/neg/t9093.scala
@@ -0,0 +1,5 @@
+object Main {
+ def apply2[C](fa: Any)(f: C) = null
+ val x: Unit = apply2(0)/*(0)*/
+}
+
diff --git a/test/files/pos/jesper.scala b/test/files/pos/jesper.scala
new file mode 100644
index 0000000000..82623e4a24
--- /dev/null
+++ b/test/files/pos/jesper.scala
@@ -0,0 +1,30 @@
+object Pair {
+ sealed trait Pair {
+ type First
+ type Second <: Pair
+ }
+
+ case class End() extends Pair {
+ type First = Nothing
+ type Second = End
+
+ def ::[T](v : T) : Cons[T, End] = Cons(v, this)
+ }
+
+ object End extends End()
+
+ final case class Cons[T1, T2 <: Pair](_1 : T1, _2 : T2) extends Pair {
+ type First = T1
+ type Second = T2
+
+ def ::[T](v : T) : Cons[T, Cons[T1, T2]] = Cons(v, this)
+ def find[T](implicit finder : Cons[T1, T2] => T) = finder(this)
+ }
+
+ implicit def findFirst[T1, T2 <: Pair] : Cons[T1, T2] => T1 = (p : Cons[T1, T2]) => p._1
+ implicit def findSecond[T, T1, T2 <: Pair](implicit finder : T2 => T) : Cons[T1, T2] => T = (p : Cons[T1, T2]) => finder(p._2)
+
+ val p : Cons[Int, Cons[Boolean, End]] = 10 :: false :: End
+// val x : Boolean = p.find[Boolean](findSecond(findFirst))
+ val x2 : Boolean = p.find[Boolean] // Doesn't compile
+}
diff --git a/test/files/pos/t8801.scala b/test/files/pos/t8801.scala
new file mode 100644
index 0000000000..695b456e12
--- /dev/null
+++ b/test/files/pos/t8801.scala
@@ -0,0 +1,21 @@
+sealed trait Nat {
+ type Prev <: Nat { type Succ = Nat.this.type }
+ type Succ <: Nat { type Prev = Nat.this.type }
+}
+
+object Nat {
+ object Zero extends Nat {
+ type Prev = Nothing
+ }
+
+ type _0 = Zero.type
+ type _1 = _0#Succ
+ type _2 = _1#Succ
+ type _3 = _2#Succ
+ type _4 = _3#Succ
+ type _5 = _4#Succ
+ type _6 = _5#Succ
+ type _7 = _6#Succ
+ type _8 = _7#Succ
+ type _9 = _8#Succ
+}
diff --git a/test/files/pos/t9050.scala b/test/files/pos/t9050.scala
new file mode 100644
index 0000000000..b1ab09f901
--- /dev/null
+++ b/test/files/pos/t9050.scala
@@ -0,0 +1,13 @@
+final class Mu[F](val value: Any) extends AnyVal {
+ def cata(f: F) {
+ // crash
+ ((y: Mu[F]) => y.cata(f))
+ // crash
+ def foo(x : Mu[F]) = x.cata(f)
+
+ // // okay
+ def x: Mu[F] = ???
+ (() => x.cata(f))
+ assert(true, cata(f))
+ }
+}
diff --git a/test/files/pos/t9086.scala b/test/files/pos/t9086.scala
new file mode 100644
index 0000000000..fba34ee226
--- /dev/null
+++ b/test/files/pos/t9086.scala
@@ -0,0 +1,8 @@
+class X[A](a: A)
+object Test {
+ implicit val ImplicitBoolean: Boolean = true
+ def local = {
+ implicit object X extends X({ implicitly[Boolean] ; "" })
+ implicitly[X[String]] // failed in 2.11.5
+ }
+}
diff --git a/test/files/pos/t9111-inliner-workaround.flags b/test/files/pos/t9111-inliner-workaround.flags
new file mode 100644
index 0000000000..63b5558cfd
--- /dev/null
+++ b/test/files/pos/t9111-inliner-workaround.flags
@@ -0,0 +1 @@
+-Ybackend:GenBCode -Yopt:l:classpath \ No newline at end of file
diff --git a/test/files/pos/t9111-inliner-workaround/A_1.java b/test/files/pos/t9111-inliner-workaround/A_1.java
new file mode 100644
index 0000000000..bc60b68ea6
--- /dev/null
+++ b/test/files/pos/t9111-inliner-workaround/A_1.java
@@ -0,0 +1,13 @@
+public class A_1 {
+ public static class T { }
+
+ public static class Inner {
+ public static class T { }
+
+ public void foo(T t) { }
+
+ public T t = null;
+
+ public class Deeper extends T { }
+ }
+}
diff --git a/test/files/pos/t9111-inliner-workaround/Test_1.scala b/test/files/pos/t9111-inliner-workaround/Test_1.scala
new file mode 100644
index 0000000000..1a00fff833
--- /dev/null
+++ b/test/files/pos/t9111-inliner-workaround/Test_1.scala
@@ -0,0 +1,10 @@
+object Test extends App {
+ println(new A_1.Inner())
+
+ // Accessing foo or Deeper triggers the error of SI-9111.
+ // However, when not referring to those definitions, compilation should
+ // succeed, also if the inliner is enabled.
+
+ // println(i.foo(null))
+ // new i.Deeper()
+}
diff --git a/test/files/pos/t9116.scala b/test/files/pos/t9116.scala
new file mode 100644
index 0000000000..16b04c2e6b
--- /dev/null
+++ b/test/files/pos/t9116.scala
@@ -0,0 +1,7 @@
+
+trait X {
+ List(1, 2, 3).toSet.subsets.map(_.toList) // ok now
+
+ List(1, 2, 3).toSet.subsets().map(_.toList) // now also
+ List(1, 2, 3).toSet.subsets(2).map(_.toList) // still ok
+}
diff --git a/test/files/pos/t9123.flags b/test/files/pos/t9123.flags
new file mode 100644
index 0000000000..c16e2f71dc
--- /dev/null
+++ b/test/files/pos/t9123.flags
@@ -0,0 +1 @@
+-optimize -Ydelambdafy:method
diff --git a/test/files/pos/t9123.scala b/test/files/pos/t9123.scala
new file mode 100644
index 0000000000..22d55b4351
--- /dev/null
+++ b/test/files/pos/t9123.scala
@@ -0,0 +1,10 @@
+trait Setting {
+ type T
+ def value: T
+}
+
+object Test {
+ def test(x: Some[Setting]) = x match {
+ case Some(dep) => Some(dep.value) map (_ => true)
+ }
+}
diff --git a/test/files/pos/t9135.scala b/test/files/pos/t9135.scala
new file mode 100644
index 0000000000..1e2c97baf9
--- /dev/null
+++ b/test/files/pos/t9135.scala
@@ -0,0 +1,16 @@
+
+class Free[A] {
+
+
+ this match {
+ case a @ Gosub() => gosub(a.a)(x => gosub(???)(???))
+ }
+ def gosub[A, B](a0: Free[A])(f0: A => Any): Free[B] = ???
+}
+
+
+
+ case class Gosub[B]() extends Free[B] {
+ type C
+ def a: Free[C] = ???
+ }
diff --git a/test/files/pos/t9157.scala b/test/files/pos/t9157.scala
new file mode 100644
index 0000000000..e178b5d84d
--- /dev/null
+++ b/test/files/pos/t9157.scala
@@ -0,0 +1,13 @@
+trait Flow[-In, +Out] {
+ type Repr[+O] <: Flow[In, O]
+ def map: Repr[String]
+}
+
+class Test {
+ // typechecking was exponentially slow wrt the number of projections here.
+ def slowFlow(
+ f: Flow[String,String]#Repr[String]#Repr[String]#Repr[String]#Repr[String]#Repr[String]#Repr[String]#Repr[String]#Repr[String]#Repr[String]#Repr[String]#Repr[String]
+ ) = {
+ f.map
+ }
+}
diff --git a/test/files/presentation/infix-completion.check b/test/files/presentation/infix-completion.check
new file mode 100644
index 0000000000..f62dc81d34
--- /dev/null
+++ b/test/files/presentation/infix-completion.check
@@ -0,0 +1,193 @@
+reload: Snippet.scala
+
+askTypeCompletion at Snippet.scala(1,34)
+================================================================================
+[response] askTypeCompletion at (1,34)
+retrieved 192 members
+[inaccessible] protected def integralNum: math.Numeric.DoubleAsIfIntegral.type
+[inaccessible] protected def num: math.Numeric.DoubleIsFractional.type
+[inaccessible] protected def ord: math.Ordering.Double.type
+[inaccessible] protected def unifiedPrimitiveEquals(x: Any): Boolean
+[inaccessible] protected def unifiedPrimitiveHashcode(): Int
+[inaccessible] protected[package lang] def clone(): Object
+[inaccessible] protected[package lang] def finalize(): Unit
+def !=(x: Byte): Boolean
+def !=(x: Char): Boolean
+def !=(x: Double): Boolean
+def !=(x: Float): Boolean
+def !=(x: Int): Boolean
+def !=(x: Long): Boolean
+def !=(x: Short): Boolean
+def %(x: Byte): Int
+def %(x: Char): Int
+def %(x: Double): Double
+def %(x: Float): Float
+def %(x: Int): Int
+def %(x: Long): Long
+def %(x: Short): Int
+def &(x: Byte): Int
+def &(x: Char): Int
+def &(x: Int): Int
+def &(x: Long): Long
+def &(x: Short): Int
+def *(x: Byte): Int
+def *(x: Char): Int
+def *(x: Double): Double
+def *(x: Float): Float
+def *(x: Int): Int
+def *(x: Long): Long
+def *(x: Short): Int
+def +(x: Byte): Int
+def +(x: Char): Int
+def +(x: Double): Double
+def +(x: Float): Float
+def +(x: Int): Int
+def +(x: Long): Long
+def +(x: Short): Int
+def +(x: String): String
+def -(x: Byte): Int
+def -(x: Char): Int
+def -(x: Double): Double
+def -(x: Float): Float
+def -(x: Int): Int
+def -(x: Long): Long
+def -(x: Short): Int
+def ->[B](y: B): (Int, B)
+def /(x: Byte): Int
+def /(x: Char): Int
+def /(x: Double): Double
+def /(x: Float): Float
+def /(x: Int): Int
+def /(x: Long): Long
+def /(x: Short): Int
+def <(x: Byte): Boolean
+def <(x: Char): Boolean
+def <(x: Double): Boolean
+def <(x: Float): Boolean
+def <(x: Int): Boolean
+def <(x: Long): Boolean
+def <(x: Short): Boolean
+def <<(x: Int): Int
+def <<(x: Long): Int
+def <=(x: Byte): Boolean
+def <=(x: Char): Boolean
+def <=(x: Double): Boolean
+def <=(x: Float): Boolean
+def <=(x: Int): Boolean
+def <=(x: Long): Boolean
+def <=(x: Short): Boolean
+def ==(x: Byte): Boolean
+def ==(x: Char): Boolean
+def ==(x: Double): Boolean
+def ==(x: Float): Boolean
+def ==(x: Int): Boolean
+def ==(x: Long): Boolean
+def ==(x: Short): Boolean
+def >(x: Byte): Boolean
+def >(x: Char): Boolean
+def >(x: Double): Boolean
+def >(x: Float): Boolean
+def >(x: Int): Boolean
+def >(x: Long): Boolean
+def >(x: Short): Boolean
+def >=(x: Byte): Boolean
+def >=(x: Char): Boolean
+def >=(x: Double): Boolean
+def >=(x: Float): Boolean
+def >=(x: Int): Boolean
+def >=(x: Long): Boolean
+def >=(x: Short): Boolean
+def >>(x: Int): Int
+def >>(x: Long): Int
+def >>>(x: Int): Int
+def >>>(x: Long): Int
+def ^(x: Byte): Int
+def ^(x: Char): Int
+def ^(x: Int): Int
+def ^(x: Long): Long
+def ^(x: Short): Int
+def byteValue(): Byte
+def ceil: Double
+def compare(y: Double): Int
+def compare(y: Long): Int
+def compareTo(that: Double): Int
+def compareTo(that: Long): Int
+def compareTo(x$1: Double): Int
+def compareTo(x$1: Long): Int
+def doubleValue(): Double
+def ensuring(cond: Boolean): Int
+def ensuring(cond: Boolean,msg: => Any): Int
+def ensuring(cond: Int => Boolean): Int
+def ensuring(cond: Int => Boolean,msg: => Any): Int
+def equals(x$1: Any): Boolean
+def floatValue(): Float
+def floor: Double
+def formatted(fmtstr: String): String
+def hashCode(): Int
+def intValue(): Int
+def isInfinite(): Boolean
+def isInfinity: Boolean
+def isNaN(): Boolean
+def isNegInfinity: Boolean
+def isPosInfinity: Boolean
+def isValidLong: Boolean
+def longValue(): Long
+def round: Long
+def shortValue(): Short
+def to(end: Double): Range.Partial[Double,scala.collection.immutable.NumericRange[Double]]
+def to(end: Double,step: Double): scala.collection.immutable.NumericRange.Inclusive[Double]
+def to(end: Long): scala.collection.immutable.NumericRange.Inclusive[Long]
+def to(end: Long,step: Long): scala.collection.immutable.NumericRange.Inclusive[Long]
+def toBinaryString: String
+def toByte: Byte
+def toChar: Char
+def toDegrees: Double
+def toDouble: Double
+def toFloat: Float
+def toHexString: String
+def toInt: Int
+def toLong: Long
+def toOctalString: String
+def toRadians: Double
+def toShort: Short
+def toString(): String
+def unary_+: Int
+def unary_-: Int
+def unary_~: Int
+def underlying(): AnyRef
+def until(end: Double): Range.Partial[Double,scala.collection.immutable.NumericRange[Double]]
+def until(end: Double,step: Double): scala.collection.immutable.NumericRange.Exclusive[Double]
+def until(end: Long): scala.collection.immutable.NumericRange.Exclusive[Long]
+def until(end: Long,step: Long): scala.collection.immutable.NumericRange.Exclusive[Long]
+def |(x: Byte): Int
+def |(x: Char): Int
+def |(x: Int): Int
+def |(x: Long): Long
+def |(x: Short): Int
+def →[B](y: B): (Int, B)
+final def !=(x$1: Any): Boolean
+final def ##(): Int
+final def ==(x$1: Any): Boolean
+final def asInstanceOf[T0]: T0
+final def eq(x$1: AnyRef): Boolean
+final def isInstanceOf[T0]: Boolean
+final def ne(x$1: AnyRef): Boolean
+final def notify(): Unit
+final def notifyAll(): Unit
+final def synchronized[T0](x$1: T0): T0
+final def wait(): Unit
+final def wait(x$1: Long): Unit
+final def wait(x$1: Long,x$2: Int): Unit
+override def abs: Double
+override def isValidByte: Boolean
+override def isValidChar: Boolean
+override def isValidInt: Boolean
+override def isValidShort: Boolean
+override def isWhole(): Boolean
+override def max(that: Double): Double
+override def max(that: Long): Long
+override def min(that: Double): Double
+override def min(that: Long): Long
+override def signum: Int
+private[this] val self: Double
+================================================================================
diff --git a/test/files/presentation/infix-completion/Runner.scala b/test/files/presentation/infix-completion/Runner.scala
new file mode 100644
index 0000000000..1c03e3d5ba
--- /dev/null
+++ b/test/files/presentation/infix-completion/Runner.scala
@@ -0,0 +1,3 @@
+import scala.tools.nsc.interactive.tests._
+
+object Test extends InteractiveTest
diff --git a/test/files/presentation/infix-completion/src/Snippet.scala b/test/files/presentation/infix-completion/src/Snippet.scala
new file mode 100644
index 0000000000..7e03c486ba
--- /dev/null
+++ b/test/files/presentation/infix-completion/src/Snippet.scala
@@ -0,0 +1 @@
+object Snippet{val x = 123; 1 + 1./*!*/}
diff --git a/test/files/presentation/infix-completion2.check b/test/files/presentation/infix-completion2.check
new file mode 100644
index 0000000000..5c69cd84cb
--- /dev/null
+++ b/test/files/presentation/infix-completion2.check
@@ -0,0 +1,211 @@
+reload: Snippet.scala
+
+askTypeCompletion at Snippet.scala(1,34)
+================================================================================
+[response] askTypeCompletion at (1,34)
+retrieved 211 members
+[inaccessible] protected def integralNum: math.Numeric.DoubleAsIfIntegral.type
+[inaccessible] protected def num: math.Numeric.DoubleIsFractional.type
+[inaccessible] protected def ord: math.Ordering.Double.type
+[inaccessible] protected def unifiedPrimitiveEquals(x: Any): Boolean
+[inaccessible] protected def unifiedPrimitiveHashcode(): Int
+[inaccessible] protected[package lang] def clone(): Object
+[inaccessible] protected[package lang] def finalize(): Unit
+def !=(x: Byte): Boolean
+def !=(x: Char): Boolean
+def !=(x: Double): Boolean
+def !=(x: Float): Boolean
+def !=(x: Int): Boolean
+def !=(x: Long): Boolean
+def !=(x: Short): Boolean
+def %(x: Byte): Int
+def %(x: Char): Int
+def %(x: Double): Double
+def %(x: Float): Float
+def %(x: Int): Int
+def %(x: Long): Long
+def %(x: Short): Int
+def &(x: Byte): Int
+def &(x: Char): Int
+def &(x: Int): Int
+def &(x: Long): Long
+def &(x: Short): Int
+def *(x: Byte): Int
+def *(x: Char): Int
+def *(x: Double): Double
+def *(x: Float): Float
+def *(x: Int): Int
+def *(x: Long): Long
+def *(x: Short): Int
+def +(x: Byte): Int
+def +(x: Char): Int
+def +(x: Double): Double
+def +(x: Float): Float
+def +(x: Int): Int
+def +(x: Long): Long
+def +(x: Short): Int
+def +(x: String): String
+def -(x: Byte): Int
+def -(x: Char): Int
+def -(x: Double): Double
+def -(x: Float): Float
+def -(x: Int): Int
+def -(x: Long): Long
+def -(x: Short): Int
+def ->[B](y: B): (Int, B)
+def /(x: Byte): Int
+def /(x: Char): Int
+def /(x: Double): Double
+def /(x: Float): Float
+def /(x: Int): Int
+def /(x: Long): Long
+def /(x: Short): Int
+def <(x: Byte): Boolean
+def <(x: Char): Boolean
+def <(x: Double): Boolean
+def <(x: Float): Boolean
+def <(x: Int): Boolean
+def <(x: Long): Boolean
+def <(x: Short): Boolean
+def <<(x: Int): Int
+def <<(x: Long): Int
+def <=(x: Byte): Boolean
+def <=(x: Char): Boolean
+def <=(x: Double): Boolean
+def <=(x: Float): Boolean
+def <=(x: Int): Boolean
+def <=(x: Long): Boolean
+def <=(x: Short): Boolean
+def ==(x: Byte): Boolean
+def ==(x: Char): Boolean
+def ==(x: Double): Boolean
+def ==(x: Float): Boolean
+def ==(x: Int): Boolean
+def ==(x: Long): Boolean
+def ==(x: Short): Boolean
+def >(x: Byte): Boolean
+def >(x: Char): Boolean
+def >(x: Double): Boolean
+def >(x: Float): Boolean
+def >(x: Int): Boolean
+def >(x: Long): Boolean
+def >(x: Short): Boolean
+def >=(x: Byte): Boolean
+def >=(x: Char): Boolean
+def >=(x: Double): Boolean
+def >=(x: Float): Boolean
+def >=(x: Int): Boolean
+def >=(x: Long): Boolean
+def >=(x: Short): Boolean
+def >>(x: Int): Int
+def >>(x: Long): Int
+def >>>(x: Int): Int
+def >>>(x: Long): Int
+def ^(x: Byte): Int
+def ^(x: Char): Int
+def ^(x: Int): Int
+def ^(x: Long): Long
+def ^(x: Short): Int
+def byteValue(): Byte
+def ceil: Double
+def compare(y: Double): Int
+def compare(y: Float): Int
+def compare(y: Int): Int
+def compare(y: Long): Int
+def compareTo(that: Double): Int
+def compareTo(that: Float): Int
+def compareTo(that: Int): Int
+def compareTo(that: Long): Int
+def compareTo(x$1: Double): Int
+def compareTo(x$1: Float): Int
+def compareTo(x$1: Integer): Int
+def compareTo(x$1: Long): Int
+def doubleValue(): Double
+def ensuring(cond: Boolean): Int
+def ensuring(cond: Boolean,msg: => Any): Int
+def ensuring(cond: Int => Boolean): Int
+def ensuring(cond: Int => Boolean,msg: => Any): Int
+def equals(x$1: Any): Boolean
+def floatValue(): Float
+def floor: Double
+def formatted(fmtstr: String): String
+def hashCode(): Int
+def intValue(): Int
+def isInfinite(): Boolean
+def isInfinity: Boolean
+def isNaN(): Boolean
+def isNegInfinity: Boolean
+def isPosInfinity: Boolean
+def isValidLong: Boolean
+def longValue(): Long
+def round: Long
+def shortValue(): Short
+def to(end: Double): Range.Partial[Double,scala.collection.immutable.NumericRange[Double]]
+def to(end: Double,step: Double): scala.collection.immutable.NumericRange.Inclusive[Double]
+def to(end: Float): Range.Partial[Float,scala.collection.immutable.NumericRange[Float]]
+def to(end: Float,step: Float): scala.collection.immutable.NumericRange.Inclusive[Float]
+def to(end: Int): scala.collection.immutable.Range.Inclusive
+def to(end: Int,step: Int): scala.collection.immutable.Range.Inclusive
+def to(end: Long): scala.collection.immutable.NumericRange.Inclusive[Long]
+def to(end: Long,step: Long): scala.collection.immutable.NumericRange.Inclusive[Long]
+def toBinaryString: String
+def toByte: Byte
+def toChar: Char
+def toDegrees: Double
+def toDouble: Double
+def toFloat: Float
+def toHexString: String
+def toInt: Int
+def toLong: Long
+def toOctalString: String
+def toRadians: Double
+def toShort: Short
+def toString(): String
+def unary_+: Int
+def unary_-: Int
+def unary_~: Int
+def underlying(): AnyRef
+def until(end: Double): Range.Partial[Double,scala.collection.immutable.NumericRange[Double]]
+def until(end: Double,step: Double): scala.collection.immutable.NumericRange.Exclusive[Double]
+def until(end: Float): Range.Partial[Float,scala.collection.immutable.NumericRange[Float]]
+def until(end: Float,step: Float): scala.collection.immutable.NumericRange.Exclusive[Float]
+def until(end: Int): scala.collection.immutable.Range
+def until(end: Int,step: Int): scala.collection.immutable.Range
+def until(end: Long): scala.collection.immutable.NumericRange.Exclusive[Long]
+def until(end: Long,step: Long): scala.collection.immutable.NumericRange.Exclusive[Long]
+def |(x: Byte): Int
+def |(x: Char): Int
+def |(x: Int): Int
+def |(x: Long): Long
+def |(x: Short): Int
+def →[B](y: B): (Int, B)
+final def !=(x$1: Any): Boolean
+final def ##(): Int
+final def ==(x$1: Any): Boolean
+final def asInstanceOf[T0]: T0
+final def eq(x$1: AnyRef): Boolean
+final def isInstanceOf[T0]: Boolean
+final def ne(x$1: AnyRef): Boolean
+final def notify(): Unit
+final def notifyAll(): Unit
+final def synchronized[T0](x$1: T0): T0
+final def wait(): Unit
+final def wait(x$1: Long): Unit
+final def wait(x$1: Long,x$2: Int): Unit
+override def abs: Double
+override def isValidByte: Boolean
+override def isValidChar: Boolean
+override def isValidInt: Boolean
+override def isValidShort: Boolean
+override def isWhole(): Boolean
+override def max(that: Double): Double
+override def max(that: Float): Float
+override def max(that: Int): Int
+override def max(that: Long): Long
+override def min(that: Double): Double
+override def min(that: Float): Float
+override def min(that: Int): Int
+override def min(that: Long): Long
+override def signum: Int
+private[this] val self: Double
+================================================================================
diff --git a/test/files/presentation/infix-completion2/Runner.scala b/test/files/presentation/infix-completion2/Runner.scala
new file mode 100644
index 0000000000..1c03e3d5ba
--- /dev/null
+++ b/test/files/presentation/infix-completion2/Runner.scala
@@ -0,0 +1,3 @@
+import scala.tools.nsc.interactive.tests._
+
+object Test extends InteractiveTest
diff --git a/test/files/presentation/infix-completion2/src/Snippet.scala b/test/files/presentation/infix-completion2/src/Snippet.scala
new file mode 100644
index 0000000000..4eb8c24a2e
--- /dev/null
+++ b/test/files/presentation/infix-completion2/src/Snippet.scala
@@ -0,0 +1 @@
+object Snippet{val x = 123; 1 + x./*!*/}
diff --git a/test/files/run/bcodeInlinerMixed.flags b/test/files/run/bcodeInlinerMixed.flags
new file mode 100644
index 0000000000..63b5558cfd
--- /dev/null
+++ b/test/files/run/bcodeInlinerMixed.flags
@@ -0,0 +1 @@
+-Ybackend:GenBCode -Yopt:l:classpath \ No newline at end of file
diff --git a/test/files/run/bcodeInlinerMixed/A_1.java b/test/files/run/bcodeInlinerMixed/A_1.java
new file mode 100644
index 0000000000..44d7d88eeb
--- /dev/null
+++ b/test/files/run/bcodeInlinerMixed/A_1.java
@@ -0,0 +1,3 @@
+public class A_1 {
+ public static final int bar() { return 100; }
+}
diff --git a/test/files/run/bcodeInlinerMixed/B_1.scala b/test/files/run/bcodeInlinerMixed/B_1.scala
new file mode 100644
index 0000000000..2aadeccb82
--- /dev/null
+++ b/test/files/run/bcodeInlinerMixed/B_1.scala
@@ -0,0 +1,20 @@
+// Partest does proper mixed compilation:
+// 1. scalac *.scala *.java
+// 2. javac *.java
+// 3. scalc *.scala
+//
+// In the second scalc round, the classfile for A_1 is on the classpath.
+// Therefore the inliner has access to the bytecode of `bar`, which means
+// it can verify that the invocation to `bar` can be safely inlined.
+//
+// So both callsites of `flop` are inlined.
+//
+// In a single mixed compilation, `flop` cannot be inlined, see JUnit InlinerTest.scala, def mixedCompilationNoInline.
+
+class B {
+ @inline final def flop = A_1.bar
+ def g = flop
+}
+class C {
+ def h(b: B) = b.flop
+}
diff --git a/test/files/run/bcodeInlinerMixed/Test.scala b/test/files/run/bcodeInlinerMixed/Test.scala
new file mode 100644
index 0000000000..c8c7a9fe2a
--- /dev/null
+++ b/test/files/run/bcodeInlinerMixed/Test.scala
@@ -0,0 +1,16 @@
+import scala.tools.partest.{BytecodeTest, ASMConverters}
+import ASMConverters._
+
+object Test extends BytecodeTest {
+ def show: Unit = {
+ val gIns = instructionsFromMethod(getMethod(loadClassNode("B"), "g"))
+ val hIns = instructionsFromMethod(getMethod(loadClassNode("C"), "h"))
+ // val invocation = Invoke(INVOKESTATIC, A_1, bar, ()I, false)
+ for (i <- List(gIns, hIns)) {
+ assert(i exists {
+ case Invoke(_, _, "bar", "()I", _) => true
+ case _ => false
+ }, i mkString "\n")
+ }
+ }
+}
diff --git a/test/files/run/bitsets.check b/test/files/run/bitsets.check
index 41c2ccdcb8..c24fd6238f 100644
--- a/test/files/run/bitsets.check
+++ b/test/files/run/bitsets.check
@@ -1,3 +1,4 @@
+warning: there were three deprecation warnings; re-run with -deprecation for details
ms0 = BitSet(2)
ms1 = BitSet(2)
ms2 = BitSet(2)
diff --git a/test/files/run/colltest1.scala b/test/files/run/colltest1.scala
index e0ec378585..de8780a050 100644
--- a/test/files/run/colltest1.scala
+++ b/test/files/run/colltest1.scala
@@ -1,5 +1,5 @@
/*
- * filter: inliner warnings; re-run with -Yinline-warnings for details
+ * filter: inliner warnings; re-run with
*/
import scala.collection._
import scala.language.postfixOps
diff --git a/test/files/run/compiler-asSeenFrom.scala b/test/files/run/compiler-asSeenFrom.scala
index 677dd40ddc..a60c2e8925 100644
--- a/test/files/run/compiler-asSeenFrom.scala
+++ b/test/files/run/compiler-asSeenFrom.scala
@@ -1,5 +1,5 @@
/*
- * filter: inliner warning; re-run with -Yinline-warnings for details
+ * filter: inliner warning; re-run with
*/
import scala.tools.nsc._
import scala.tools.partest.DirectTest
diff --git a/test/files/run/existentials-in-compiler.scala b/test/files/run/existentials-in-compiler.scala
index dfc7048b31..e516eddf95 100644
--- a/test/files/run/existentials-in-compiler.scala
+++ b/test/files/run/existentials-in-compiler.scala
@@ -1,5 +1,5 @@
/*
- * filter: inliner warnings; re-run with -Yinline-warnings for details
+ * filter: inliner warnings; re-run with
*/
import scala.tools.nsc._
import scala.tools.partest.CompilerTest
diff --git a/test/files/run/is-valid-num.scala b/test/files/run/is-valid-num.scala
index 4ab2fac8dd..156121cab5 100644
--- a/test/files/run/is-valid-num.scala
+++ b/test/files/run/is-valid-num.scala
@@ -1,5 +1,5 @@
/*
- * filter: inliner warnings; re-run with -Yinline-warnings for details
+ * filter: inliner warnings; re-run with
*/
object Test {
def x = BigInt("10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")
diff --git a/test/files/run/iterator-from.scala b/test/files/run/iterator-from.scala
index e2ca5864ea..e7ba1aeb28 100644
--- a/test/files/run/iterator-from.scala
+++ b/test/files/run/iterator-from.scala
@@ -1,5 +1,5 @@
/* This file tests iteratorFrom, keysIteratorFrom, and valueIteratorFrom on various sorted sets and maps
- * filter: inliner warnings; re-run with -Yinline-warnings for details
+ * filter: inliner warnings; re-run with
*/
import scala.util.{Random => R}
diff --git a/test/files/run/macroPlugins-enterStats.check b/test/files/run/macroPlugins-enterStats.check
new file mode 100644
index 0000000000..133b1ae1af
--- /dev/null
+++ b/test/files/run/macroPlugins-enterStats.check
@@ -0,0 +1,30 @@
+[[syntax trees at end of typer]] // newSource1.scala
+package <empty> {
+ class C extends scala.AnyRef {
+ def <init>(): C = {
+ C.super.<init>();
+ ()
+ };
+ def x: Int = 2;
+ def xmacroPlugin1: Nothing = scala.this.Predef.???;
+ def xmacroPlugin2: Nothing = scala.this.Predef.???;
+ def xmacroPlugin2macroPlugin1: Nothing = scala.this.Predef.???;
+ def y: Int = 3;
+ def ymacroPlugin1: Nothing = scala.this.Predef.???;
+ def ymacroPlugin2: Nothing = scala.this.Predef.???;
+ def ymacroPlugin2macroPlugin1: Nothing = scala.this.Predef.???
+ }
+}
+
+macroPlugin2:enterStat(class C extends scala.AnyRef { def <init>() = { super.<init>(); () }; def x = 2; def y = 3 })
+macroPlugin1:enterStat(class C extends scala.AnyRef { def <init>() = { super.<init>(); () }; def x = 2; def y = 3 })
+macroPlugin2:enterStat(def <init>() = { super.<init>(); () })
+macroPlugin2:enterStat(def x = 2)
+macroPlugin2:enterStat(def y = 3)
+macroPlugin1:enterStat(def <init>() = { super.<init>(); () })
+macroPlugin1:enterStat(def x = 2)
+macroPlugin1:enterStat(def xmacroPlugin2 = $qmark$qmark$qmark)
+macroPlugin1:enterStat(def y = 3)
+macroPlugin1:enterStat(def ymacroPlugin2 = $qmark$qmark$qmark)
+macroPlugin2:enterStat(super.<init>())
+macroPlugin1:enterStat(super.<init>())
diff --git a/test/files/run/macroPlugins-enterStats.scala b/test/files/run/macroPlugins-enterStats.scala
new file mode 100644
index 0000000000..917233e990
--- /dev/null
+++ b/test/files/run/macroPlugins-enterStats.scala
@@ -0,0 +1,50 @@
+import scala.tools.partest._
+import scala.tools.nsc._
+
+object Test extends DirectTest {
+ override def extraSettings: String = "-usejavacp -Xprint:typer"
+
+ def code = """
+ class C {
+ def x = 2
+ def y = 3
+ }
+ """.trim
+
+ def show() {
+ val global = newCompiler()
+ import global._
+ import analyzer._
+
+ val output = collection.mutable.ListBuffer[String]()
+ def log(what: String) = output += what.replace(String.format("%n"), " ")
+
+ def logEnterStat(pluginName: String, stat: Tree): Unit = log(s"$pluginName:enterStat($stat)")
+ def deriveStat(pluginName: String, typer: Typer, stat: Tree): List[Tree] = stat match {
+ case DefDef(mods, name, Nil, Nil, TypeTree(), body) =>
+ val derived = DefDef(NoMods, TermName(name + pluginName), Nil, Nil, TypeTree(), Ident(TermName("$qmark$qmark$qmark")))
+ newNamer(typer.context).enterSym(derived)
+ List(derived)
+ case _ =>
+ Nil
+ }
+
+ object macroPlugin1 extends MacroPlugin {
+ override def pluginsEnterStats(typer: Typer, stats: List[Tree]): List[Tree] = {
+ stats.foreach(stat => logEnterStat("macroPlugin1", stat))
+ stats.flatMap(stat => stat +: deriveStat("macroPlugin1", typer, stat))
+ }
+ }
+ object macroPlugin2 extends MacroPlugin {
+ override def pluginsEnterStats(typer: Typer, stats: List[Tree]): List[Tree] = {
+ stats.foreach(stat => logEnterStat("macroPlugin2", stat))
+ stats.flatMap(stat => stat +: deriveStat("macroPlugin2", typer, stat))
+ }
+ }
+
+ addMacroPlugin(macroPlugin1)
+ addMacroPlugin(macroPlugin2)
+ compileString(global)(code)
+ println(output.mkString("\n"))
+ }
+}
diff --git a/test/files/run/mapConserve.scala b/test/files/run/mapConserve.scala
index f52af3b9f4..c17754283a 100644
--- a/test/files/run/mapConserve.scala
+++ b/test/files/run/mapConserve.scala
@@ -1,5 +1,5 @@
/*
- * filter: inliner warnings; re-run with -Yinline-warnings for details
+ * filter: inliner warnings; re-run with
*/
import scala.annotation.tailrec
import scala.collection.mutable.ListBuffer
diff --git a/test/files/run/pc-conversions.scala b/test/files/run/pc-conversions.scala
index 5fecac9d94..d4ae305aa7 100644
--- a/test/files/run/pc-conversions.scala
+++ b/test/files/run/pc-conversions.scala
@@ -1,5 +1,5 @@
/*
- * filter: inliner warning; re-run with -Yinline-warnings for details
+ * filter: inliner warning; re-run with
*/
import collection._
diff --git a/test/files/run/settings-parse.scala b/test/files/run/settings-parse.scala
index 2754feb972..8d83caf68f 100644
--- a/test/files/run/settings-parse.scala
+++ b/test/files/run/settings-parse.scala
@@ -3,9 +3,8 @@ import scala.language.postfixOps
import scala.tools.nsc._
object Test {
- val tokens = List("", "-deprecation", "foo.scala")
- val subsets = tokens.toSet.subsets.toList
- val permutations0 = subsets.flatMap(_.toList.permutations).distinct
+ val tokens = "" :: "-deprecation" :: "foo.scala" :: Nil
+ val permutations0 = tokens.toSet.subsets.flatMap(_.toList.permutations).toList.distinct
def runWithCp(cp: String) = {
val permutations = permutations0 flatMap ("-cp CPTOKEN" :: _ permutations)
diff --git a/test/files/run/stringinterpolation_macro-run.scala b/test/files/run/stringinterpolation_macro-run.scala
index e18375d521..ae7c0e5d7a 100644
--- a/test/files/run/stringinterpolation_macro-run.scala
+++ b/test/files/run/stringinterpolation_macro-run.scala
@@ -1,5 +1,5 @@
/*
- * filter: inliner warnings; re-run with -Yinline-warnings for details
+ * filter: inliner warnings; re-run with
*/
object Test extends App {
diff --git a/test/files/run/synchronized.check b/test/files/run/synchronized.check
index eab191b4ed..9add05ea0c 100644
--- a/test/files/run/synchronized.check
+++ b/test/files/run/synchronized.check
@@ -1,4 +1,8 @@
+#partest !-Ybackend:GenBCode
warning: there were 14 inliner warnings; re-run with -Yinline-warnings for details
+#partest -Ybackend:GenBCode
+warning: there were 14 inliner warnings; re-run with -Yopt-warnings for details
+#partest
.|. c1.f1: OK
.|. c1.fi: OK
.|... c1.fv: OK
diff --git a/test/files/run/t6502.check b/test/files/run/t6502.check
deleted file mode 100644
index 95d36ee221..0000000000
--- a/test/files/run/t6502.check
+++ /dev/null
@@ -1,8 +0,0 @@
-test1 res1: true
-test1 res2: true
-test2 res1: true
-test2 res2: true
-test3 res1: true
-test3 res2: true
-test4 res1: true
-test4 res2: true
diff --git a/test/files/run/t6502.scala b/test/files/run/t6502.scala
index 4ce034a482..52fabef6b8 100644
--- a/test/files/run/t6502.scala
+++ b/test/files/run/t6502.scala
@@ -46,6 +46,12 @@ object Test extends StoreReporterDirectTest {
}
}"""
+ def app6 = """
+ package test6
+ class A extends Test { println("created test6.A") }
+ class Z extends Test { println("created test6.Z") }
+ trait Test"""
+
def test1(): Unit = {
val jar = "test1.jar"
compileCode(app1, jar)
@@ -53,11 +59,12 @@ object Test extends StoreReporterDirectTest {
val codeToRun = toCodeInSeparateLines(s":require ${testOutput.path}/$jar", "test.Test.test()")
val output = ILoop.run(codeToRun, settings)
val lines = output.split("\n")
- val res1 = lines(4).contains("Added") && lines(4).contains("test1.jar")
- val res2 = lines(lines.length-3).contains("testing...")
-
- println(s"test1 res1: $res1")
- println(s"test1 res2: $res2")
+ assert {
+ lines(4).contains("Added") && lines(4).contains("test1.jar")
+ }
+ assert {
+ lines(lines.length-3).contains("testing...")
+ }
}
def test2(): Unit = {
@@ -69,11 +76,12 @@ object Test extends StoreReporterDirectTest {
val codeToRun = toCodeInSeparateLines(s":require ${testOutput.path}/$jar1", s":require ${testOutput.path}/$jar2")
val output = ILoop.run(codeToRun, settings)
val lines = output.split("\n")
- val res1 = lines(4).contains("Added") && lines(4).contains("test1.jar")
- val res2 = lines(lines.length-3).contains("test2.jar") && lines(lines.length-3).contains("existing classpath entries conflict")
-
- println(s"test2 res1: $res1")
- println(s"test2 res2: $res2")
+ assert {
+ lines(4).contains("Added") && lines(4).contains("test1.jar")
+ }
+ assert {
+ lines(lines.length-3).contains("test2.jar") && lines(lines.length-3).contains("existing classpath entries conflict")
+ }
}
def test3(): Unit = {
@@ -85,11 +93,12 @@ object Test extends StoreReporterDirectTest {
val codeToRun = toCodeInSeparateLines(s":require ${testOutput.path}/$jar1", s":require ${testOutput.path}/$jar3", "test.Test3.test()")
val output = ILoop.run(codeToRun, settings)
val lines = output.split("\n")
- val res1 = lines(4).contains("Added") && lines(4).contains("test1.jar")
- val res2 = lines(lines.length-3).contains("new object in existing package")
-
- println(s"test3 res1: $res1")
- println(s"test3 res2: $res2")
+ assert {
+ lines(4).contains("Added") && lines(4).contains("test1.jar")
+ }
+ assert {
+ lines(lines.length-3).contains("new object in existing package")
+ }
}
def test4(): Unit = {
@@ -98,11 +107,30 @@ object Test extends StoreReporterDirectTest {
val codeToRun = toCodeInSeparateLines(s":require ${testOutput.path}/$jar1", s":require ${testOutput.path}/$jar1")
val output = ILoop.run(codeToRun, settings)
val lines = output.split("\n")
- val res1 = lines(4).contains("Added") && lines(4).contains("test1.jar")
- val res2 = lines(lines.length-3).contains("test1.jar") && lines(lines.length-3).contains("existing classpath entries conflict")
+ assert {
+ lines(4).contains("Added") && lines(4).contains("test1.jar")
+ }
+ assert {
+ lines(lines.length-3).contains("test1.jar") && lines(lines.length-3).contains("existing classpath entries conflict")
+ }
+ }
- println(s"test4 res1: $res1")
- println(s"test4 res2: $res2")
+ def test5(): Unit = {
+ val codeToRun = ":require /does/not/exist.jar"
+ val output = ILoop.run(codeToRun, settings)
+ assert(!output.contains("NullPointerException"), output)
+ assert(output.contains("Cannot load '/does/not/exist.jar'"), output)
+ }
+
+ def test6(): Unit = {
+ // Avoid java.lang.NoClassDefFoundError triggered by the old appoach of using a Java
+ // classloader to parse .class files in order to read their names.
+ val jar = "test6.jar"
+ compileCode(app6, jar)
+ val codeToRun = toCodeInSeparateLines(s":require ${testOutput.path}/$jar", "import test6._; new A; new Z")
+ val output = ILoop.run(codeToRun, settings)
+ assert(output.contains("created test6.A"), output)
+ assert(output.contains("created test6.Z"), output)
}
def show(): Unit = {
@@ -110,7 +138,9 @@ object Test extends StoreReporterDirectTest {
test2()
test3()
test4()
+ test5()
+ test6()
}
- def toCodeInSeparateLines(lines: String*): String = lines.map(_ + "\n").mkString
+ def toCodeInSeparateLines(lines: String*): String = lines mkString "\n"
}
diff --git a/test/files/run/t7096.scala b/test/files/run/t7096.scala
index 872562dd4d..f723d70abe 100644
--- a/test/files/run/t7096.scala
+++ b/test/files/run/t7096.scala
@@ -1,5 +1,5 @@
/*
- * filter: inliner warning; re-run with -Yinline-warnings for details
+ * filter: inliner warning; re-run with
*/
import scala.tools.partest._
import scala.tools.nsc._
diff --git a/test/files/run/t7582.check b/test/files/run/t7582.check
index cd951d8d4f..2a11210000 100644
--- a/test/files/run/t7582.check
+++ b/test/files/run/t7582.check
@@ -1,2 +1,6 @@
+#partest !-Ybackend:GenBCode
warning: there was one inliner warning; re-run with -Yinline-warnings for details
+#partest -Ybackend:GenBCode
+warning: there was one inliner warning; re-run with -Yopt-warnings for details
+#partest
2
diff --git a/test/files/run/t7582b.check b/test/files/run/t7582b.check
index cd951d8d4f..2a11210000 100644
--- a/test/files/run/t7582b.check
+++ b/test/files/run/t7582b.check
@@ -1,2 +1,6 @@
+#partest !-Ybackend:GenBCode
warning: there was one inliner warning; re-run with -Yinline-warnings for details
+#partest -Ybackend:GenBCode
+warning: there was one inliner warning; re-run with -Yopt-warnings for details
+#partest
2
diff --git a/test/files/run/t7974.check b/test/files/run/t7974.check
index d8152d3286..4eae5eb152 100644
--- a/test/files/run/t7974.check
+++ b/test/files/run/t7974.check
@@ -1,19 +1,3 @@
-public class Symbols {
-
-
-
-
- // access flags 0x12
- private final Lscala/Symbol; someSymbol3
-
- // access flags 0xA
- private static Lscala/Symbol; symbol$1
-
- // access flags 0xA
- private static Lscala/Symbol; symbol$2
-
- // access flags 0xA
- private static Lscala/Symbol; symbol$3
// access flags 0x9
public static <clinit>()V
@@ -33,6 +17,7 @@ public class Symbols {
MAXSTACK = 2
MAXLOCALS = 0
+
// access flags 0x1
public someSymbol1()Lscala/Symbol;
GETSTATIC Symbols.symbol$1 : Lscala/Symbol;
@@ -40,6 +25,7 @@ public class Symbols {
MAXSTACK = 1
MAXLOCALS = 1
+
// access flags 0x1
public someSymbol2()Lscala/Symbol;
GETSTATIC Symbols.symbol$2 : Lscala/Symbol;
@@ -47,6 +33,7 @@ public class Symbols {
MAXSTACK = 1
MAXLOCALS = 1
+
// access flags 0x1
public sameSymbol1()Lscala/Symbol;
GETSTATIC Symbols.symbol$1 : Lscala/Symbol;
@@ -54,6 +41,7 @@ public class Symbols {
MAXSTACK = 1
MAXLOCALS = 1
+
// access flags 0x1
public someSymbol3()Lscala/Symbol;
ALOAD 0
@@ -62,6 +50,7 @@ public class Symbols {
MAXSTACK = 1
MAXLOCALS = 1
+
// access flags 0x1
public <init>()V
ALOAD 0
@@ -72,4 +61,4 @@ public class Symbols {
RETURN
MAXSTACK = 2
MAXLOCALS = 1
-}
+
diff --git a/test/files/run/t7974/Test.scala b/test/files/run/t7974/Test.scala
index 29d2b9cb64..296ec32ee2 100644
--- a/test/files/run/t7974/Test.scala
+++ b/test/files/run/t7974/Test.scala
@@ -1,20 +1,14 @@
-import java.io.PrintWriter;
+import java.io.PrintWriter
import scala.tools.partest.BytecodeTest
+import scala.tools.nsc.backend.jvm.AsmUtils
import scala.tools.asm.util._
import scala.tools.nsc.util.stringFromWriter
+import scala.collection.convert.decorateAsScala._
object Test extends BytecodeTest {
def show {
val classNode = loadClassNode("Symbols", skipDebugInfo = true)
- val textifier = new Textifier
- classNode.accept(new TraceClassVisitor(null, textifier, null))
-
- val classString = stringFromWriter(w => textifier.print(w))
- val result =
- classString.split('\n')
- .dropWhile(elem => elem != "public class Symbols {")
- .filterNot(elem => elem.startsWith(" @Lscala/reflect/ScalaSignature") || elem.startsWith(" ATTRIBUTE ScalaSig"))
- result foreach println
+ classNode.methods.asScala.foreach(m => println(AsmUtils.textify(m)))
}
}
diff --git a/test/files/run/t9097.scala b/test/files/run/t9097.scala
new file mode 100644
index 0000000000..d2bf55fc44
--- /dev/null
+++ b/test/files/run/t9097.scala
@@ -0,0 +1,34 @@
+import scala.tools.partest._
+import java.io.{Console => _, _}
+
+object Test extends StoreReporterDirectTest {
+
+ override def extraSettings: String = List(
+ "-usejavacp",
+ "-Xfatal-warnings",
+ "-Ybackend:GenBCode",
+ "-Ydelambdafy:method",
+ "-Xprint:delambdafy",
+ s"-d ${testOutput.path}"
+ ) mkString " "
+
+ override def code = """package o
+ |package a {
+ | class C {
+ | def hihi = List(1,2).map(_ * 2)
+ | }
+ |}
+ |package object a {
+ | def f = 1
+ |}
+ |""".stripMargin.trim
+
+ override def show(): Unit = {
+ val baos = new java.io.ByteArrayOutputStream()
+ Console.withOut(baos)(Console.withErr(baos)(compile()))
+ assert(!storeReporter.hasErrors, message = filteredInfos map (_.msg) mkString "; ")
+ val out = baos.toString("UTF-8")
+ // was 2 before the fix, the two PackageDefs for a would both contain the ClassDef for the closure
+ assert(out.lines.count(_ contains "class hihi$1") == 1, out)
+ }
+}
diff --git a/test/files/run/t9102.scala b/test/files/run/t9102.scala
new file mode 100644
index 0000000000..c46cf0e4b4
--- /dev/null
+++ b/test/files/run/t9102.scala
@@ -0,0 +1,81 @@
+
+object Test extends App {
+ import reflect.runtime._, universe._
+
+ class C { def f(i: Int, j: => Int) = i + j }
+
+ class V(val v: Int) extends AnyVal { def doubled = 2 * v }
+ class D { def f(i: Int, j: V) = i + j.doubled }
+
+ class E(i: Int, j: V)
+
+ locally {
+ val ms = typeOf[C].member(TermName("f")).asMethod
+ val im = currentMirror reflect (new C)
+ val mm = im reflectMethod ms
+ assert(mm(2,3) == 5)
+ }
+ locally {
+ val ms = typeOf[D].member(TermName("f")).asMethod
+ val im = currentMirror reflect (new D)
+ val mm = im reflectMethod ms
+ assert(mm(2, new V(3)) == 8)
+ }
+ locally {
+ val ms = typeOf[E].typeSymbol.asClass.primaryConstructor
+ val cm = currentMirror reflectClass typeOf[E].typeSymbol.asClass
+ val mm = cm reflectConstructor ms.asMethod
+ assert(mm(42, new V(7)).isInstanceOf[E])
+ }
+}
+
+/* Session tests without special init code should reside in simple script files.
+ * Also, provide filters such as for `(bound to C@74f7d1d2)`.
+
+import scala.tools.partest.SessionTest
+
+object Test extends SessionTest {
+//Welcome to Scala version 2.11.6 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_40).
+ def session =
+ s"""|Type in expressions to have them evaluated.
+ |Type :help for more information.
+ |
+ |scala> import reflect.runtime._, universe._
+ |import reflect.runtime._
+ |import universe._
+ |
+ |scala> class C { def f(i: Int, j: => Int) = i + j }
+ |defined class C
+ |
+ |scala> typeOf[C].member(TermName("f"))
+ |res0: reflect.runtime.universe.Symbol = method f
+ |
+ |scala> .asMethod
+ |res1: reflect.runtime.universe.MethodSymbol = method f
+ |
+ |scala> currentMirror reflect (new C)
+ |res2: reflect.runtime.universe.InstanceMirror = instance mirror for C@74f7d1d2
+ |
+ |scala> res2 reflectMethod res1
+ |res3: reflect.runtime.universe.MethodMirror = method mirror for def f(i: scala.Int,j: => scala.Int): scala.Int (bound to C@74f7d1d2)
+ |
+ |scala> res3(2,3)
+ |res4: Any = 5
+ |
+ |scala> :quit"""
+}
+*/
+
+/* was:
+scala> res3(2,3)
+java.lang.IllegalArgumentException
+ at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
+ at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
+ at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
+ at java.lang.reflect.Method.invoke(Method.java:497)
+ at scala.reflect.runtime.JavaMirrors$JavaMirror$JavaMethodMirror.jinvokeraw(JavaMirrors.scala:335)
+ at scala.reflect.runtime.JavaMirrors$JavaMirror$JavaMethodMirror.jinvoke(JavaMirrors.scala:339)
+ at scala.reflect.runtime.JavaMirrors$JavaMirror$JavaTransformingMethodMirror.apply(JavaMirrors.scala:436)
+ ... 33 elided
+*/
+
diff --git a/test/files/run/t9219.check b/test/files/run/t9219.check
new file mode 100644
index 0000000000..3509ece003
--- /dev/null
+++ b/test/files/run/t9219.check
@@ -0,0 +1,3 @@
+Stream(1, 2, ?)
+Stream(1, 2, 3, 4, ?)
+Stream(1, 2, 3, 4, 5, 6, ?)
diff --git a/test/files/run/t9219.scala b/test/files/run/t9219.scala
new file mode 100644
index 0000000000..c15f55faac
--- /dev/null
+++ b/test/files/run/t9219.scala
@@ -0,0 +1,11 @@
+object Test extends App {
+ def check[U](f: Stream[Int] => U) = {
+ val s = Stream.from(1)
+ f(s)
+ println(s)
+ }
+
+ check(_.tail)
+ check(_.take(4).force)
+ check(_(5))
+}
diff --git a/test/files/run/t9223.scala b/test/files/run/t9223.scala
new file mode 100644
index 0000000000..78767b158d
--- /dev/null
+++ b/test/files/run/t9223.scala
@@ -0,0 +1,8 @@
+class X(val x: String)
+class Y(y: => String) extends X(y) { def f = y }
+
+object Test {
+ def main(args: Array[String]): Unit = {
+ assert(new Y("hi").f == "hi")
+ }
+}
diff --git a/test/files/run/t9223b.scala b/test/files/run/t9223b.scala
new file mode 100644
index 0000000000..2afc7ddfe0
--- /dev/null
+++ b/test/files/run/t9223b.scala
@@ -0,0 +1,8 @@
+class X(x: => String) { def xx = x }
+class Y(y: String) extends X(y) { def f = y }
+
+object Test {
+ def main(args: Array[String]): Unit = {
+ assert(new Y("hi").f == "hi")
+ }
+}
diff --git a/test/files/scalacheck/Ctrie.scala b/test/files/scalacheck/Ctrie.scala
index 714f1c3b09..eef9d06f37 100644
--- a/test/files/scalacheck/Ctrie.scala
+++ b/test/files/scalacheck/Ctrie.scala
@@ -186,6 +186,25 @@ object Test extends Properties("concurrent.TrieMap") {
})
}
+ property("concurrent getOrElseUpdate") = forAll(threadCounts, sizes) {
+ (p, sz) =>
+ val totalInserts = new java.util.concurrent.atomic.AtomicInteger
+ val ct = new TrieMap[Wrap, String]
+
+ val results = inParallel(p) {
+ idx =>
+ (0 until sz) foreach {
+ i =>
+ val v = ct.getOrElseUpdate(Wrap(i), idx + ":" + i)
+ if (v == idx + ":" + i) totalInserts.incrementAndGet()
+ }
+ }
+
+ (totalInserts.get == sz) && ((0 until sz) forall {
+ case i => ct(Wrap(i)).split(":")(1).toInt == i
+ })
+ }
+
}