nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: google/closure-compiler
Pull request #770 (2015-01-03 23:00:03)

Fix index.js resolution for non-relative require invocations.
Resolve absolute references against the module root, so directories containing index.js files will be handled as they are for relative references.


Patch:
diff --git a/src/com/google/javascript/jscomp/ES6ModuleLoader.java b/src/com/google/javascript/jscomp/ES6ModuleLoader.java
index b46b00d2c..3d1875972 100644
--- a/src/com/google/javascript/jscomp/ES6ModuleLoader.java
+++ b/src/com/google/javascript/jscomp/ES6ModuleLoader.java
@@ -107,7 +107,7 @@ abstract class ES6ModuleLoader {
 
     private NaiveModuleLoader(AbstractCompiler compiler, String moduleRoot) {
       this.moduleRoot = moduleRoot;
-      this.moduleRootURI = new File(moduleRoot).toURI();
+      this.moduleRootURI = createUri(moduleRoot);
 
       // Precompute the module name of each source file.
       for (CompilerInput input : compiler.getInputsInOrder()) {
@@ -117,11 +117,10 @@ abstract class ES6ModuleLoader {
 
     @Override
     String locate(String name, CompilerInput referrer) {
-      if (isRelativeIdentifier(name)) {
-        return convertSourceUriToModuleAddress(
-            createUri(referrer).resolve(createUri(name)));
-      }
-      return createUri(name).normalize().toString();
+      URI base = isRelativeIdentifier(name) ? createUri(referrer)
+          : moduleRootURI;
+
+      return convertSourceUriToModuleAddress(base.resolve(createUri(name)));
     }
 
     @Override


Test patch:
diff --git a/test/com/google/javascript/jscomp/ES6ModuleLoaderFileSystemTest.java b/test/com/google/javascript/jscomp/ES6ModuleLoaderFileSystemTest.java
index f3fb9fc83..74e41b6fb 100644
--- a/test/com/google/javascript/jscomp/ES6ModuleLoaderFileSystemTest.java
+++ b/test/com/google/javascript/jscomp/ES6ModuleLoaderFileSystemTest.java
@@ -96,5 +96,6 @@ public class ES6ModuleLoaderFileSystemTest {
     Assert.assertEquals("A/index.js", loader.getLoadAddress(inputA));
     Assert.assertEquals("A/index.js", loader.locate("../A", inputB));
     Assert.assertEquals("A/index.js", loader.locate("./A", inputApp));
+    Assert.assertEquals("A/index.js", loader.locate("A", inputApp));
   }
 }
Repository: google/closure-compiler
Pull request #1098 (2015-08-25 15:55:56)

turn on xmodule dep check in VERBOSE mode
see https://github.com/google/closure-compiler/issues/1084


Patch:
diff --git a/src/com/google/javascript/jscomp/WarningLevel.java b/src/com/google/javascript/jscomp/WarningLevel.java
index 2b0c6082a..591c889c8 100644
--- a/src/com/google/javascript/jscomp/WarningLevel.java
+++ b/src/com/google/javascript/jscomp/WarningLevel.java
@@ -118,6 +118,8 @@ public enum WarningLevel {
         DiagnosticGroups.CONST, CheckLevel.WARNING);
     options.setWarningLevel(
         DiagnosticGroups.CHECK_REGEXP, CheckLevel.WARNING);
+    options.setWarningLevel(
+        DiagnosticGroups.STRICT_MODULE_DEP_CHECK, CheckLevel.WARNING);
 
     // Kindly tell the user that they have JsDocs that we don't understand.
     options.setWarningLevel(DiagnosticGroups.NON_STANDARD_JSDOC,


Test patch:
diff --git a/test/com/google/javascript/jscomp/IntegrationTest.java b/test/com/google/javascript/jscomp/IntegrationTest.java
index 2451de673..0fdf24c9d 100644
--- a/test/com/google/javascript/jscomp/IntegrationTest.java
+++ b/test/com/google/javascript/jscomp/IntegrationTest.java
@@ -1440,6 +1440,18 @@ public final class IntegrationTest extends IntegrationTestCase {
         });
   }
 
+  public void testCrossModuleDepCheck() {
+    CompilerOptions options = createCompilerOptions();
+    String[] code = new String[] {
+      "var goog = {}; new goog.Foo();",
+      "/** @constructor */ goog.Foo = function() {};",
+    };
+    testSame(options, code);
+
+    WarningLevel.VERBOSE.setOptionsForWarningLevel(options);
+    test(options, code, code, CheckGlobalNames.STRICT_MODULE_DEP_QNAME);
+  }
+
   public void testFlowSensitiveInlineVariables1() {
     CompilerOptions options = createCompilerOptions();
     String code = "function f() { var x = 3; x = 5; return x; }";
Repository: google/closure-compiler
Pull request #1101 (2015-08-27 19:23:04)

Allow simple alias assignments in externs for type inference.
The compiler can correctly infer the types of aliases in externs when they are assigned and we should allow this pattern.

This removes the spurious warning that is generated for such simple assignments.

I can remove 400 lines from the jQuery externs with this change.


Patch:
diff --git a/src/com/google/javascript/jscomp/VarCheck.java b/src/com/google/javascript/jscomp/VarCheck.java
index 0e2739846..bf2dc7083 100644
--- a/src/com/google/javascript/jscomp/VarCheck.java
+++ b/src/com/google/javascript/jscomp/VarCheck.java
@@ -303,7 +303,12 @@ class VarCheck extends AbstractPostOrderCallback implements
             }
             // fall through
           default:
-            t.report(n, NAME_REFERENCE_IN_EXTERNS_ERROR, n.getString());
+            // Don't warn for simple var assignments "/** @const */ var foo = bar;"
+            // They are used to infer the types of namespace aliases.
+            if (parent.getType() != Token.NAME || parent.getParent() == null ||
+                !NodeUtil.isNameDeclaration(parent.getParent())) {
+              t.report(n, NAME_REFERENCE_IN_EXTERNS_ERROR, n.getString());
+            }
 
             Scope scope = t.getScope();
             Var var = scope.getVar(n.getString());


Test patch:
diff --git a/test/com/google/javascript/jscomp/VarCheckTest.java b/test/com/google/javascript/jscomp/VarCheckTest.java
index bd1e8071d..f329f8aeb 100644
--- a/test/com/google/javascript/jscomp/VarCheckTest.java
+++ b/test/com/google/javascript/jscomp/VarCheckTest.java
@@ -180,6 +180,10 @@ public final class VarCheckTest extends Es6CompilerTestCase {
     testSame("var asdf;", "asdf;", null);
   }
 
+  public void testVarAssignmentInExterns() {
+    testSame("/** @type{{foo:string}} */ var foo; var asdf = foo;", "asdf.foo;", null);
+  }
+
   public void testLetDeclarationInExterns() {
     testSameEs6("let asdf;", "asdf;", null);
   }