summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2010-12-11 14:57:06 +0000
committerPaul Phillips <paulp@improving.org>2010-12-11 14:57:06 +0000
commit262ee3a852f278f97b083a05376de0eab96c805d (patch)
tree482c62113aeb64e1bc7170610a958d58ec60cd19
parent4cfcc156f404f574451d2ddcaf62326d32d0ef95 (diff)
downloadscala-262ee3a852f278f97b083a05376de0eab96c805d.tar.gz
scala-262ee3a852f278f97b083a05376de0eab96c805d.tar.bz2
scala-262ee3a852f278f97b083a05376de0eab96c805d.zip
When was the last time -Xcheckinit was run? It ...
When was the last time -Xcheckinit was run? It must have been a long time. All these changes are to address bugs revealed by -Xcheckinit, mostly in test cases, some in the compiler. I'm guessing the partest -Xcheckinit runs are hanging the first time they run into a failure, so if it starts "working" again after this commit don't get too confident. No review.
-rw-r--r--src/compiler/scala/tools/nsc/Global.scala4
-rw-r--r--src/compiler/scala/tools/nsc/plugins/Plugins.scala3
-rw-r--r--test/files/jvm/t2511.check3
-rw-r--r--test/files/jvm/t2511.scala7
-rw-r--r--test/files/jvm/t3003/Annot.java4
-rw-r--r--test/files/jvm/t3003/Test_1.scala9
-rw-r--r--test/files/run/bug428.check8
-rw-r--r--test/files/run/bug428.scala37
-rw-r--r--test/files/run/bug429.check2
-rw-r--r--test/files/run/bug429.scala4
-rw-r--r--test/files/run/existentials.scala16
-rw-r--r--test/files/run/spec-init.check4
-rw-r--r--test/files/run/spec-init.scala3
-rw-r--r--test/files/run/t1524.scala2
-rw-r--r--test/files/run/t3897/J_2.java8
-rw-r--r--test/files/run/t3897/a_2.scala14
16 files changed, 55 insertions, 73 deletions
diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala
index d1091a4b7c..327de376c0 100644
--- a/src/compiler/scala/tools/nsc/Global.scala
+++ b/src/compiler/scala/tools/nsc/Global.scala
@@ -603,8 +603,8 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable
lazy val phaseDescriptors: List[SubComponent] = computePhaseDescriptors
/* The set of phase objects that is the basis for the compiler phase chain */
- protected val phasesSet = new mutable.HashSet[SubComponent]
- protected val phasesDescMap = new mutable.HashMap[SubComponent, String] withDefaultValue ""
+ protected lazy val phasesSet = new mutable.HashSet[SubComponent]
+ protected lazy val phasesDescMap = new mutable.HashMap[SubComponent, String] withDefaultValue ""
protected def addToPhasesSet(sub: SubComponent, descr: String) {
phasesSet += sub
phasesDescMap(sub) = descr
diff --git a/src/compiler/scala/tools/nsc/plugins/Plugins.scala b/src/compiler/scala/tools/nsc/plugins/Plugins.scala
index c798fa89e1..24962ee085 100644
--- a/src/compiler/scala/tools/nsc/plugins/Plugins.scala
+++ b/src/compiler/scala/tools/nsc/plugins/Plugins.scala
@@ -15,8 +15,7 @@ import io.{ File, Path }
* @version 1.1, 2009/1/2
* Updated 2009/1/2 by Anders Bach Nielsen: Added features to implement SIP 00002
*/
-trait Plugins
-{
+trait Plugins {
self: Global =>
/** Load a rough list of the plugins. For speed, it
diff --git a/test/files/jvm/t2511.check b/test/files/jvm/t2511.check
index ec747fa47d..004b8e2031 100644
--- a/test/files/jvm/t2511.check
+++ b/test/files/jvm/t2511.check
@@ -1 +1,2 @@
-null \ No newline at end of file
+null
+bippy
diff --git a/test/files/jvm/t2511.scala b/test/files/jvm/t2511.scala
index d4b5e83d0f..eb57dc503d 100644
--- a/test/files/jvm/t2511.scala
+++ b/test/files/jvm/t2511.scala
@@ -4,6 +4,7 @@ object Test {
trait IMyMessage extends Serializable {
@transient var message: String = null
+ var message2: String = null
}
class MyMessage extends IMyMessage
@@ -13,6 +14,7 @@ object Test {
val out = new ObjectOutputStream(buf)
val m = new MyMessage
m.message = "foo"
+ m.message2 = "bippy"
out.writeObject(m)
out.flush
buf.toByteArray
@@ -25,6 +27,9 @@ object Test {
def main(args: Array[String]) {
val m = unserialize(serialize)
- println(m.message)
+ // Xcheckinit freaks out here but its nullness is what we're testing
+ try println(m.message)
+ catch { case _: UninitializedFieldError => println("null") }
+ println(m.message2)
}
}
diff --git a/test/files/jvm/t3003/Annot.java b/test/files/jvm/t3003/Annot.java
index 1d5f206fd7..30dcb66bd7 100644
--- a/test/files/jvm/t3003/Annot.java
+++ b/test/files/jvm/t3003/Annot.java
@@ -1,4 +1,6 @@
-@java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME)
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME)
public @interface Annot {
Class<?> optionType();
}
diff --git a/test/files/jvm/t3003/Test_1.scala b/test/files/jvm/t3003/Test_1.scala
index ec7f220c94..8ec08bebc6 100644
--- a/test/files/jvm/t3003/Test_1.scala
+++ b/test/files/jvm/t3003/Test_1.scala
@@ -3,6 +3,13 @@ class C {
}
object Test {
def main(args: Array[String]) {
- println(classOf[C].getDeclaredFields.toList.sortBy(f => f.getName).map(f => f.getAnnotations.toList))
+ val xs = (
+ classOf[C].getDeclaredFields.toList
+ . sortBy(f => f.getName)
+ . map(f => f.getAnnotations.toList)
+ . filterNot (_.isEmpty) // there are extra fields under -Xcheckinit
+ )
+
+ println(xs)
}
}
diff --git a/test/files/run/bug428.check b/test/files/run/bug428.check
deleted file mode 100644
index 21bef2f8d3..0000000000
--- a/test/files/run/bug428.check
+++ /dev/null
@@ -1,8 +0,0 @@
-Foo 1: a = 0, b = 0, x = 0, y = 0
-Foo 2: a = 2, b = 0, x = 0, y = 0
-Foo 3: a = 2, b = 3, x = 0, y = 0
-Foo 4: a = 2, b = 3, x = 0, y = 0
-Foo 5: a = 2, b = 3, x = 0, y = 0
-Bar 1: a = 2, b = 3, x = 0, y = 0
-Bar 2: a = 2, b = 3, x = 5, y = 0
-Bar 3: a = 2, b = 3, x = 5, y = 7
diff --git a/test/files/run/bug428.scala b/test/files/run/bug428.scala
deleted file mode 100644
index 34d99efd1f..0000000000
--- a/test/files/run/bug428.scala
+++ /dev/null
@@ -1,37 +0,0 @@
-object Test {
-
- abstract class Foo(_a: Int, _b: Int) {
-
- Console.println("Foo 1: " + this);
- val a: Int = _a;
- Console.println("Foo 2: " + this);
- val b: Int = { fun(); _b }
- Console.println("Foo 3: " + this);
- val x: Int;
- Console.println("Foo 4: " + this);
- val y: Int;
- Console.println("Foo 5: " + this);
-
-
- def fun(): Unit = ();
-
- override def toString(): String =
- "a = " + a + ", b = " + b + ", x = " + x + ", y = " + y;
-
- }
-
- class Bar(_a: Int, _b: Int, _x: Int, _y: Int) extends Foo(_a, _b) {
-
- Console.println("Bar 1: " + this);
- val x: Int = _x;
- Console.println("Bar 2: " + this);
- val y: Int = { fun(); _y }
- Console.println("Bar 3: " + this);
-
- }
-
- def main (args: Array[String]): Unit = {
- new Bar(2,3,5,7);
- }
-
-}
diff --git a/test/files/run/bug429.check b/test/files/run/bug429.check
index 9e871b7bff..22b91b7850 100644
--- a/test/files/run/bug429.check
+++ b/test/files/run/bug429.check
@@ -1 +1 @@
-AyB1
+AyB5
diff --git a/test/files/run/bug429.scala b/test/files/run/bug429.scala
index b2cc8128c0..e62a6b307b 100644
--- a/test/files/run/bug429.scala
+++ b/test/files/run/bug429.scala
@@ -6,8 +6,8 @@ object Test {
}
class B extends A {
Console.print("B");
- val z = 0;
- val x = 4 + z
+ lazy val z = 0;
+ lazy val x = 4 + z
}
def main (args: Array[String]): Unit = {
Console.print((new B).y);
diff --git a/test/files/run/existentials.scala b/test/files/run/existentials.scala
index 471f8fe779..902ae31b5a 100644
--- a/test/files/run/existentials.scala
+++ b/test/files/run/existentials.scala
@@ -69,14 +69,6 @@ object Test extends Application {
case _ =>
}
- var ex: Counter[T] forSome { type T } = _
- ex = ci
- ex = cf
-
- var exW: Counter[_] = _
- ex = ci
- ex = cf
-
val ci = new Counter[Int] {
def newCounter = 0
def get(i: Int) = i
@@ -91,6 +83,14 @@ object Test extends Application {
def name = "Float"
}
+ var ex: Counter[T] forSome { type T } = _
+ ex = ci
+ ex = cf
+
+ var exW: Counter[_] = _
+ ex = ci
+ ex = cf
+
foo(ci)
foo(cf)
fooW(ci)
diff --git a/test/files/run/spec-init.check b/test/files/run/spec-init.check
index 8a659f868c..7705ee2947 100644
--- a/test/files/run/spec-init.check
+++ b/test/files/run/spec-init.check
@@ -1,9 +1,9 @@
abc
abc
-null
+abc
shouldn't see two initialized values and one uninitialized
42
42
-0
+42
ok
ok
diff --git a/test/files/run/spec-init.scala b/test/files/run/spec-init.scala
index bd3428f4ea..60852245b4 100644
--- a/test/files/run/spec-init.scala
+++ b/test/files/run/spec-init.scala
@@ -5,11 +5,10 @@ class Foo[@specialized(Int) T](_x: T) {
val y = x
println(x)
println(y)
- println(z)
def baz {}
val z = y
-
+ println(z)
}
class Bar[@specialized(Int) T] {
diff --git a/test/files/run/t1524.scala b/test/files/run/t1524.scala
index 4f6c65d052..3b06afdbfd 100644
--- a/test/files/run/t1524.scala
+++ b/test/files/run/t1524.scala
@@ -1,6 +1,6 @@
object Test extends Application {
- val buf = new scala.collection.mutable.ArrayBuffer[String] { override val initialSize = 0 }
+ val buf = new scala.collection.mutable.ArrayBuffer[String](0)
buf += "initial"
buf += "second"
println(buf.head)
diff --git a/test/files/run/t3897/J_2.java b/test/files/run/t3897/J_2.java
index 5d5131737e..a4c9a98fb1 100644
--- a/test/files/run/t3897/J_2.java
+++ b/test/files/run/t3897/J_2.java
@@ -4,13 +4,17 @@ public class J_2 {
public void f1(Class<?> clazz) {
Field[] fields = clazz.getDeclaredFields();
for (int i = 0 ; i < fields.length; i++) {
- System.out.println("(" + fields[i].getName() + "," + fields[i].getGenericType() + ")");
+ String name = fields[i].getName();
+ if (name.length() >= 7 && name.substring(0, 7).equals("bitmap$")) { }
+ else System.out.println("(" + name + "," + fields[i].getGenericType() + ")");
}
}
public void f2(Class<?> clazz) {
Method[] methods = clazz.getDeclaredMethods();
for (int i = 0 ; i < methods.length; i++) {
- System.out.println("(" + methods[i].getName() + "," + methods[i].getGenericReturnType() + ")");
+ String name = methods[i].getName();
+ if (name.length() >= 7 && name.substring(0, 7).equals("bitmap$")) { }
+ else System.out.println("(" + name + "," + methods[i].getGenericReturnType() + ")");
}
}
diff --git a/test/files/run/t3897/a_2.scala b/test/files/run/t3897/a_2.scala
index da5f8df63e..7a161fcbe4 100644
--- a/test/files/run/t3897/a_2.scala
+++ b/test/files/run/t3897/a_2.scala
@@ -1,6 +1,16 @@
object Test {
- def f1(clazz: Class[_]) = clazz.getDeclaredFields.toList map (f => (f.getName, f.getGenericType)) foreach println
- def f2(clazz: Class[_]) = clazz.getDeclaredMethods.toList map (f => (f.getName, f.getGenericReturnType)) foreach println
+ def f1(clazz: Class[_]) = (
+ clazz.getDeclaredFields.toList
+ . filterNot (_.getName contains "bitmap$")
+ . map (f => (f.getName, f.getGenericType))
+ . foreach (println)
+ )
+ def f2(clazz: Class[_]) = (
+ clazz.getDeclaredMethods.toList
+ . filterNot (_.getName contains "bitmap$")
+ . map (f => (f.getName, f.getGenericReturnType))
+ . foreach (println)
+ )
def main(args: Array[String]): Unit = {
f1(classOf[One])