summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-02-28 14:43:47 +0000
committerPaul Phillips <paulp@improving.org>2011-02-28 14:43:47 +0000
commitbee568cb56a72f4e17bf3340c15a55d999a232ff (patch)
treef091d21f608f3a209c29450fb7d1425f9f8ecb76
parentba236bdcdcf0816ffad8b4d17b90b69c80a80ac7 (diff)
downloadscala-bee568cb56a72f4e17bf3340c15a55d999a232ff.tar.gz
scala-bee568cb56a72f4e17bf3340c15a55d999a232ff.tar.bz2
scala-bee568cb56a72f4e17bf3340c15a55d999a232ff.zip
Altered a check for impl classes to look at the...
Altered a check for impl classes to look at the name instead of the flags, since the flags are wrong. Obviously we should fix the flags or otherwise better address. Note that the test is well intentioned but doesn't actually fail with older versions; the crash is not easy to reproduce even when I simulate the whole repl. Review by dragos.
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Symbols.scala14
-rw-r--r--src/compiler/scala/tools/nsc/transform/Mixin.scala9
-rw-r--r--test/files/run/bug4285.check9
-rw-r--r--test/files/run/bug4285.flags1
-rw-r--r--test/files/run/bug4285.scala7
5 files changed, 33 insertions, 7 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/Symbols.scala b/src/compiler/scala/tools/nsc/symtab/Symbols.scala
index 98bd271556..e6b2c1e450 100644
--- a/src/compiler/scala/tools/nsc/symtab/Symbols.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Symbols.scala
@@ -1640,14 +1640,16 @@ trait Symbols extends reflect.generic.Symbols { self: SymbolTable =>
else if (variance == -1) "-"
else ""
+ def defaultFlagMask =
+ if (settings.debug.value) -1L
+ else if (owner.isRefinementClass) ExplicitFlags & ~OVERRIDE
+ else ExplicitFlags
+
+ def defaultFlagString = hasFlagsToString(defaultFlagMask)
+
/** String representation of symbol's definition */
def defString: String = {
- val mask =
- if (settings.debug.value) -1L
- else if (owner.isRefinementClass) ExplicitFlags & ~OVERRIDE
- else ExplicitFlags
-
- compose(List(hasFlagsToString(mask), keyString, varianceString + nameString +
+ compose(List(defaultFlagString, keyString, varianceString + nameString +
(if (hasRawInfo) infoString(rawInfo) else "<_>")))
}
diff --git a/src/compiler/scala/tools/nsc/transform/Mixin.scala b/src/compiler/scala/tools/nsc/transform/Mixin.scala
index 549f6f2abb..866f66cf74 100644
--- a/src/compiler/scala/tools/nsc/transform/Mixin.scala
+++ b/src/compiler/scala/tools/nsc/transform/Mixin.scala
@@ -250,7 +250,14 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL {
/** Mix in members of implementation class mixinClass into class clazz */
def mixinImplClassMembers(impl: Symbol, iface: Symbol) {
- assert (impl.isImplClass)
+ assert(
+ // XXX this should be impl.isImplClass, except that we get impl classes
+ // coming through under -optimise which do not agree that they are (because
+ // the IMPLCLASS flag is unset, I believe.) See ticket #4285.
+ nme.isImplClassName(impl.name),
+ "%s (%s) is not a an implementation class, it cannot mix in %s".format(
+ impl, impl.defaultFlagString, iface)
+ )
for (member <- impl.info.decls.toList) {
if (isForwarded(member)) {
val imember = member.overriddenSymbol(iface)
diff --git a/test/files/run/bug4285.check b/test/files/run/bug4285.check
new file mode 100644
index 0000000000..6f906f80a6
--- /dev/null
+++ b/test/files/run/bug4285.check
@@ -0,0 +1,9 @@
+Welcome to Scala version 2.9.0.r24351-b20110228153004 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_22).
+Type in expressions to have them evaluated.
+Type :help for more information.
+
+scala> 56
+x: Array[Int] = Array(2, 4, 6, 8, 10, 12, 14)
+y: scala.collection.mutable.WrappedArray[Int] = WrappedArray(2, 4, 6, 8, 10, 12, 14)
+
+scala>
diff --git a/test/files/run/bug4285.flags b/test/files/run/bug4285.flags
new file mode 100644
index 0000000000..eb4d19bcb9
--- /dev/null
+++ b/test/files/run/bug4285.flags
@@ -0,0 +1 @@
+-optimise \ No newline at end of file
diff --git a/test/files/run/bug4285.scala b/test/files/run/bug4285.scala
new file mode 100644
index 0000000000..9e89b13a3a
--- /dev/null
+++ b/test/files/run/bug4285.scala
@@ -0,0 +1,7 @@
+object Test {
+ def main(args: Array[String]): Unit = {
+ println(scala.tools.nsc.interpreter.ILoop.run("val x = Array(1,2,3,4,5,6,7) ; val y = x transform (_ * 2) ; println(y.sum)"))
+ }
+}
+
+