From 7f2d1fab225565794b41c1ea4606430acf8dd270 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Sun, 5 Feb 2017 15:12:09 -0700 Subject: Avoid forcing info transforms of primitive methods Although this is cheap, when debugging log output of info transformer activity this was a major source of noise. This commit avoids the info lookup for methods other than `+`, and then for `+` uses the typer phase info to distinguish concatentation from addition. --- src/compiler/scala/tools/nsc/Global.scala | 5 +++-- src/compiler/scala/tools/nsc/backend/ScalaPrimitives.scala | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'src/compiler/scala/tools/nsc') diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index c1b0733895..819887f959 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -953,10 +953,11 @@ class Global(var currentSettings: Settings, var reporter: Reporter) definitions.isDefinitionsInitialized && rootMirror.isMirrorInitialized ) - override def isPastTyper = ( + override def isPastTyper = isPast(currentRun.typerPhase) + def isPast(phase: Phase) = ( (curRun ne null) && isGlobalInitialized // defense against init order issues - && (globalPhase.id > currentRun.typerPhase.id) + && (globalPhase.id > phase.id) ) // TODO - trim these to the absolute minimum. diff --git a/src/compiler/scala/tools/nsc/backend/ScalaPrimitives.scala b/src/compiler/scala/tools/nsc/backend/ScalaPrimitives.scala index dfd5b07a3b..c18f220d95 100644 --- a/src/compiler/scala/tools/nsc/backend/ScalaPrimitives.scala +++ b/src/compiler/scala/tools/nsc/backend/ScalaPrimitives.scala @@ -446,9 +446,10 @@ abstract class ScalaPrimitives { inform(s"Unknown primitive method $cls.$method") else alts foreach (s => addPrimitive(s, - s.info.paramTypes match { - case tp :: _ if code == ADD && tp =:= StringTpe => CONCAT - case _ => code + if (code != ADD) code + else exitingTyper(s.info).paramTypes match { + case tp :: _ if tp =:= StringTpe => CONCAT + case _ => code } ) ) -- cgit v1.2.3