From fc94340963208470f82e295000aaef575c733675 Mon Sep 17 00:00:00 2001 From: tdurieux Date: Tue, 7 Mar 2017 13:25:01 +0100 Subject: [PATCH] fixed files form Closure #116 --- .../google/javascript/jscomp/FunctionInjector.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/projects/Closure/116/com/google/javascript/jscomp/FunctionInjector.java b/projects/Closure/116/com/google/javascript/jscomp/FunctionInjector.java index c3fc14b..accf4c5 100644 --- a/projects/Closure/116/com/google/javascript/jscomp/FunctionInjector.java +++ b/projects/Closure/116/com/google/javascript/jscomp/FunctionInjector.java @@ -694,6 +694,15 @@ private CanInlineResult canInlineReferenceDirectly( Node block = fnNode.getLastChild(); + boolean hasSideEffects = false; // empty function case + if (block.hasChildren()) { + Preconditions.checkState(block.hasOneChild()); + Node stmt = block.getFirstChild(); + if (stmt.isReturn()) { + hasSideEffects = NodeUtil.mayHaveSideEffects( + stmt.getFirstChild(), compiler); + } + } // CALL NODE: [ NAME, ARG1, ARG2, ... ] Node cArg = callNode.getFirstChild().getNext(); @@ -720,6 +729,9 @@ private CanInlineResult canInlineReferenceDirectly( // For each named parameter check if a mutable argument use more than one. if (fnParam != null) { if (cArg != null) { + if (hasSideEffects && NodeUtil.canBeSideEffected(cArg)) { + return CanInlineResult.NO; + } // Check for arguments that are evaluated more than once. // Note: Unlike block inlining, there it is not possible that a