summaryrefslogtreecommitdiff
path: root/test/files/run
diff options
context:
space:
mode:
Diffstat (limited to 'test/files/run')
-rw-r--r--test/files/run/scalapInvokedynamic.check5
-rw-r--r--test/files/run/scalapInvokedynamic.scala11
-rwxr-xr-xtest/files/run/t2127.scala2
-rw-r--r--test/files/run/t720.scala48
-rw-r--r--test/files/run/t7214.scala2
-rw-r--r--test/files/run/t8502b.scala46
-rw-r--r--test/files/run/t9365.check2
-rw-r--r--test/files/run/t9365.scala18
-rw-r--r--test/files/run/t9387.scala20
-rw-r--r--test/files/run/t9387b.check1
-rw-r--r--test/files/run/t9387b.scala16
-rw-r--r--test/files/run/t9403.flags1
-rw-r--r--test/files/run/t9403/C_1.scala5
-rw-r--r--test/files/run/t9403/Test_2.scala29
-rw-r--r--test/files/run/t9422.scala11
-rw-r--r--test/files/run/t9425.scala8
-rw-r--r--test/files/run/test-cpp.scala2
17 files changed, 224 insertions, 3 deletions
diff --git a/test/files/run/scalapInvokedynamic.check b/test/files/run/scalapInvokedynamic.check
new file mode 100644
index 0000000000..8e4b08f234
--- /dev/null
+++ b/test/files/run/scalapInvokedynamic.check
@@ -0,0 +1,5 @@
+class C extends scala.AnyRef {
+ def this() = { /* compiled code */ }
+ def m: java.lang.String = { /* compiled code */ }
+}
+
diff --git a/test/files/run/scalapInvokedynamic.scala b/test/files/run/scalapInvokedynamic.scala
new file mode 100644
index 0000000000..670cf26662
--- /dev/null
+++ b/test/files/run/scalapInvokedynamic.scala
@@ -0,0 +1,11 @@
+class C {
+ def m = {
+ val f = (x: String) => x.trim
+ f(" H ae i ")
+ }
+}
+
+object Test extends App {
+ val testClassesDir = System.getProperty("partest.output")
+ scala.tools.scalap.Main.main(Array("-cp", testClassesDir, "C"))
+} \ No newline at end of file
diff --git a/test/files/run/t2127.scala b/test/files/run/t2127.scala
index 869d8a38d6..839c8d6a5c 100755
--- a/test/files/run/t2127.scala
+++ b/test/files/run/t2127.scala
@@ -28,5 +28,5 @@
}
-The constructor invocation of Bar is done within the scope of object Foo's constructor, and therefor the private constructor of Foo should be visible and accessible.
+The constructor invocation of Bar is done within the scope of object Foo's constructor, and therefore the private constructor of Foo should be visible and accessible.
*/
diff --git a/test/files/run/t720.scala b/test/files/run/t720.scala
new file mode 100644
index 0000000000..a5cb2495cf
--- /dev/null
+++ b/test/files/run/t720.scala
@@ -0,0 +1,48 @@
+class Lazy(f: => Int) {
+ lazy val get: Int = f
+}
+
+class UsedLater(f: => Int) {
+ lazy val get: Int = f
+ def other = f
+}
+
+class TransientLazy(f: => Int) {
+ @transient
+ lazy val get: Int = f
+}
+
+object Test {
+ def main(args: Array[String]): Unit = {
+ testLazy()
+ testUsedLater()
+ }
+
+ def testLazy() {
+ val o = new Lazy("".length)
+ val f = classOf[Lazy].getDeclaredField("f")
+ f.setAccessible(true)
+ assert(f.get(o) != null)
+ o.get
+ assert(f.get(o) == null)
+ }
+
+ def testUsedLater() {
+ val o = new UsedLater("".length)
+ val f = classOf[UsedLater].getDeclaredField("f")
+ f.setAccessible(true)
+ assert(f.get(o) != null)
+ o.get
+ assert(f.get(o) != null)
+ }
+
+ def testTransientLazy() {
+ val o = new TransientLazy("".length)
+ val f = classOf[TransientLazy].getDeclaredField("f")
+ f.setAccessible(true)
+ assert(f.get(o) != null)
+ o.get
+ assert(f.get(o) != null) // SI-9365
+ }
+}
+
diff --git a/test/files/run/t7214.scala b/test/files/run/t7214.scala
index 15c2c24fa0..b2ef53eeab 100644
--- a/test/files/run/t7214.scala
+++ b/test/files/run/t7214.scala
@@ -1,4 +1,4 @@
-// pattern matcher crashes here trying to synthesize an uneeded outer test.
+// pattern matcher crashes here trying to synthesize an unneeded outer test.
// no-symbol does not have an owner
// at scala.reflect.internal.SymbolTable.abort(SymbolTable.scala:49)
// at scala.tools.nsc.Global.abort(Global.scala:253)
diff --git a/test/files/run/t8502b.scala b/test/files/run/t8502b.scala
new file mode 100644
index 0000000000..4f70d13bb0
--- /dev/null
+++ b/test/files/run/t8502b.scala
@@ -0,0 +1,46 @@
+import scala.tools.partest._
+import java.io.File
+
+// used to crash with an assertion failure in flatten because the type symbol created for the missing
+// package was a ClassSymbol, not a PackageClassSymbol
+// - isFlattenablePrefix(vanishingPackage) was true (wrongly)
+// - therefore flatten tried to flatten the class defined in the package, but the class is
+// top-level, vanishingClass.enclosingTopLevelClass is NoSymbol
+object Test extends StoreReporterDirectTest {
+ def code = ???
+
+ def compileCode(code: String) = {
+ val classpath = List(sys.props("partest.lib"), testOutput.path) mkString sys.props("path.separator")
+ compileString(newCompiler("-cp", classpath, "-d", testOutput.path))(code)
+ }
+
+ def show(): Unit = {
+ compileCode("""
+ class Outer {
+ class Nested extends vanishing.Vanishing
+ }
+
+ package vanishing {
+ class Vanishing
+ }
+ """)
+ assert(filteredInfos.isEmpty, filteredInfos)
+ deletePackage("vanishing")
+ compileCode("""
+ class Test {
+ def f(o: Outer): Outer = o
+ }
+ """)
+ assert(storeReporter.infos.isEmpty, storeReporter.infos.mkString("\n")) // Included a MissingRequirementError before.
+ }
+
+ def deletePackage(name: String) {
+ val directory = new File(testOutput.path, name)
+ for (f <- directory.listFiles()) {
+ assert(f.getName.endsWith(".class"))
+ assert(f.delete())
+ }
+ assert(directory.listFiles().isEmpty)
+ assert(directory.delete())
+ }
+}
diff --git a/test/files/run/t9365.check b/test/files/run/t9365.check
new file mode 100644
index 0000000000..0d55bed3a3
--- /dev/null
+++ b/test/files/run/t9365.check
@@ -0,0 +1,2 @@
+foo
+foo
diff --git a/test/files/run/t9365.scala b/test/files/run/t9365.scala
new file mode 100644
index 0000000000..0c4477dda9
--- /dev/null
+++ b/test/files/run/t9365.scala
@@ -0,0 +1,18 @@
+class Test(x: => Object) extends Serializable {
+ @transient lazy val foo = x
+}
+
+object Test {
+ def main(args: Array[String]): Unit = {
+ import java.io._
+ val t = new Test("foo")
+ println(t.foo)
+ val baos = new ByteArrayOutputStream
+ val dos = new ObjectOutputStream(baos)
+ dos.writeObject(t)
+ dos.close()
+ val dis = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()))
+ val t1 = dis.readObject().asInstanceOf[Test]
+ println(t1.foo) // was NPE
+ }
+}
diff --git a/test/files/run/t9387.scala b/test/files/run/t9387.scala
new file mode 100644
index 0000000000..3e33d19fd2
--- /dev/null
+++ b/test/files/run/t9387.scala
@@ -0,0 +1,20 @@
+class G[T]
+object G {
+ def v[T](x: T): G[T] = null
+}
+
+class A[T]
+object A {
+ def apply[T](x: => G[T]): A[T] = null
+}
+
+object T {
+ A[Unit](G.v(() => ())) // Was VerifyError
+}
+
+object Test {
+ def main(args: Array[String]): Unit = {
+ T
+ }
+
+} \ No newline at end of file
diff --git a/test/files/run/t9387b.check b/test/files/run/t9387b.check
new file mode 100644
index 0000000000..6a452c185a
--- /dev/null
+++ b/test/files/run/t9387b.check
@@ -0,0 +1 @@
+()
diff --git a/test/files/run/t9387b.scala b/test/files/run/t9387b.scala
new file mode 100644
index 0000000000..6339f4caba
--- /dev/null
+++ b/test/files/run/t9387b.scala
@@ -0,0 +1,16 @@
+object T {
+ val f: Unit = () => ()
+ println(f)
+}
+
+object U {
+ def f[T](t: T): T = t
+ f[Unit](() => ())
+}
+
+object Test {
+ def main(args: Array[String]): Unit = {
+ T
+ U
+ }
+}
diff --git a/test/files/run/t9403.flags b/test/files/run/t9403.flags
new file mode 100644
index 0000000000..307668060c
--- /dev/null
+++ b/test/files/run/t9403.flags
@@ -0,0 +1 @@
+-Ybackend:GenASM -optimize
diff --git a/test/files/run/t9403/C_1.scala b/test/files/run/t9403/C_1.scala
new file mode 100644
index 0000000000..439af1a386
--- /dev/null
+++ b/test/files/run/t9403/C_1.scala
@@ -0,0 +1,5 @@
+package p
+class C {
+ @inline final def f(x: Int): Long = 10L / (if (x < 0) -2 else 2)
+ @inline final def g(x: Int): Long = 3000L / (if (x < 0) -300 else 300)
+}
diff --git a/test/files/run/t9403/Test_2.scala b/test/files/run/t9403/Test_2.scala
new file mode 100644
index 0000000000..fb2777b9a8
--- /dev/null
+++ b/test/files/run/t9403/Test_2.scala
@@ -0,0 +1,29 @@
+import p.C
+import scala.tools.asm.Opcodes
+import scala.tools.partest.BytecodeTest
+import scala.tools.partest.ASMConverters._
+
+
+object Test extends BytecodeTest {
+ def foo(c: C, x: Int) = c.f(x)
+ def goo(c: C, x: Int) = c.g(x)
+
+ def has(i: Instruction, c: String, m: String) = {
+ val cls = loadClassNode(c)
+ val mth = convertMethod(getMethod(cls, m))
+ assert(mth.instructions.contains(i))
+ }
+
+ def show(): Unit = {
+ assert(foo(new C, -2) == -5L)
+ assert(goo(new C, -2) == -10L)
+
+ val bipush2 = IntOp(Opcodes.BIPUSH, -2)
+ has(bipush2, "p.C", "f")
+ has(bipush2, "Test$", "foo")
+
+ val sipush300 = IntOp(Opcodes.SIPUSH, -300)
+ has(sipush300, "p.C", "g")
+ has(sipush300, "Test$", "goo")
+ }
+}
diff --git a/test/files/run/t9422.scala b/test/files/run/t9422.scala
new file mode 100644
index 0000000000..5ca2e8daaa
--- /dev/null
+++ b/test/files/run/t9422.scala
@@ -0,0 +1,11 @@
+class Test(val x: Long) {
+ def sameDirection(y: Long): Boolean =
+ (y == 0 || x == 0 || ((y > 0) == (x > 0)))
+}
+
+object Test {
+ def main(args: Array[String]) {
+ val b = new Test(1L)
+ assert(!b.sameDirection(-1L))
+ }
+}
diff --git a/test/files/run/t9425.scala b/test/files/run/t9425.scala
new file mode 100644
index 0000000000..f251cc8579
--- /dev/null
+++ b/test/files/run/t9425.scala
@@ -0,0 +1,8 @@
+class C { case class Foo private (x: Int); Foo.apply(0) }
+
+object Test {
+ def test(c: C) = {import c.Foo; Foo.apply(0)}
+ def main(args: Array[String]): Unit = {
+ test(new C)
+ }
+}
diff --git a/test/files/run/test-cpp.scala b/test/files/run/test-cpp.scala
index 4e00e72658..4fca67d51e 100644
--- a/test/files/run/test-cpp.scala
+++ b/test/files/run/test-cpp.scala
@@ -46,7 +46,7 @@ object TestSetterInline {
* The access of the local variable 'y' should be replaced by the
* constant.
*/
-object TestAliasChainConstat {
+object TestAliasChainConstant {
def main(args: Array[String]): Unit = {
val x = 2