diff options
author | Adriaan Moors <adriaan@lightbend.com> | 2017-02-22 11:02:56 -0800 |
---|---|---|
committer | Adriaan Moors <adriaan@lightbend.com> | 2017-04-06 16:31:06 -0700 |
commit | d8613df1cd6545f85767bf649a483621676b5893 (patch) | |
tree | 0509f7849588474220eb6f8d1725ac3d0fdf1781 /src/compiler/scala/tools/nsc/typechecker | |
parent | 379e113e568c3d3193aace81fc37d7279eff4f8c (diff) | |
download | scala-d8613df1cd6545f85767bf649a483621676b5893.tar.gz scala-d8613df1cd6545f85767bf649a483621676b5893.tar.bz2 scala-d8613df1cd6545f85767bf649a483621676b5893.zip |
Create scope only once
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 2cbd9475fc..1f2b8ae16e 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -3099,8 +3099,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper || (looker.hasAccessorFlag && !accessed.hasAccessorFlag && accessed.isPrivate) ) - def checkNoDoubleDefs: Unit = { - val scope = if (inBlock) context.scope else context.owner.info.decls + def checkNoDoubleDefs(scope: Scope): Unit = { var e = scope.elems while ((e ne null) && e.owner == scope) { var e1 = scope.lookupNextEntry(e) @@ -3143,8 +3142,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper } } - def addSynthetics(stats: List[Tree]): List[Tree] = { - val scope = if (inBlock) context.scope else context.owner.info.decls + def addSynthetics(stats: List[Tree], scope: Scope): List[Tree] = { var newStats = new ListBuffer[Tree] var moreToAdd = true while (moreToAdd) { @@ -3219,11 +3217,14 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper val stats1 = stats mapConserve typedStat if (phase.erasedTypes) stats1 else { + val scope = if (inBlock) context.scope else context.owner.info.decls + // As packages are open, it doesn't make sense to check double definitions here. Furthermore, // it is expensive if the package is large. Instead, such double definitions are checked in `Namers.enterInScope` if (!context.owner.isPackageClass) - checkNoDoubleDefs - addSynthetics(stats1) + checkNoDoubleDefs(scope) + + addSynthetics(stats1, scope) } } |