From 5618b77ca8d89b8f44db062334ac2b0663596dee Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Tue, 27 Dec 2011 10:36:27 -0800 Subject: Added option -Xlog-reflective-calls. A message is emitted when a reflective call is generated. We can now be eager consumers of this since we purged all the reflective calls at some point -- but without a backstop, they have been slipping back in. --- src/compiler/scala/tools/nsc/settings/ScalaSettings.scala | 1 + src/compiler/scala/tools/nsc/transform/CleanUp.scala | 6 +++++- src/library/scala/collection/parallel/mutable/ParHashMap.scala | 5 ++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala index a712f4cba2..efd5323ce2 100644 --- a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala @@ -68,6 +68,7 @@ trait ScalaSettings extends AbsScalaSettings val genPhaseGraph = StringSetting ("-Xgenerate-phase-graph", "file", "Generate the phase graphs (outputs .dot files) to fileX.dot.", "") val XlogImplicits = BooleanSetting ("-Xlog-implicits", "Show more detail on why some implicits are not applicable.") val logImplicitConv = BooleanSetting ("-Xlog-implicit-conversions", "Print a message whenever an implicit conversion is inserted.") + val logReflectiveCalls = BooleanSetting("-Xlog-reflective-calls", "Print a message when a reflective method call is generated") val maxClassfileName = IntSetting ("-Xmax-classfile-name", "Maximum filename length for generated classes", 255, Some((72, 255)), _ => None) val Xmigration28 = BooleanSetting ("-Xmigration", "Warn about constructs whose behavior may have changed between 2.7 and 2.8.") val nouescape = BooleanSetting ("-Xno-uescape", "Disable handling of \\u unicode escapes.") diff --git a/src/compiler/scala/tools/nsc/transform/CleanUp.scala b/src/compiler/scala/tools/nsc/transform/CleanUp.scala index 98345dd01e..575fe8f295 100644 --- a/src/compiler/scala/tools/nsc/transform/CleanUp.scala +++ b/src/compiler/scala/tools/nsc/transform/CleanUp.scala @@ -106,6 +106,9 @@ abstract class CleanUp extends Transform with ast.TreeDSL { * refinement, where the refinement defines a parameter based on a * type variable. */ case ad@ApplyDynamic(qual0, params) => + if (settings.logReflectiveCalls.value) + unit.echo(ad.pos, "method invocation uses reflection") + val typedPos = typedWithPos(ad.pos) _ assert(ad.symbol.isPublic) @@ -502,7 +505,8 @@ abstract class CleanUp extends Transform with ast.TreeDSL { * expected to be an AnyRef. */ val t: Tree = ad.symbol.tpe match { case MethodType(mparams, resType) => - assert(params.length == mparams.length) + assert(params.length == mparams.length, mparams) + typedPos { val sym = currentOwner.newValue(ad.pos, mkTerm("qual")) setInfo qual0.tpe qual = safeREF(sym) diff --git a/src/library/scala/collection/parallel/mutable/ParHashMap.scala b/src/library/scala/collection/parallel/mutable/ParHashMap.scala index 37065e32fc..31750b0b0d 100644 --- a/src/library/scala/collection/parallel/mutable/ParHashMap.scala +++ b/src/library/scala/collection/parallel/mutable/ParHashMap.scala @@ -190,7 +190,7 @@ extends collection.parallel.BucketCombiner[(K, V), ParHashMap[K, V], DefaultEntr } else { // construct a normal table and fill it sequentially // TODO parallelize by keeping separate sizemaps and merging them - val table = new HashTable[K, DefaultEntry[K, V]] { + object table extends HashTable[K, DefaultEntry[K, V]] { def insertEntry(e: DefaultEntry[K, V]) = if (super.findEntry(e.key) eq null) super.addEntry(e) sizeMapInit(table.length) } @@ -201,8 +201,7 @@ extends collection.parallel.BucketCombiner[(K, V), ParHashMap[K, V], DefaultEntr } i += 1 } - val c = table.hashTableContents - new ParHashMap(c) + new ParHashMap(table.hashTableContents) } /* classes */ -- cgit v1.2.3