Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding command line flag for setAssumeStaticInheritanceRequired #3864

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/com/google/javascript/jscomp/CommandLineRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,14 @@ private static class Flags {
+ "An alias of 'import' is allowed.")
private String dynamicImportAlias = null;

@Option(
name = "--assume_static_inheritance_required",
handler = BooleanOptionHandler.class,
usage =
"Instructs the compiler not to perform potential breaking optimizations "
+ "when the code being compiled depends on static inheritance." )
private boolean assumeStaticInheritanceRequired = false;

@Argument private List<String> arguments = new ArrayList<>();
private final CmdLineParser parser;

Expand Down Expand Up @@ -1042,6 +1050,7 @@ private void parse(List<String> args) throws CmdLineException {
"json_streams",
"third_party",
"use_types_for_optimization",
"assume_static_inheritance_required",
"version"))
.build();

Expand Down Expand Up @@ -1982,6 +1991,7 @@ protected CompilerOptions createOptions() {
options.setProductionInstrumentationArrayName(flags.productionInstrumentationArrayName);
options.setAllowDynamicImport(flags.allowDynamicImport);
options.setDynamicImportAlias(flags.dynamicImportAlias);
options.setAssumeStaticInheritanceRequired(flags.assumeStaticInheritanceRequired);

if (flags.chunkOutputType == ChunkOutputType.ES_MODULES) {
if (flags.renamePrefixNamespace != null) {
Expand Down
9 changes: 9 additions & 0 deletions test/com/google/javascript/jscomp/CommandLineRunnerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2926,6 +2926,15 @@ public void testChunkOutputFiles() throws IOException {
assertThat(weakFile.exists()).isFalse();
}

@Test
public void testAssumeStaticInheritanceRequired() {
testSame("");
assertThat(lastCompiler.getOptions().getAssumeStaticInheritanceRequired()).isFalse();
args.add("--assume_static_inheritance_required");
testSame("");
assertThat(lastCompiler.getOptions().getAssumeStaticInheritanceRequired()).isTrue();
}

/* Helper functions */

private void testSame(String original) {
Expand Down