summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala204
-rw-r--r--test/files/run/t2849.scala24
2 files changed, 116 insertions, 112 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala
index 6a3c7a000a..41df23427b 100644
--- a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala
+++ b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala
@@ -73,8 +73,7 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid {
def moduleSuffix(sym: Symbol) =
if (sym.hasModuleFlag && !sym.isMethod &&
!sym.isImplClass && !sym.isJavaDefined) "$"
- else "";
-
+ else ""
var pickledBytes = 0 // statistics
@@ -126,9 +125,9 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid {
val versionPickle = {
val vp = new PickleBuffer(new Array[Byte](16), -1, 0)
assert(vp.writeIndex == 0)
- vp.writeNat(PickleFormat.MajorVersion)
- vp.writeNat(PickleFormat.MinorVersion)
- vp.writeNat(0)
+ vp writeNat PickleFormat.MajorVersion
+ vp writeNat PickleFormat.MinorVersion
+ vp writeNat 0
vp
}
@@ -138,7 +137,8 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid {
var jmethod: JMethod = _
// var jcode: JExtendedCode = _
- var innerClasses: immutable.Set[Symbol] = immutable.ListSet.empty // referenced inner classes
+ // referenced inner classes
+ var innerClasses: immutable.Set[Symbol] = immutable.ListSet.empty
val fjbgContext = new FJBGContext(49, 0)
@@ -156,7 +156,7 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid {
addInnerClasses(jclass)
val outfile = getFile(sym, jclass, ".class")
val outstream = new DataOutputStream(outfile.bufferedOutput)
- jclass.writeTo(outstream)
+ jclass writeTo outstream
outstream.close()
informProgress("wrote " + outfile)
}
@@ -181,12 +181,12 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid {
* signature (a Scala marker attribute has been written).
*/
def scalaSignatureAddingMarker(jclass: JClass, sym: Symbol): Option[AnnotationInfo] =
- currentRun.symData.get(sym) match {
+ currentRun.symData get sym match {
case Some(pickle) if !jclass.getName().endsWith("$") =>
val scalaAttr =
fjbgContext.JOtherAttribute(jclass, jclass, tpnme.ScalaSignatureATTR.toString,
versionPickle.bytes, versionPickle.writeIndex)
- jclass.addAttribute(scalaAttr)
+ jclass addAttribute scalaAttr
val scalaAnnot = {
val sigBytes = ScalaSigBytes(pickle.bytes.take(pickle.writeIndex))
AnnotationInfo(sigBytes.sigAnnot, Nil, List((nme.bytes, sigBytes)))
@@ -198,7 +198,7 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid {
case _ =>
val markerAttr =
fjbgContext.JOtherAttribute(jclass, jclass, tpnme.ScalaATTR.toString, new Array[Byte](0), 0)
- jclass.addAttribute(markerAttr)
+ jclass addAttribute markerAttr
None
}
@@ -253,12 +253,12 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid {
if (isStaticModule(c.symbol) || serialVUID != None || isParcelableClass ||
clasz.bootstrapClass.isDefined) {
if (isStaticModule(c.symbol))
- addModuleInstanceField;
+ addModuleInstanceField
addStaticInit(jclass, c.lookupStaticCtor)
if (isTopLevelModule(c.symbol)) {
if (c.symbol.companionClass == NoSymbol)
- dumpMirrorClass(c.symbol, c.cunit.source.toString);
+ dumpMirrorClass(c.symbol, c.cunit.source.toString)
else
log("No mirror class for module with linked class: " +
c.symbol.fullName)
@@ -269,7 +269,7 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid {
// it must be a top level class (name contains no $s)
def isCandidateForForwarders(sym: Symbol): Boolean =
- atPhase (currentRun.picklerPhase.next) {
+ atPhase(currentRun.picklerPhase.next) {
!(sym.name.toString contains '$') && sym.hasModuleFlag && !sym.isImplClass && !sym.isNestedClass
}
@@ -292,7 +292,7 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid {
val ssa = scalaSignatureAddingMarker(jclass, c.symbol)
addGenericSignature(jclass, c.symbol, c.symbol.owner)
addAnnotations(jclass, c.symbol.annotations ++ ssa)
- if (needsEnclosingMethod) addEnclosingMethodAttribute(jclass, c.symbol)
+ if (needsEnclosingMethod) addEnclosingMethodAttribute(jclass, c.symbol)
emitClass(jclass, c.symbol)
if (c.symbol hasAnnotation BeanInfoAttr)
@@ -304,7 +304,7 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid {
if (sym.isMethod) {
log("enclosing method for %s is %s".format(clazz, sym))
var outerName = javaName(sym.enclClass)
- jclass.addAttribute(fjbgContext.JEnclosingMethodAttribute(jclass, outerName, javaName(sym), javaType(sym)))
+ jclass addAttribute fjbgContext.JEnclosingMethodAttribute(jclass, outerName, javaName(sym), javaType(sym))
}
}
@@ -315,7 +315,7 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid {
*/
def genBeanInfoClass(c: IClass) {
val description = c.symbol.annotations.find(_.atp.typeSymbol == BeanDescriptionAttr)
- // informProgress(description.toString())
+ // informProgress(description.toString)
val beanInfoClass = fjbgContext.JClass(javaFlags(c.symbol),
javaName(c.symbol) + "BeanInfo",
@@ -347,28 +347,28 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid {
var fi = 0
for (f <- lst) {
jcode.emitDUP()
- jcode.emitPUSH(fi)
+ jcode emitPUSH fi
if (f != null)
- jcode.emitPUSH(f)
+ jcode emitPUSH f
else
jcode.emitACONST_NULL()
- jcode.emitASTORE(strKind)
+ jcode emitASTORE strKind
fi += 1
}
}
jcode.emitALOAD_0()
// push the class
- jcode.emitPUSH(javaType(c.symbol).asInstanceOf[JReferenceType])
+ jcode emitPUSH javaType(c.symbol).asInstanceOf[JReferenceType]
// push the the string array of field information
- jcode.emitPUSH(fieldList.length)
- jcode.emitANEWARRAY(strKind)
+ jcode emitPUSH fieldList.length
+ jcode emitANEWARRAY strKind
push(fieldList)
// push the string array of method information
- jcode.emitPUSH(methodList.length)
- jcode.emitANEWARRAY(strKind)
+ jcode emitPUSH methodList.length
+ jcode emitANEWARRAY strKind
push(methodList)
// invoke the superclass constructor, which will do the
@@ -379,22 +379,21 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid {
// write the bean information class file.
val outfile = getFile(c.symbol, beanInfoClass, ".class")
val outstream = new DataOutputStream(outfile.bufferedOutput)
- beanInfoClass.writeTo(outstream)
+ beanInfoClass writeTo outstream
outstream.close()
informProgress("wrote BeanInfo " + outfile)
}
-
/** Add the given 'throws' attributes to jmethod */
def addExceptionsAttribute(jmethod: JMethod, excs: List[AnnotationInfo]) {
if (excs.isEmpty) return
- val cpool = jmethod.getConstantPool()
+ val cpool = jmethod.getConstantPool
val buf: ByteBuffer = ByteBuffer.allocate(512)
var nattr = 0
// put some random value; the actual number is determined at the end
- buf.putShort(0xbaba.toShort)
+ buf putShort 0xbaba.toShort
for (AnnotationInfo(tp, List(exc), _) <- excs.distinct if tp.typeSymbol == ThrowsClass) {
val Literal(const) = exc
@@ -413,83 +412,83 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid {
* .initialize: if 'annot' is read from pickle, atp might be un-initialized
*/
private def shouldEmitAnnotation(annot: AnnotationInfo) =
- (annot.atp.typeSymbol.initialize.isJavaDefined &&
- annot.atp.typeSymbol.isNonBottomSubClass(ClassfileAnnotationClass) &&
- annot.args.isEmpty)
+ annot.atp.typeSymbol.initialize.isJavaDefined &&
+ annot.atp.typeSymbol.isNonBottomSubClass(ClassfileAnnotationClass) &&
+ annot.args.isEmpty
private def emitJavaAnnotations(cpool: JConstantPool, buf: ByteBuffer, annotations: List[AnnotationInfo]): Int = {
def emitArgument(arg: ClassfileAnnotArg): Unit = arg match {
case LiteralAnnotArg(const) =>
const.tag match {
case BooleanTag =>
- buf.put('Z'.toByte)
- buf.putShort(cpool.addInteger(if(const.booleanValue) 1 else 0).toShort)
+ buf put 'Z'.toByte
+ buf putShort cpool.addInteger(if(const.booleanValue) 1 else 0).toShort
case ByteTag =>
- buf.put('B'.toByte)
- buf.putShort(cpool.addInteger(const.byteValue).toShort)
+ buf put 'B'.toByte
+ buf putShort cpool.addInteger(const.byteValue).toShort
case ShortTag =>
- buf.put('S'.toByte)
- buf.putShort(cpool.addInteger(const.shortValue).toShort)
+ buf put 'S'.toByte
+ buf putShort cpool.addInteger(const.shortValue).toShort
case CharTag =>
- buf.put('C'.toByte)
- buf.putShort(cpool.addInteger(const.charValue).toShort)
+ buf put 'C'.toByte
+ buf putShort cpool.addInteger(const.charValue).toShort
case IntTag =>
- buf.put('I'.toByte)
- buf.putShort(cpool.addInteger(const.intValue).toShort)
+ buf put 'I'.toByte
+ buf putShort cpool.addInteger(const.intValue).toShort
case LongTag =>
- buf.put('J'.toByte)
- buf.putShort(cpool.addLong(const.longValue).toShort)
+ buf put 'J'.toByte
+ buf putShort cpool.addLong(const.longValue).toShort
case FloatTag =>
- buf.put('F'.toByte)
- buf.putShort(cpool.addFloat(const.floatValue).toShort)
+ buf put 'F'.toByte
+ buf putShort cpool.addFloat(const.floatValue).toShort
case DoubleTag =>
- buf.put('D'.toByte)
- buf.putShort(cpool.addDouble(const.doubleValue).toShort)
+ buf put 'D'.toByte
+ buf putShort cpool.addDouble(const.doubleValue).toShort
case StringTag =>
- buf.put('s'.toByte)
- buf.putShort(cpool.addUtf8(const.stringValue).toShort)
+ buf put 's'.toByte
+ buf putShort cpool.addUtf8(const.stringValue).toShort
case ClassTag =>
- buf.put('c'.toByte)
- buf.putShort(cpool.addUtf8(javaType(const.typeValue).getSignature()).toShort)
+ buf put 'c'.toByte
+ buf putShort cpool.addUtf8(javaType(const.typeValue).getSignature()).toShort
case EnumTag =>
- buf.put('e'.toByte)
- buf.putShort(cpool.addUtf8(javaType(const.tpe).getSignature()).toShort)
- buf.putShort(cpool.addUtf8(const.symbolValue.name.toString).toShort)
+ buf put 'e'.toByte
+ buf putShort cpool.addUtf8(javaType(const.tpe).getSignature()).toShort
+ buf putShort cpool.addUtf8(const.symbolValue.name.toString).toShort
}
case sb@ScalaSigBytes(bytes) if !sb.isLong =>
- buf.put('s'.toByte)
- buf.putShort(cpool.addUtf8(sb.encodedBytes).toShort)
+ buf put 's'.toByte
+ buf putShort cpool.addUtf8(sb.encodedBytes).toShort
case sb@ScalaSigBytes(bytes) if sb.isLong =>
- buf.put('['.toByte)
+ buf put '['.toByte
val stringCount = (sb.encodedBytes.length / 65534) + 1
- buf.putShort(stringCount.toShort)
+ buf putShort stringCount.toShort
for (i <- 0 until stringCount) {
- buf.put('s'.toByte)
+ buf put 's'.toByte
val j = i * 65535
val string = sb.encodedBytes.slice(j, j + 65535)
- buf.putShort(cpool.addUtf8(string).toShort)
+ buf putShort cpool.addUtf8(string).toShort
}
case ArrayAnnotArg(args) =>
- buf.put('['.toByte)
- buf.putShort(args.length.toShort)
+ buf put '['.toByte
+ buf putShort args.length.toShort
args foreach emitArgument
case NestedAnnotArg(annInfo) =>
- buf.put('@'.toByte)
+ buf put '@'.toByte
emitAnnotation(annInfo)
}
def emitAnnotation(annotInfo: AnnotationInfo) {
val AnnotationInfo(typ, args, assocs) = annotInfo
val jtype = javaType(typ)
- buf.putShort(cpool.addUtf8(jtype.getSignature()).toShort)
+ buf putShort cpool.addUtf8(jtype.getSignature()).toShort
assert(args.isEmpty, args.toString)
- buf.putShort(assocs.length.toShort)
+ buf putShort assocs.length.toShort
for ((name, value) <- assocs) {
- buf.putShort(cpool.addUtf8(name.toString).toShort)
+ buf putShort cpool.addUtf8(name.toString).toShort
emitArgument(value)
}
}
@@ -498,7 +497,7 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid {
val pos = buf.position()
// put some random value; the actual number of annotations is determined at the end
- buf.putShort(0xbaba.toShort)
+ buf putShort 0xbaba.toShort
for (annot <- annotations if shouldEmitAnnotation(annot)) {
nannots += 1
@@ -510,12 +509,15 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid {
nannots
}
- // @M don't generate java generics sigs for (members of) implementation classes, as they are monomorphic (TODO: ok?)
+ // @M don't generate java generics sigs for (members of) implementation
+ // classes, as they are monomorphic (TODO: ok?)
private def noGenericSignature(sym: Symbol) = (
- // PP: This condition used to include sym.hasExpandedName, but this leads to the total loss
- // of generic information if a private member is accessed from a closure: both the field and
- // the accessor were generated without it. This is particularly bad because the availability
- // of generic information could disappear as a consequence of a seemingly unrelated change.
+ // PP: This condition used to include sym.hasExpandedName, but this leads
+ // to the total loss of generic information if a private member is
+ // accessed from a closure: both the field and the accessor were generated
+ // without it. This is particularly bad because the availability of
+ // generic information could disappear as a consequence of a seemingly
+ // unrelated change.
sym.isSynthetic
|| sym.isLiftedMethod
|| (sym.ownerChain exists (_.isImplClass))
@@ -530,13 +532,13 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid {
if (settings.Yverifysigs.value)
verifySig(sym, sig)
- val index = jmember.getConstantPool().addUtf8(sig).toShort
+ val index = jmember.getConstantPool.addUtf8(sig).toShort
if (settings.debug.value && settings.verbose.value)
atPhase(currentRun.erasurePhase) {
println("add generic sig "+sym+":"+sym.info+" ==> "+sig+" @ "+index)
}
val buf = ByteBuffer.allocate(2)
- buf.putShort(index)
+ buf putShort index
addAttribute(jmember, tpnme.SignatureATTR, buf)
}
}
@@ -623,15 +625,17 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid {
val innerClassesAttr = jclass.getInnerClasses()
// sort them so inner classes succeed their enclosing class
// to satisfy the Eclipse Java compiler
- for (innerSym <- innerClasses.toList sortBy (_.name.length)) {
+ //for (innerSym <- innerClasses.toList sortBy (_.name.length)) {
+ for (innerSym <- innerClasses.toList sortBy (_.name.length);
+ outer = outerName(innerSym) if outer != null) {
var flags = javaFlags(innerSym)
if (innerSym.rawowner.hasModuleFlag)
flags |= ACC_STATIC
innerClassesAttr.addEntry(javaName(innerSym),
- outerName(innerSym),
+ outer, //outerName(innerSym),
innerName(innerSym),
- (flags & INNER_CLASSES_FLAGS));
+ (flags & INNER_CLASSES_FLAGS))
}
}
}
@@ -669,10 +673,10 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid {
var resTpe = javaType(m.symbol.tpe.resultType)
if (m.symbol.isClassConstructor)
- resTpe = JType.VOID;
+ resTpe = JType.VOID
var flags = javaFlags(m.symbol)
- if (jclass.isInterface())
+ if (jclass.isInterface)
flags |= ACC_ABSTRACT
if (m.symbol.isStrictFP)
@@ -686,7 +690,7 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid {
javaName(m.symbol),
resTpe,
javaTypes(m.params map (_.kind)),
- javaNames(m.params map (_.sym)));
+ javaNames(m.params map (_.sym)))
addRemoteException(jmethod, m.symbol)
@@ -713,7 +717,7 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid {
for (local <- m.locals if ! m.params.contains(local)) {
if (settings.debug.value)
- log("add local var: " + local);
+ log("add local var: " + local)
jmethod.addNewLocalVariable(javaType(local.kind), javaName(local.sym))
}
@@ -740,7 +744,7 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid {
}
if (isRemoteClass ||
- (meth.hasAnnotation(RemoteAttr) && jmethod.isPublic())) {
+ (meth.hasAnnotation(RemoteAttr) && jmethod.isPublic)) {
val c = Constant(RemoteException)
val ainfo = AnnotationInfo(ThrowsClass.tpe, List(Literal(c).setType(c.tpe)), List())
if (!meth.annotations.exists(isRemoteThrows)) {
@@ -764,7 +768,7 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid {
(sym.name == nme.apply) &&
sym.owner.isSynthetic &&
sym.owner.tpe.parents.exists { t =>
- val TypeRef(_, sym, _) = t;
+ val TypeRef(_, sym, _) = t
FunctionClass contains sym
}
}
@@ -793,8 +797,8 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid {
if (isStaticModule(clasz.symbol)) {
// call object's private ctor from static ctor
- lastBlock.emit(NEW(REFERENCE(m.symbol.enclClass)))
- lastBlock.emit(CALL_METHOD(m.symbol.enclClass.primaryConstructor, Static(true)))
+ lastBlock emit NEW(REFERENCE(m.symbol.enclClass))
+ lastBlock emit CALL_METHOD(m.symbol.enclClass.primaryConstructor, Static(true))
}
// add serialVUID code
@@ -897,7 +901,7 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid {
i += 1
}
- mirrorCode.emitINVOKEVIRTUAL(moduleName, mirrorMethod.getName(), javaType(m).asInstanceOf[JMethodType])
+ mirrorCode.emitINVOKEVIRTUAL(moduleName, mirrorMethod.getName, javaType(m).asInstanceOf[JMethodType])
mirrorCode emitRETURN mirrorMethod.getReturnType()
addRemoteException(mirrorMethod, m)
@@ -1054,7 +1058,7 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid {
if (!covered.isEmpty)
if (settings.debug.value)
log("Some covered blocks were not found in method: " + method +
- " covered: " + covered + " not in " + linearization);
+ " covered: " + covered + " not in " + linearization)
ranges
}
@@ -1077,7 +1081,7 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid {
labels(b).anchorToNext()
if (settings.debug.value)
- log("Generating code for block: " + b + " at pc: " + labels(b).getAnchor());
+ log("Generating code for block: " + b + " at pc: " + labels(b).getAnchor())
var lastMappedPC = 0
var lastLineNr = 0
var crtPC = 0
@@ -1137,7 +1141,7 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid {
javaType(module));
case STORE_ARRAY_ITEM(kind) =>
- jcode.emitASTORE(javaType(kind))
+ jcode emitASTORE javaType(kind)
case STORE_LOCAL(local) =>
jcode.emitSTORE(indexOf(local), javaType(local.kind))
@@ -1266,11 +1270,11 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid {
i += 1
}
if (settings.debug.value)
- log("Emitting SWITCH:\ntags: " + tags + "\nbranches: " + branches);
+ log("Emitting SWITCH:\ntags: " + tags + "\nbranches: " + branches)
jcode.emitSWITCH(tagArray,
branchArray,
labels(branches.last),
- MIN_SWITCH_DENSITY);
+ MIN_SWITCH_DENSITY)
()
case JUMP(whereto) =>
@@ -1286,7 +1290,7 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid {
} else {
jcode.emitIF_ICMP(conds(cond), labels(success))
if (nextBlock != failure)
- jcode.emitGOTO_maybe_W(labels(failure), false);
+ jcode.emitGOTO_maybe_W(labels(failure), false)
}
case REFERENCE(_) | ARRAY(_) =>
@@ -1296,7 +1300,7 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid {
} else {
jcode.emitIF_ACMP(conds(cond), labels(success))
if (nextBlock != failure)
- jcode.emitGOTO_maybe_W(labels(failure), false);
+ jcode.emitGOTO_maybe_W(labels(failure), false)
}
case _ =>
@@ -1310,12 +1314,12 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid {
else jcode.emitDCMPL()
}
if (nextBlock == success) {
- jcode.emitIF(conds(negate(cond)), labels(failure));
+ jcode.emitIF(conds(negate(cond)), labels(failure))
// .. and fall through to success label
} else {
jcode.emitIF(conds(cond), labels(success));
if (nextBlock != failure)
- jcode.emitGOTO_maybe_W(labels(failure), false);
+ jcode.emitGOTO_maybe_W(labels(failure), false)
}
}
@@ -1327,7 +1331,7 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid {
} else {
jcode.emitIF(conds(cond), labels(success))
if (nextBlock != failure)
- jcode.emitGOTO_maybe_W(labels(failure), false);
+ jcode.emitGOTO_maybe_W(labels(failure), false)
}
case REFERENCE(_) | ARRAY(_) =>
@@ -1368,7 +1372,7 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid {
} else {
jcode.emitIF(conds(cond), labels(success))
if (nextBlock != failure)
- jcode.emitGOTO_maybe_W(labels(failure), false);
+ jcode.emitGOTO_maybe_W(labels(failure), false)
}
}
@@ -1428,7 +1432,7 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid {
}
if (b.lastInstruction == instr)
- endPC(b) = jcode.getPC();
+ endPC(b) = jcode.getPC()
//System.err.println("CRTLINE: " + instr.pos + " " +
// /* (if (instr.pos < clasz.cunit.source.content.length) clasz.cunit.source.content(instr.pos) else '*') + */ " " + crtLine);
@@ -1637,7 +1641,7 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid {
var vars = m.locals filterNot (_.sym.isSynthetic)
if (vars.length == 0) return
- val pool = jclass.getConstantPool()
+ val pool = jclass.getConstantPool
val pc = jcode.getPC()
var anonCounter = 0
var entries = 0
@@ -1731,7 +1735,6 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid {
super.javaName(sym)
}
-
/** Calls to methods in 'sym' need invokeinterface? */
def needsInterfaceCall(sym: Symbol): Boolean = {
log("checking for interface call: " + sym.fullName)
@@ -1819,5 +1822,4 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid {
sym.isModuleClass && !sym.isImplClass && !sym.isLifted
}
-
}
diff --git a/test/files/run/t2849.scala b/test/files/run/t2849.scala
index 68094de736..cadf605ae0 100644
--- a/test/files/run/t2849.scala
+++ b/test/files/run/t2849.scala
@@ -1,11 +1,6 @@
-
-
-
import scala.collection.immutable.SortedSet
import scala.collection.immutable.TreeSet
-
-
object Test {
def main(args: Array[String]) {
@@ -13,15 +8,22 @@ object Test {
similarExample
}
+ //def freeMBytes = Runtime.getRuntime.freeMemory / 1048576
+ def totalMBytes = Runtime.getRuntime.totalMemory / 1048576
+
+ val N = if (totalMBytes > 1000) 10000 else 4000
+ val M = N / 10
+
def ticketExample {
var big = 100000
var aSortedSet: SortedSet[Int] = TreeSet(big)
- for (i <- 1 until 10000) {
+ for (i <- 1 until N) {
aSortedSet = (aSortedSet - big) ++ (TreeSet(i, big - 1))
- big = big - 1
- if (i % 1000 == 0) {
+ big -= 1
+ if (i % M == 0) {
+ //println("big: "+big+", free memory: "+freeMBytes)
aSortedSet.until(i)
}
}
@@ -32,10 +34,10 @@ object Test {
var aSortedSet: SortedSet[Int] = TreeSet(big)
- for (i <- 1 until 10000) {
+ for (i <- 1 until N) {
aSortedSet = (aSortedSet - big) ++ (TreeSet(i, big - 1)) + big
- big = big - 1
- if (i % 1000 == 0) {
+ big -= 1
+ if (i % M == 0) {
aSortedSet.until(i)
}
}