Skip to content

Commit

Permalink
Create scope only once
Browse files Browse the repository at this point in the history
  • Loading branch information
adriaanm committed Apr 6, 2017
1 parent 379e113 commit d8613df
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/compiler/scala/tools/nsc/typechecker/Typers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
}
}

Expand Down

0 comments on commit d8613df

Please sign in to comment.