--- old/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/ForNode.java 2016-03-18 11:22:27.758479384 +0100 +++ new/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/ForNode.java 2016-03-18 11:22:27.678479387 +0100 @@ -274,4 +274,14 @@ public boolean hasPerIterationScope() { return (flags & PER_ITERATION_SCOPE) != 0; } + + /** + * Returns true if this for-node needs the scope creator of its containing block to create + * per-iteration scope. This is only true for for-in loops with lexical declarations. + * + * @return true if the containing block's scope object creator is required in codegen + */ + public boolean needsScopeCreator() { + return isForIn() && hasPerIterationScope(); + } }