diff options
author | 2017-11-29 11:56:12 -0800 | |
---|---|---|
committer | 2017-11-29 11:57:42 -0800 | |
commit | 515746b684f894572a11c01208f7f6f2370f67cb (patch) | |
tree | df7a5bc520d95356d4a8ac47ef9e57ff82fac5d0 | |
parent | 8438bf33d5872ba5875b40db80de4413002bb721 (diff) |
Remove the check "Reassignment of builtin" in BUILD files.
If the check is useful, it can be done in the linter.
RELNOTES: None.
PiperOrigin-RevId: 177342483
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/packages/PackageFactory.java | 37 | ||||
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/packages/PackageFactoryTest.java | 13 |
2 files changed, 0 insertions, 50 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/packages/PackageFactory.java b/src/main/java/com/google/devtools/build/lib/packages/PackageFactory.java index 9eeca62759..1091366d14 100644 --- a/src/main/java/com/google/devtools/build/lib/packages/PackageFactory.java +++ b/src/main/java/com/google/devtools/build/lib/packages/PackageFactory.java @@ -37,7 +37,6 @@ import com.google.devtools.build.lib.packages.RuleFactory.BuildLangTypedAttribut import com.google.devtools.build.lib.skylarkinterface.Param; import com.google.devtools.build.lib.skylarkinterface.SkylarkSignature; import com.google.devtools.build.lib.skylarkinterface.SkylarkValue; -import com.google.devtools.build.lib.syntax.AssignmentStatement; import com.google.devtools.build.lib.syntax.BaseFunction; import com.google.devtools.build.lib.syntax.BazelLibrary; import com.google.devtools.build.lib.syntax.BuildFileAST; @@ -48,11 +47,9 @@ import com.google.devtools.build.lib.syntax.Environment.Extension; import com.google.devtools.build.lib.syntax.Environment.Phase; import com.google.devtools.build.lib.syntax.EvalException; import com.google.devtools.build.lib.syntax.EvalUtils; -import com.google.devtools.build.lib.syntax.Expression; import com.google.devtools.build.lib.syntax.FuncallExpression; import com.google.devtools.build.lib.syntax.FunctionSignature; import com.google.devtools.build.lib.syntax.GlobList; -import com.google.devtools.build.lib.syntax.Identifier; import com.google.devtools.build.lib.syntax.Mutability; import com.google.devtools.build.lib.syntax.ParserInputSource; import com.google.devtools.build.lib.syntax.Runtime; @@ -1684,10 +1681,6 @@ public final class PackageFactory { pkgBuilder.setContainsErrors(); } - if (!validateAssignmentStatements(pkgEnv, buildFileAST, eventHandler)) { - pkgBuilder.setContainsErrors(); - } - if (buildFileAST.containsErrors()) { pkgBuilder.setContainsErrors(); } @@ -1706,36 +1699,6 @@ public final class PackageFactory { return pkgBuilder; } - /** Visit all targets and expand the globs in parallel. */ - /** - * Tests a build AST to ensure that it contains no assignment statements that redefine built-in - * build rules. - * - * @param pkgEnv a package environment initialized with all of the built-in build rules - * @param ast the build file AST to be tested - * @param eventHandler a eventHandler where any errors should be logged - * @return true if the build file contains no redefinitions of built-in functions - */ - // TODO(bazel-team): Remove this check. It should be moved to LValue.assign - private static boolean validateAssignmentStatements( - Environment pkgEnv, BuildFileAST ast, ExtendedEventHandler eventHandler) { - for (Statement stmt : ast.getStatements()) { - if (stmt instanceof AssignmentStatement) { - Expression lvalue = ((AssignmentStatement) stmt).getLValue().getExpression(); - if (!(lvalue instanceof Identifier)) { - continue; - } - String target = ((Identifier) lvalue).getName(); - if (pkgEnv.hasVariable(target)) { - eventHandler.handle(Event.error(stmt.getLocation(), "Reassignment of builtin build " - + "function '" + target + "' not permitted")); - return false; - } - } - } - return true; - } - // Reports an error and returns false iff package identifier was illegal. private static boolean validatePackageIdentifier( PackageIdentifier packageId, Location location, ExtendedEventHandler eventHandler) { diff --git a/src/test/java/com/google/devtools/build/lib/packages/PackageFactoryTest.java b/src/test/java/com/google/devtools/build/lib/packages/PackageFactoryTest.java index cf450317a1..96c5b99081 100644 --- a/src/test/java/com/google/devtools/build/lib/packages/PackageFactoryTest.java +++ b/src/test/java/com/google/devtools/build/lib/packages/PackageFactoryTest.java @@ -1210,19 +1210,6 @@ public class PackageFactoryTest extends PackageFactoryTestBase { "package(default_restricted_to=['//foo', '//bar', '//foo'])"); } - /** - * Test that build files that reassign builtins fail correctly. - */ - @Test - public void testReassignPrimitive() throws Exception { - expectEvalError( - "Reassignment of builtin build function 'cc_binary' not permitted", - "cc_binary = (['hello.cc'])", - "cc_binary(name = 'hello',", - " srcs=['hello.cc'],", - " malloc = '//base:system_malloc')"); - } - @Override protected PackageFactoryApparatus createPackageFactoryApparatus() { return new PackageFactoryApparatus(events.reporter()); |