summaryrefslogtreecommitdiff
path: root/test/files
diff options
context:
space:
mode:
Diffstat (limited to 'test/files')
-rw-r--r--test/files/neg/double-def-top-level.check7
-rw-r--r--test/files/neg/double-def-top-level/A_1.scala4
-rw-r--r--test/files/neg/double-def-top-level/B_2.scala2
-rw-r--r--test/files/neg/double-def-top-level/C_3.scala2
-rw-r--r--test/files/neg/double-def-top-level/D_3.scala2
-rw-r--r--test/files/neg/t6289.check2
-rw-r--r--test/files/neg/t8630.check7
-rw-r--r--test/files/neg/t8630.scala1
-rw-r--r--test/files/pos/t8596.flags1
-rw-r--r--test/files/pos/t8596.scala7
-rw-r--r--test/files/pos/t8617.flags1
-rw-r--r--test/files/pos/t8617.scala10
-rw-r--r--test/files/pos/t8625.scala5
-rw-r--r--test/files/presentation/ide-bug-1000531.check111
-rw-r--r--test/files/presentation/ide-bug-1000531/src/CrashOnLoad.scala15
-rw-r--r--test/files/presentation/ide-bug-1000531/src/TestIterable.java7
-rw-r--r--test/files/presentation/t7915.check20
-rw-r--r--test/files/presentation/t7915/src/Foo.scala4
-rw-r--r--test/files/run/analyzerPlugins.check13
-rw-r--r--test/files/run/icode-reader-dead-code.check19
-rw-r--r--test/files/run/icode-reader-dead-code.scala82
-rw-r--r--test/files/run/repl-javap-app.check39
-rw-r--r--test/files/run/repl-javap-app.scala11
-rw-r--r--test/files/run/t7974.check29
-rw-r--r--test/files/run/t7974/Test.scala2
-rw-r--r--test/files/run/t8346.check6
-rw-r--r--test/files/run/t8346.scala34
-rw-r--r--test/files/run/t8607.scala36
-rw-r--r--test/files/run/t8637.check0
-rw-r--r--test/files/run/t8637.scala9
30 files changed, 338 insertions, 150 deletions
diff --git a/test/files/neg/double-def-top-level.check b/test/files/neg/double-def-top-level.check
new file mode 100644
index 0000000000..85b16e81e5
--- /dev/null
+++ b/test/files/neg/double-def-top-level.check
@@ -0,0 +1,7 @@
+D_3.scala:1: error: C is already defined as class C
+class C
+ ^
+D_3.scala:2: error: O is already defined as object O
+object O
+ ^
+two errors found
diff --git a/test/files/neg/double-def-top-level/A_1.scala b/test/files/neg/double-def-top-level/A_1.scala
new file mode 100644
index 0000000000..c3d68d9d05
--- /dev/null
+++ b/test/files/neg/double-def-top-level/A_1.scala
@@ -0,0 +1,4 @@
+package p
+
+class C
+object O
diff --git a/test/files/neg/double-def-top-level/B_2.scala b/test/files/neg/double-def-top-level/B_2.scala
new file mode 100644
index 0000000000..c328e8c964
--- /dev/null
+++ b/test/files/neg/double-def-top-level/B_2.scala
@@ -0,0 +1,2 @@
+class C /* noerror */
+object O /* noerror */ \ No newline at end of file
diff --git a/test/files/neg/double-def-top-level/C_3.scala b/test/files/neg/double-def-top-level/C_3.scala
new file mode 100644
index 0000000000..e1c327c15a
--- /dev/null
+++ b/test/files/neg/double-def-top-level/C_3.scala
@@ -0,0 +1,2 @@
+class C
+object O \ No newline at end of file
diff --git a/test/files/neg/double-def-top-level/D_3.scala b/test/files/neg/double-def-top-level/D_3.scala
new file mode 100644
index 0000000000..518e0d1c54
--- /dev/null
+++ b/test/files/neg/double-def-top-level/D_3.scala
@@ -0,0 +1,2 @@
+class C
+object O
diff --git a/test/files/neg/t6289.check b/test/files/neg/t6289.check
index f6f43cabd3..989932750f 100644
--- a/test/files/neg/t6289.check
+++ b/test/files/neg/t6289.check
@@ -3,7 +3,7 @@ t6289/J.java:2: method does not override or implement a method from a supertype
@Override public void foo() { }
^
1 error
-#partest java7
+#partest !java6
t6289/J.java:2: error: method does not override or implement a method from a supertype
@Override public void foo() { }
^
diff --git a/test/files/neg/t8630.check b/test/files/neg/t8630.check
new file mode 100644
index 0000000000..98b084b153
--- /dev/null
+++ b/test/files/neg/t8630.check
@@ -0,0 +1,7 @@
+t8630.scala:1: error: '{' expected but 'abstract' found.
+package bobsdelights abstract class Fruit( val name: String, val color: String ) object Fruits { object Apple extends Fruit("apple", "red") object Orange extends Fruit("orange", "orange") object Pear extends Fruit("pear", "yellowish") val menu = List(Apple, Orange, Pear) }
+ ^
+t8630.scala:1: error: '}' expected but eof found.
+package bobsdelights abstract class Fruit( val name: String, val color: String ) object Fruits { object Apple extends Fruit("apple", "red") object Orange extends Fruit("orange", "orange") object Pear extends Fruit("pear", "yellowish") val menu = List(Apple, Orange, Pear) }
+ ^
+two errors found
diff --git a/test/files/neg/t8630.scala b/test/files/neg/t8630.scala
new file mode 100644
index 0000000000..ea25227452
--- /dev/null
+++ b/test/files/neg/t8630.scala
@@ -0,0 +1 @@
+package bobsdelights abstract class Fruit( val name: String, val color: String ) object Fruits { object Apple extends Fruit("apple", "red") object Orange extends Fruit("orange", "orange") object Pear extends Fruit("pear", "yellowish") val menu = List(Apple, Orange, Pear) } \ No newline at end of file
diff --git a/test/files/pos/t8596.flags b/test/files/pos/t8596.flags
new file mode 100644
index 0000000000..281f0a10cd
--- /dev/null
+++ b/test/files/pos/t8596.flags
@@ -0,0 +1 @@
+-Yrangepos
diff --git a/test/files/pos/t8596.scala b/test/files/pos/t8596.scala
new file mode 100644
index 0000000000..bfed58eadf
--- /dev/null
+++ b/test/files/pos/t8596.scala
@@ -0,0 +1,7 @@
+class TypeTreeObjects {
+ class Container {
+ def typeParamAndDefaultArg[C](name: String = ""): String = ""
+ }
+ // crashed under -Yrangepos
+ new Container().typeParamAndDefaultArg[Any]()
+}
diff --git a/test/files/pos/t8617.flags b/test/files/pos/t8617.flags
new file mode 100644
index 0000000000..281f0a10cd
--- /dev/null
+++ b/test/files/pos/t8617.flags
@@ -0,0 +1 @@
+-Yrangepos
diff --git a/test/files/pos/t8617.scala b/test/files/pos/t8617.scala
new file mode 100644
index 0000000000..fc825bbcba
--- /dev/null
+++ b/test/files/pos/t8617.scala
@@ -0,0 +1,10 @@
+object Test {
+ def foo[A] = implicitly[OptManifest[A]] // was "unpositioned tree" under -Yrangepos
+
+ // These did not crash, but testing for good measure.
+ implicitly[OptManifest[String]]
+ implicitly[Manifest[String]]
+
+ implicitly[reflect.ClassTag[String]]
+ implicitly[reflect.runtime.universe.TypeTag[String]]
+}
diff --git a/test/files/pos/t8625.scala b/test/files/pos/t8625.scala
new file mode 100644
index 0000000000..95c4b0dbcd
--- /dev/null
+++ b/test/files/pos/t8625.scala
@@ -0,0 +1,5 @@
+object Test {
+ def f1(a: Boolean, b: Boolean) = (a || ???) && (b || ???)
+ def f2(a: Boolean, b: Boolean) = (a || ???) && b
+ def f3(a: Boolean, b: Boolean) = (a && ???) || b
+}
diff --git a/test/files/presentation/ide-bug-1000531.check b/test/files/presentation/ide-bug-1000531.check
index d8c7a369f7..12eafcd6de 100644
--- a/test/files/presentation/ide-bug-1000531.check
+++ b/test/files/presentation/ide-bug-1000531.check
@@ -1,111 +1,24 @@
-reload: CrashOnLoad.scala
+reload: CrashOnLoad.scala, TestIterable.java
-askTypeCompletion at CrashOnLoad.scala(6,12)
+askTypeCompletion at CrashOnLoad.scala(6,11)
================================================================================
-[response] askTypeCompletion at (6,12)
-retrieved 117 members
+[response] askTypeCompletion at (6,11)
+retrieved 30 members
[inaccessible] protected[package lang] def clone(): Object
[inaccessible] protected[package lang] def finalize(): Unit
-[inaccessible] protected[this] def reversed: List[B]
-class GroupedIterator[B >: A] extends AbstractIterator[Seq[B]] with Iterator[Seq[B]]
def +(other: String): String
-def ++[B >: B](that: => scala.collection.GenTraversableOnce[B]): Iterator[B]
-def ->[B](y: B): (java.util.Iterator[B], B)
-def /:[B](z: B)(op: (B, B) => B): B
-def :\[B](z: B)(op: (B, B) => B): B
-def addString(b: StringBuilder): StringBuilder
-def addString(b: StringBuilder,sep: String): StringBuilder
-def addString(b: StringBuilder,start: String,sep: String,end: String): StringBuilder
-def aggregate[B](z: => B)(seqop: (B, B) => B,combop: (B, B) => B): B
-def buffered: scala.collection.BufferedIterator[B]
-def collectFirst[B](pf: PartialFunction[B,B]): Option[B]
-def collect[B](pf: PartialFunction[B,B]): Iterator[B]
-def contains(elem: Any): Boolean
-def copyToArray[B >: B](xs: Array[B]): Unit
-def copyToArray[B >: B](xs: Array[B],start: Int): Unit
-def copyToArray[B >: B](xs: Array[B],start: Int,len: Int): Unit
-def copyToBuffer[B >: B](dest: scala.collection.mutable.Buffer[B]): Unit
-def corresponds[B](that: scala.collection.GenTraversableOnce[B])(p: (B, B) => Boolean): Boolean
-def count(p: B => Boolean): Int
-def drop(n: Int): Iterator[B]
-def dropWhile(p: B => Boolean): Iterator[B]
-def duplicate: (Iterator[B], Iterator[B])
-def ensuring(cond: Boolean): java.util.Iterator[B]
-def ensuring(cond: Boolean,msg: => Any): java.util.Iterator[B]
-def ensuring(cond: java.util.Iterator[B] => Boolean): java.util.Iterator[B]
-def ensuring(cond: java.util.Iterator[B] => Boolean,msg: => Any): java.util.Iterator[B]
+def ->[B](y: B): (other.TestIterator[Nothing], B)
+def ensuring(cond: Boolean): other.TestIterator[Nothing]
+def ensuring(cond: Boolean,msg: => Any): other.TestIterator[Nothing]
+def ensuring(cond: other.TestIterator[Nothing] => Boolean): other.TestIterator[Nothing]
+def ensuring(cond: other.TestIterator[Nothing] => Boolean,msg: => Any): other.TestIterator[Nothing]
def equals(x$1: Any): Boolean
-def exists(p: B => Boolean): Boolean
-def filter(p: B => Boolean): Iterator[B]
-def filterNot(p: B => Boolean): Iterator[B]
-def find(p: B => Boolean): Option[B]
-def flatMap[B](f: B => scala.collection.GenTraversableOnce[B]): Iterator[B]
-def foldLeft[B](z: B)(op: (B, B) => B): B
-def foldRight[B](z: B)(op: (B, B) => B): B
-def fold[A1 >: B](z: A1)(op: (A1, A1) => A1): A1
-def forall(p: B => Boolean): Boolean
-def foreach[U](f: B => U): Unit
def formatted(fmtstr: String): String
-def grouped[B >: B](size: Int): Iterator[B]#GroupedIterator[B]
-def hasDefiniteSize: Boolean
-def hasNext(): Boolean
+def hasNext: Boolean
def hashCode(): Int
-def indexOf[B >: B](elem: B): Int
-def indexWhere(p: B => Boolean): Int
-def isEmpty: Boolean
-def isTraversableAgain: Boolean
-def length: Int
-def map[B](f: B => B): Iterator[B]
-def maxBy[B](f: B => B)(implicit cmp: Ordering[B]): B
-def max[B >: B](implicit cmp: Ordering[B]): B
-def minBy[B](f: B => B)(implicit cmp: Ordering[B]): B
-def min[B >: B](implicit cmp: Ordering[B]): B
-def mkString(sep: String): String
-def mkString(start: String,sep: String,end: String): String
-def mkString: String
-def next(): B
-def nonEmpty: Boolean
-def padTo[A1 >: B](len: Int,elem: A1): Iterator[A1]
-def partition(p: B => Boolean): (Iterator[B], Iterator[B])
-def patch[B >: B](from: Int,patchElems: Iterator[B],replaced: Int): Iterator[B]
-def product[B >: B](implicit num: Numeric[B]): B
-def reduceLeftOption[B >: B](op: (B, B) => B): Option[B]
-def reduceLeft[B >: B](op: (B, B) => B): B
-def reduceOption[A1 >: B](op: (A1, A1) => A1): Option[A1]
-def reduceRightOption[B >: B](op: (B, B) => B): Option[B]
-def reduceRight[B >: B](op: (B, B) => B): B
-def reduce[A1 >: B](op: (A1, A1) => A1): A1
-def remove(): Unit
-def sameElements(that: Iterator[_]): Boolean
-def scanLeft[B](z: B)(op: (B, B) => B): Iterator[B]
-def scanRight[B](z: B)(op: (B, B) => B): Iterator[B]
-def seq: Iterator[B]
-def size: Int
-def slice(from: Int,until: Int): Iterator[B]
-def sliding[B >: B](size: Int,step: Int): Iterator[B]#GroupedIterator[B]
-def span(p: B => Boolean): (Iterator[B], Iterator[B])
-def sum[B >: B](implicit num: Numeric[B]): B
-def take(n: Int): Iterator[B]
-def takeWhile(p: B => Boolean): Iterator[B]
-def toArray[B >: B](implicit evidence$1: scala.reflect.ClassTag[B]): Array[B]
-def toBuffer[B >: B]: scala.collection.mutable.Buffer[B]
-def toIndexedSeq: scala.collection.immutable.IndexedSeq[B]
-def toIterable: Iterable[B]
-def toIterator: Iterator[B]
-def toList: List[B]
-def toMap[T, U](implicit ev: <:<[B,(T, U)]): scala.collection.immutable.Map[T,U]
-def toSeq: Seq[B]
-def toSet[B >: B]: scala.collection.immutable.Set[B]
-def toStream: scala.collection.immutable.Stream[B]
+def next: T
def toString(): String
-def toTraversable: Traversable[B]
-def toVector: Vector[B]
-def to[Col[_]](implicit cbf: scala.collection.generic.CanBuildFrom[Nothing,B,Col[B]]): Col[B]
-def withFilter(p: B => Boolean): Iterator[B]
-def zipAll[B, A1 >: B, B1 >: B](that: Iterator[B],thisElem: A1,thatElem: B1): Iterator[(A1, B1)]
-def zipWithIndex: Iterator[(B, Int)]
-def zip[B](that: Iterator[B]): Iterator[(B, B)]
-def →[B](y: B): (java.util.Iterator[B], B)
+def →[B](y: B): (other.TestIterator[Nothing], B)
final def !=(x$1: Any): Boolean
final def ##(): Int
final def ==(x$1: Any): Boolean
diff --git a/test/files/presentation/ide-bug-1000531/src/CrashOnLoad.scala b/test/files/presentation/ide-bug-1000531/src/CrashOnLoad.scala
index 878bbfa19e..3f59282083 100644
--- a/test/files/presentation/ide-bug-1000531/src/CrashOnLoad.scala
+++ b/test/files/presentation/ide-bug-1000531/src/CrashOnLoad.scala
@@ -1,7 +1,14 @@
/** When this files is opened within the IDE, a typing error is reported. */
-class A[B] extends java.lang.Iterable[B] {
+class A[B] extends TestIterable[B] {
import scala.collection.JavaConversions._
- def iterator = Iterator.empty
+ def iterator: other.TestIterator[Nothing] = ???
- iterator. /*!*/
-} \ No newline at end of file
+ iterator./*!*/
+}
+
+object other {
+ trait TestIterator[T] {
+ def hasNext: Boolean
+ def next: T
+ }
+}
diff --git a/test/files/presentation/ide-bug-1000531/src/TestIterable.java b/test/files/presentation/ide-bug-1000531/src/TestIterable.java
new file mode 100644
index 0000000000..84a6fe77f1
--- /dev/null
+++ b/test/files/presentation/ide-bug-1000531/src/TestIterable.java
@@ -0,0 +1,7 @@
+public abstract class TestIterable<T> {
+ public abstract TestIterator<T> iterator();
+ public static abstract class TestIterator<T> {
+ public abstract T next();
+ public abstract boolean hasNext();
+ }
+}
diff --git a/test/files/presentation/t7915.check b/test/files/presentation/t7915.check
index b18b4ddb55..0849aaa82b 100644
--- a/test/files/presentation/t7915.check
+++ b/test/files/presentation/t7915.check
@@ -9,3 +9,23 @@ askHyperlinkPos for `bar` at (7,22) Foo.scala
================================================================================
[response] found askHyperlinkPos for `bar` at (2,7) Foo.scala
================================================================================
+
+askHyperlinkPos for `Bar` at (8,11) Foo.scala
+================================================================================
+[response] found askHyperlinkPos for `Bar` at (1,7) Foo.scala
+================================================================================
+
+askHyperlinkPos for `baz` at (8,22) Foo.scala
+================================================================================
+[response] found askHyperlinkPos for `baz` at (2,31) Foo.scala
+================================================================================
+
+askHyperlinkPos for `Bar` at (9,11) Foo.scala
+================================================================================
+[response] found askHyperlinkPos for `Bar` at (1,7) Foo.scala
+================================================================================
+
+askHyperlinkPos for `baz` at (9,22) Foo.scala
+================================================================================
+[response] found askHyperlinkPos for `baz` at (2,31) Foo.scala
+================================================================================
diff --git a/test/files/presentation/t7915/src/Foo.scala b/test/files/presentation/t7915/src/Foo.scala
index a4166ae5b4..5c9ca36a6e 100644
--- a/test/files/presentation/t7915/src/Foo.scala
+++ b/test/files/presentation/t7915/src/Foo.scala
@@ -1,9 +1,11 @@
class Bar {
- def bar(b: Int = 2) {}
+ def bar(b: Int = 2) {}; def baz[X](b: Int = 2) {}
}
class Foo {
def foo() {
new Bar/*#*/().bar/*#*/()
+ new Bar/*#*/().baz/*#*/[Any]()
+ new Bar/*#*/().baz/*#*/()
}
}
diff --git a/test/files/run/analyzerPlugins.check b/test/files/run/analyzerPlugins.check
index e3ab554d4c..9803465ddc 100644
--- a/test/files/run/analyzerPlugins.check
+++ b/test/files/run/analyzerPlugins.check
@@ -19,7 +19,7 @@ canAdaptAnnotations(Trees$Typed, Any) [1]
canAdaptAnnotations(Trees$Typed, Int) [1]
lub(List(Int @testAnn, Int)) [1]
pluginsPt(?, Trees$Annotated) [7]
-pluginsPt(?, Trees$Apply) [9]
+pluginsPt(?, Trees$Apply) [8]
pluginsPt(?, Trees$ApplyImplicitView) [2]
pluginsPt(?, Trees$Assign) [7]
pluginsPt(?, Trees$Block) [4]
@@ -31,13 +31,13 @@ pluginsPt(?, Trees$Literal) [16]
pluginsPt(?, Trees$New) [5]
pluginsPt(?, Trees$PackageDef) [1]
pluginsPt(?, Trees$Return) [1]
-pluginsPt(?, Trees$Select) [48]
+pluginsPt(?, Trees$Select) [47]
pluginsPt(?, Trees$Super) [2]
pluginsPt(?, Trees$This) [20]
-pluginsPt(?, Trees$TypeApply) [4]
+pluginsPt(?, Trees$TypeApply) [3]
pluginsPt(?, Trees$TypeBoundsTree) [2]
pluginsPt(?, Trees$TypeDef) [1]
-pluginsPt(?, Trees$TypeTree) [39]
+pluginsPt(?, Trees$TypeTree) [38]
pluginsPt(?, Trees$Typed) [1]
pluginsPt(?, Trees$ValDef) [21]
pluginsPt(Any, Trees$Literal) [2]
@@ -98,7 +98,6 @@ pluginsTyped(()String, Trees$Ident) [1]
pluginsTyped(()String, Trees$TypeApply) [1]
pluginsTyped(()scala.annotation.Annotation, Trees$Select) [1]
pluginsTyped(()testAnn, Trees$Select) [10]
-pluginsTyped(()type, Trees$TypeApply) [1]
pluginsTyped((str: String)A <and> (param: Double)A, Trees$Select) [1]
pluginsTyped((x$1: Any)Boolean <and> (x: Double)Boolean <and> (x: Float)Boolean <and> (x: Long)Boolean <and> (x: Int)Boolean <and> (x: Char)Boolean <and> (x: Short)Boolean <and> (x: Byte)Boolean, Trees$Select) [1]
pluginsTyped((x$1: Int)Unit, Trees$Select) [1]
@@ -173,7 +172,7 @@ pluginsTyped(Unit, Trees$Literal) [5]
pluginsTyped(Unit, Trees$TypeTree) [1]
pluginsTyped([A](xs: A*)List[A], Trees$Select) [1]
pluginsTyped([T <: Int]=> Int, Trees$Select) [1]
-pluginsTyped([T0]()T0, Trees$Select) [2]
+pluginsTyped([T0]()T0, Trees$Select) [1]
pluginsTyped([T](xs: Array[T])scala.collection.mutable.WrappedArray[T], Trees$Select) [1]
pluginsTyped(annotation.type, Trees$Select) [4]
pluginsTyped(math.type, Trees$Select) [9]
@@ -190,7 +189,5 @@ pluginsTyped(testAnn, Trees$New) [5]
pluginsTyped(testAnn, Trees$This) [1]
pluginsTyped(testAnn, Trees$TypeTree) [2]
pluginsTyped(testAnn.super.type, Trees$Super) [1]
-pluginsTyped(type, Trees$Apply) [1]
pluginsTyped(type, Trees$Select) [1]
-pluginsTyped(type, Trees$TypeTree) [1]
pluginsTypedReturn(return f, String) [1]
diff --git a/test/files/run/icode-reader-dead-code.check b/test/files/run/icode-reader-dead-code.check
new file mode 100644
index 0000000000..d1739fed3b
--- /dev/null
+++ b/test/files/run/icode-reader-dead-code.check
@@ -0,0 +1,19 @@
+Bytecode for method f
+ L0
+ LINENUMBER 4 L0
+ ICONST_1
+ IRETURN
+ L1
+ LOCALVARIABLE this Lp/A; L0 L1 0
+ MAXSTACK = 1
+ MAXLOCALS = 1
+Bytecode for method f
+ L0
+ LINENUMBER 4 L0
+ ICONST_1
+ ATHROW
+ IRETURN
+ L1
+ LOCALVARIABLE this Lp/A; L0 L1 0
+ MAXSTACK = 1
+ MAXLOCALS = 1
diff --git a/test/files/run/icode-reader-dead-code.scala b/test/files/run/icode-reader-dead-code.scala
new file mode 100644
index 0000000000..00ba58829f
--- /dev/null
+++ b/test/files/run/icode-reader-dead-code.scala
@@ -0,0 +1,82 @@
+import java.io.{FileOutputStream, FileInputStream}
+
+import scala.tools.asm.{ClassWriter, Opcodes, ClassReader}
+import scala.tools.asm.tree.{InsnNode, ClassNode}
+import scala.tools.nsc.backend.jvm.AsmUtils
+import scala.tools.partest.DirectTest
+import scala.collection.JavaConverters._
+
+/**
+ * Test that the ICodeReader does not crash if the bytecode of a method has unreachable code.
+ */
+object Test extends DirectTest {
+ def code: String = ???
+
+ def show(): Unit = {
+ // The bytecode of f will be modified using ASM by `addDeadCode`
+ val aCode =
+ """
+ |package p
+ |class A {
+ | @inline final def f = 1
+ |}
+ """.stripMargin
+
+ val bCode =
+ """
+ |package p
+ |class B {
+ | def g = (new A()).f
+ |}
+ """.stripMargin
+
+ compileString(newCompiler("-usejavacp"))(aCode)
+
+ addDeadCode()
+
+ // If inlining fails, the compiler will issue an inliner warning that is not present in the
+ // check file
+ compileString(newCompiler("-usejavacp", "-optimise"))(bCode)
+ }
+
+ def readClass(file: String) = {
+ val cnode = new ClassNode()
+ val is = new FileInputStream(file)
+ val reader = new ClassReader(is)
+ reader.accept(cnode, 0)
+ is.close()
+ cnode
+ }
+
+ def writeClass(file: String, cnode: ClassNode): Unit = {
+ val writer = new ClassWriter(0)
+ cnode.accept(writer)
+
+ val os = new FileOutputStream(file)
+ os.write(writer.toByteArray)
+ os.close()
+ }
+
+ def addDeadCode() {
+ val file = (testOutput / "p" / "A.class").path
+ val cnode = readClass(file)
+ val method = cnode.methods.asScala.find(_.name == "f").head
+
+ AsmUtils.traceMethod(method)
+
+ val insns = method.instructions
+ val it = insns.iterator()
+ while (it.hasNext) {
+ val in = it.next()
+ if (in.getOpcode == Opcodes.IRETURN) {
+ // Insert an ATHROW before the IRETURN. The IRETURN will then be dead code.
+ // The ICodeReader should not crash if there's dead code.
+ insns.insert(in.getPrevious, new InsnNode(Opcodes.ATHROW))
+ }
+ }
+
+ AsmUtils.traceMethod(method)
+
+ writeClass(file, cnode)
+ }
+}
diff --git a/test/files/run/repl-javap-app.check b/test/files/run/repl-javap-app.check
index 490860585c..1136b415d7 100644
--- a/test/files/run/repl-javap-app.check
+++ b/test/files/run/repl-javap-app.check
@@ -1,4 +1,5 @@
#partest java6
+Welcome to Scala
Type in expressions to have them evaluated.
Type :help for more information.
@@ -6,16 +7,17 @@ scala> :javap -app MyApp$
public final void delayedEndpoint$MyApp$1();
Code:
Stack=2, Locals=1, Args_size=1
- 0: getstatic #61; //Field scala/Console$.MODULE$:Lscala/Console$;
- 3: ldc #63; //String Hello, delayed world.
- 5: invokevirtual #67; //Method scala/Console$.println:(Ljava/lang/Object;)V
+ 0: getstatic #XX; //Field scala/Console$.MODULE$:Lscala/Console$;
+ 3: ldc #XX; //String Hello, delayed world.
+ 5: invokevirtual #XX; //Method scala/Console$.println:(Ljava/lang/Object;)V
8: return
LocalVariableTable:
Start Length Slot Name Signature
0 9 0 this LMyApp$;
scala>
-#partest !java6
+#partest java7
+Welcome to Scala
Type in expressions to have them evaluated.
Type :help for more information.
@@ -24,9 +26,9 @@ scala> :javap -app MyApp$
flags: ACC_PUBLIC, ACC_FINAL
Code:
stack=2, locals=1, args_size=1
- 0: getstatic #61 // Field scala/Console$.MODULE$:Lscala/Console$;
- 3: ldc #63 // String Hello, delayed world.
- 5: invokevirtual #67 // Method scala/Console$.println:(Ljava/lang/Object;)V
+ 0: getstatic #XX // Field scala/Console$.MODULE$:Lscala/Console$;
+ 3: ldc #XX // String Hello, delayed world.
+ 5: invokevirtual #XX // Method scala/Console$.println:(Ljava/lang/Object;)V
8: return
LocalVariableTable:
Start Length Slot Name Signature
@@ -36,3 +38,26 @@ scala> :javap -app MyApp$
}
scala>
+#partest java8
+Welcome to Scala
+Type in expressions to have them evaluated.
+Type :help for more information.
+
+scala> :javap -app MyApp$
+ public final void delayedEndpoint$MyApp$1();
+ descriptor: ()V
+ flags: ACC_PUBLIC, ACC_FINAL
+ Code:
+ stack=2, locals=1, args_size=1
+ 0: getstatic #XX // Field scala/Console$.MODULE$:Lscala/Console$;
+ 3: ldc #XX // String Hello, delayed world.
+ 5: invokevirtual #XX // Method scala/Console$.println:(Ljava/lang/Object;)V
+ 8: return
+ LocalVariableTable:
+ Start Length Slot Name Signature
+ 0 9 0 this LMyApp$;
+ LineNumberTable:
+ line 5: 0
+}
+
+scala>
diff --git a/test/files/run/repl-javap-app.scala b/test/files/run/repl-javap-app.scala
index be04920be1..ad6076c2d5 100644
--- a/test/files/run/repl-javap-app.scala
+++ b/test/files/run/repl-javap-app.scala
@@ -7,4 +7,15 @@ object MyApp extends App {
object Test extends ReplTest {
def code = ":javap -app MyApp$"
+
+ override def welcoming = true
+
+ // The constant pool indices are not the same for GenASM / GenBCode, so
+ // replacing the exact numbers by XX.
+ lazy val hasConstantPoolRef = """(.*)(#\d\d)(.*)""".r
+
+ override def normalize(s: String) = s match {
+ case hasConstantPoolRef(start, ref, end) => start + "#XX" + end
+ case _ => super.normalize(s)
+ }
}
diff --git a/test/files/run/t7974.check b/test/files/run/t7974.check
index 0be496d8d0..d8152d3286 100644
--- a/test/files/run/t7974.check
+++ b/test/files/run/t7974.check
@@ -1,6 +1,5 @@
public class Symbols {
- // compiled from: Symbols.scala
@@ -18,20 +17,14 @@ public class Symbols {
// access flags 0x9
public static <clinit>()V
- L0
- LINENUMBER 2 L0
GETSTATIC scala/Symbol$.MODULE$ : Lscala/Symbol$;
LDC "Symbolic1"
INVOKEVIRTUAL scala/Symbol$.apply (Ljava/lang/String;)Lscala/Symbol;
PUTSTATIC Symbols.symbol$1 : Lscala/Symbol;
- L1
- LINENUMBER 3 L1
GETSTATIC scala/Symbol$.MODULE$ : Lscala/Symbol$;
LDC "Symbolic2"
INVOKEVIRTUAL scala/Symbol$.apply (Ljava/lang/String;)Lscala/Symbol;
PUTSTATIC Symbols.symbol$2 : Lscala/Symbol;
- L2
- LINENUMBER 5 L2
GETSTATIC scala/Symbol$.MODULE$ : Lscala/Symbol$;
LDC "Symbolic3"
INVOKEVIRTUAL scala/Symbol$.apply (Ljava/lang/String;)Lscala/Symbol;
@@ -42,63 +35,41 @@ public class Symbols {
// access flags 0x1
public someSymbol1()Lscala/Symbol;
- L0
- LINENUMBER 2 L0
GETSTATIC Symbols.symbol$1 : Lscala/Symbol;
ARETURN
- L1
- LOCALVARIABLE this LSymbols; L0 L1 0
MAXSTACK = 1
MAXLOCALS = 1
// access flags 0x1
public someSymbol2()Lscala/Symbol;
- L0
- LINENUMBER 3 L0
GETSTATIC Symbols.symbol$2 : Lscala/Symbol;
ARETURN
- L1
- LOCALVARIABLE this LSymbols; L0 L1 0
MAXSTACK = 1
MAXLOCALS = 1
// access flags 0x1
public sameSymbol1()Lscala/Symbol;
- L0
- LINENUMBER 4 L0
GETSTATIC Symbols.symbol$1 : Lscala/Symbol;
ARETURN
- L1
- LOCALVARIABLE this LSymbols; L0 L1 0
MAXSTACK = 1
MAXLOCALS = 1
// access flags 0x1
public someSymbol3()Lscala/Symbol;
- L0
- LINENUMBER 5 L0
ALOAD 0
GETFIELD Symbols.someSymbol3 : Lscala/Symbol;
ARETURN
- L1
- LOCALVARIABLE this LSymbols; L0 L1 0
MAXSTACK = 1
MAXLOCALS = 1
// access flags 0x1
public <init>()V
- L0
- LINENUMBER 6 L0
ALOAD 0
INVOKESPECIAL java/lang/Object.<init> ()V
- L1
- LINENUMBER 5 L1
ALOAD 0
GETSTATIC Symbols.symbol$3 : Lscala/Symbol;
PUTFIELD Symbols.someSymbol3 : Lscala/Symbol;
RETURN
- L2
- LOCALVARIABLE this LSymbols; L0 L2 0
MAXSTACK = 2
MAXLOCALS = 1
}
diff --git a/test/files/run/t7974/Test.scala b/test/files/run/t7974/Test.scala
index 433d9061a7..29d2b9cb64 100644
--- a/test/files/run/t7974/Test.scala
+++ b/test/files/run/t7974/Test.scala
@@ -6,7 +6,7 @@ import scala.tools.nsc.util.stringFromWriter
object Test extends BytecodeTest {
def show {
- val classNode = loadClassNode("Symbols", skipDebugInfo = false)
+ val classNode = loadClassNode("Symbols", skipDebugInfo = true)
val textifier = new Textifier
classNode.accept(new TraceClassVisitor(null, textifier, null))
diff --git a/test/files/run/t8346.check b/test/files/run/t8346.check
new file mode 100644
index 0000000000..1ba5c31abe
--- /dev/null
+++ b/test/files/run/t8346.check
@@ -0,0 +1,6 @@
+BitSet: List(invariant, invariant, invariant, invariant)
+HashSet: List(covariant (true), covariant (true), covariant (true), covariant (true))
+ListSet: List(covariant (true), covariant (true), covariant (true), covariant (true))
+SortedSet: List(invariant, invariant, invariant, invariant)
+TreeSet: List(invariant, invariant, invariant, invariant)
+ValueSet: invariant
diff --git a/test/files/run/t8346.scala b/test/files/run/t8346.scala
new file mode 100644
index 0000000000..5f3df84174
--- /dev/null
+++ b/test/files/run/t8346.scala
@@ -0,0 +1,34 @@
+object Test extends App {
+ import reflect.ClassTag
+
+ object SomeEnum extends Enumeration {
+ val one, two, three, four = Value
+ }
+
+ def sctor[A <: Set[Int]](f: Int => A)(implicit A: ClassTag[A])
+ : (String, Int => Set[Int]) =
+ (A.runtimeClass.getSimpleName, f)
+
+ val inits: Seq[(String, Int => Set[Int])] = {
+ import collection.immutable.{Seq => _, _}
+ Seq(sctor(BitSet(_)),
+ sctor(HashSet(_)),
+ sctor(ListSet(_)),
+ sctor(SortedSet(_)),
+ sctor(TreeSet(_)))
+ }
+
+ def sVarInfo[A](sa: Set[A]): String = {
+ val saa = sa.toSet[Any]
+ if (sa eq saa) s"""covariant (${(saa + "hi") contains "hi"})"""
+ else "invariant"
+ }
+
+ inits foreach {case (name, singleton) =>
+ print(s"${name}: ")
+ val one = singleton(1)
+ println(Seq(2,3,4).scanLeft(one)(_ + _) map sVarInfo toList)
+ }
+
+ println(s"ValueSet: ${sVarInfo(SomeEnum.values)}")
+}
diff --git a/test/files/run/t8607.scala b/test/files/run/t8607.scala
new file mode 100644
index 0000000000..1b8ef9bbd0
--- /dev/null
+++ b/test/files/run/t8607.scala
@@ -0,0 +1,36 @@
+package p1 {
+ private[p1] trait B extends Any {
+ def a: Any = ""
+ }
+
+ class C(val value: Int) extends AnyVal with B {
+ // def b = ""
+ }
+}
+
+object Test {
+ def main(args: Array[String]) {
+ val c = new p1.C(42)
+ c.a
+ /*
+ new p1.C.<init>(
+ c.$asInstanceOf[scala.this.Int]()
+ ).a();
+
+
+ new p1.C.<init>(
+ new p1.C.<init>(
+ c.$asInstanceOf[scala.this.Int]()
+ ).$asInstanceOf[ErasedValueType(class C, scala.this.Int)]()
+ .$asInstanceOf[scala.this.Int]()
+ ).a();
+
+ new p1.C.<init>(
+ new p1.C.<init>(c)
+ .$asInstanceOf[scala.this.Int]()
+ .$asInstanceOf[scala.this.Int]()
+ ).a();
+
+ */
+ }
+}
diff --git a/test/files/run/t8637.check b/test/files/run/t8637.check
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/test/files/run/t8637.check
diff --git a/test/files/run/t8637.scala b/test/files/run/t8637.scala
new file mode 100644
index 0000000000..99c8d4c413
--- /dev/null
+++ b/test/files/run/t8637.scala
@@ -0,0 +1,9 @@
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.currentMirror
+import scala.tools.reflect.ToolBox
+
+object Test extends App {
+ val tb = currentMirror.mkToolBox()
+ tb.compile(q"true > true")
+ tb.typecheck(q"true > true")
+} \ No newline at end of file