summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2009-03-31 18:08:39 +0000
committerPaul Phillips <paulp@improving.org>2009-03-31 18:08:39 +0000
commit79c1f9882a31a833bb02ecbbdfdcb6ca61d2c522 (patch)
treec3647eb1a56b0a62b11e06e0ca0f6ea1014f67a4
parent16d4b1d76a6388c0dea5ee118c4f94a0f4b15fc5 (diff)
downloadscala-79c1f9882a31a833bb02ecbbdfdcb6ca61d2c522.tar.gz
scala-79c1f9882a31a833bb02ecbbdfdcb6ca61d2c522.tar.bz2
scala-79c1f9882a31a833bb02ecbbdfdcb6ca61d2c522.zip
Moved static forwarder generation behind -Xforw...
Moved static forwarder generation behind -Xforwarders option. Special cased main so #363 continues to work. Moved test case for #1745 into pending since it requires forwarders to work.
-rw-r--r--src/compiler/scala/tools/nsc/Settings.scala1
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala22
-rw-r--r--test/files/pos/t1840/J.java (renamed from test/pending/pos/t1840/J.java)0
-rw-r--r--test/files/pos/t1840/S.scala (renamed from test/pending/pos/t1840/S.scala)0
-rw-r--r--test/files/pos5/misc-pos.log4
-rw-r--r--test/pending/pos5/t1745/J.java (renamed from test/files/pos5/t1745/J.java)0
-rw-r--r--test/pending/pos5/t1745/S.scala (renamed from test/files/pos5/t1745/S.scala)0
7 files changed, 17 insertions, 10 deletions
diff --git a/src/compiler/scala/tools/nsc/Settings.scala b/src/compiler/scala/tools/nsc/Settings.scala
index f13e1cfa21..6026186010 100644
--- a/src/compiler/scala/tools/nsc/Settings.scala
+++ b/src/compiler/scala/tools/nsc/Settings.scala
@@ -618,6 +618,7 @@ trait ScalacSettings
val checkInit = BooleanSetting ("-Xcheckinit", "Add runtime checks on field accessors. Uninitialized accesses result in an exception being thrown.")
val noassertions = BooleanSetting ("-Xdisable-assertions", "Generate no assertions and assumptions")
val Xexperimental = BooleanSetting ("-Xexperimental", "Enable experimental extensions")
+ val forwarders = BooleanSetting ("-Xforwarders", "Generate static forwarders in mirror classes")
val future = BooleanSetting ("-Xfuture", "Turn on future language features")
val genPhaseGraph = StringSetting ("-Xgenerate-phase-graph", "file", "Generate the phase graphs (outputs .dot files) to fileX.dot", "")
val XlogImplicits = BooleanSetting ("-Xlog-implicits", "Show more info on why some implicits are not applicable")
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala
index cee270e555..e77333581b 100644
--- a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala
+++ b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala
@@ -209,10 +209,17 @@ abstract class GenJVM extends SubComponent {
}
}
else {
+ val lmoc = c.symbol.linkedModuleOfClass
// add static forwarders if there are no name conflicts; see bugs #363 and #1735
- if (c.symbol.linkedModuleOfClass != NoSymbol && !c.symbol.hasFlag(Flags.INTERFACE)) {
- log("Adding forwarders to existing class " + c.symbol + " found in module " + c.symbol.linkedModuleOfClass)
- addForwarders(jclass, c.symbol.linkedModuleOfClass.moduleClass)
+ if (lmoc != NoSymbol && !c.symbol.hasFlag(Flags.INTERFACE)) {
+ // forwarders were creating many issues, see #1795 for instance; so for now
+ // they are only enabled if -Xforwarders is supplied to scalac...
+ if (settings.forwarders.value) {
+ log("Adding forwarders to existing class " + c.symbol + " found in module " + lmoc)
+ addForwarders(jclass, lmoc.moduleClass)
+ }
+ // ...but we special case main so at least ticket #363 can continue to work.
+ else addForwarders(jclass, lmoc.moduleClass, _.name == nme.main)
}
}
@@ -228,6 +235,7 @@ abstract class GenJVM extends SubComponent {
genBeanInfoClass(c)
}
+
/**
* Generate a bean info class that describes the given class.
*
@@ -748,9 +756,11 @@ abstract class GenJVM extends SubComponent {
/** Add forwarders for all methods defined in `module' that don't conflict with
* methods in the companion class of `module'. A conflict arises when a method
* with the same name is defined both in a class and its companion object (method
- * signature is not taken into account).
+ * signature is not taken into account). If 3rd argument cond is supplied, only
+ * symbols for which cond(sym) is true are given forwarders.
*/
- def addForwarders(jclass: JClass, module: Symbol) {
+ def addForwarders(jclass: JClass, module: Symbol) { addForwarders(jclass, module, _ => true) }
+ def addForwarders(jclass: JClass, module: Symbol, cond: (Symbol) => Boolean) {
def conflictsIn(cls: Symbol, name: Name) =
cls.info.nonPrivateMembers.exists(_.name == name)
@@ -784,7 +794,7 @@ abstract class GenJVM extends SubComponent {
if (settings.debug.value)
log("Dumping mirror class for object: " + module);
- for (m <- module.info.nonPrivateMembers; if shouldForward(m))
+ for (m <- module.info.nonPrivateMembers; if shouldForward(m) ; if cond(m))
addForwarder(jclass, module, m)
}
diff --git a/test/pending/pos/t1840/J.java b/test/files/pos/t1840/J.java
index 3914721431..3914721431 100644
--- a/test/pending/pos/t1840/J.java
+++ b/test/files/pos/t1840/J.java
diff --git a/test/pending/pos/t1840/S.scala b/test/files/pos/t1840/S.scala
index 00ab0ff3b1..00ab0ff3b1 100644
--- a/test/pending/pos/t1840/S.scala
+++ b/test/files/pos/t1840/S.scala
diff --git a/test/files/pos5/misc-pos.log b/test/files/pos5/misc-pos.log
deleted file mode 100644
index b921dd4d64..0000000000
--- a/test/files/pos5/misc-pos.log
+++ /dev/null
@@ -1,4 +0,0 @@
-A.java:3: error: illegal cyclic reference involving object A
-import static test.A.STATE.UNDEF;
- ^
-one error found
diff --git a/test/files/pos5/t1745/J.java b/test/pending/pos5/t1745/J.java
index 8444eabb24..8444eabb24 100644
--- a/test/files/pos5/t1745/J.java
+++ b/test/pending/pos5/t1745/J.java
diff --git a/test/files/pos5/t1745/S.scala b/test/pending/pos5/t1745/S.scala
index 70210ba502..70210ba502 100644
--- a/test/files/pos5/t1745/S.scala
+++ b/test/pending/pos5/t1745/S.scala