Skip to content

Commit

Permalink
Change logic for maybe_using_refinements check to be temporarl
Browse files Browse the repository at this point in the history
  • Loading branch information
enebo committed Apr 8, 2015
1 parent 9befcdf commit d333a3a
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions core/src/main/java/org/jruby/ir/IRScope.java
Expand Up @@ -183,6 +183,10 @@ public IRScope(IRManager manager, IRScope lexicalParent, String name,
flags.add(REQUIRES_DYNSCOPE);
flags.add(USES_ZSUPER);

// We only can compute this once since 'module X; using A; class B; end; end' vs
// 'module X; class B; using A; end; end'. First case B can see refinements and in second it cannot.
if (parentMaybeUsingRefinements()) flags.add(MAYBE_USING_REFINEMENTS);

this.localVars = new HashMap<>();
this.scopeId = globalScopeCount.getAndIncrement();

Expand Down Expand Up @@ -257,10 +261,7 @@ public void setIsMaybeUsingRefinements() {
flags.add(MAYBE_USING_REFINEMENTS);
}

// FIXME: This is somewhat expensive to walk all parent scopes for refined scopes but
// the life cycle of when to do this walking makes wonder if I can just stuff this into
// computeScopeFlags?
public boolean maybeUsingRefinements() {
public boolean parentMaybeUsingRefinements() {
for (IRScope s = this; s != null; s = s.getLexicalParent()) {
if (s.getFlags().contains(MAYBE_USING_REFINEMENTS)) return true;

Expand All @@ -271,6 +272,10 @@ public boolean maybeUsingRefinements() {
return false;
}

public boolean maybeUsingRefinements() {
return getFlags().contains(MAYBE_USING_REFINEMENTS);
}

/**
* Returns the lexical scope that contains this scope definition
*/
Expand Down

0 comments on commit d333a3a

Please sign in to comment.