From 55e9f07a5bdfefd5eaef6496bd21bf4fef0bcd0e Mon Sep 17 00:00:00 2001 From: blickly Date: Thu, 16 Nov 2017 16:18:08 -0800 Subject: [PATCH] Use immutable interface for return types when the actual values returned are of an immutable collection. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=176038754 --- .../javascript/jscomp/AbstractCommandLineRunner.java | 8 ++++---- .../jscomp/CheckMissingAndExtraRequires.java | 2 +- .../javascript/jscomp/ChromeCodingConvention.java | 6 +++--- .../javascript/jscomp/ClosureCodingConvention.java | 6 +++--- src/com/google/javascript/jscomp/CodePrinter.java | 2 +- .../google/javascript/jscomp/ConformanceRules.java | 3 ++- .../javascript/jscomp/GlobalTypeInfoCollector.java | 5 +++-- src/com/google/javascript/jscomp/NTIScope.java | 6 +++--- src/com/google/javascript/jscomp/PolymerPass.java | 4 ++-- src/com/google/javascript/jscomp/SymbolTable.java | 2 +- src/com/google/javascript/jscomp/TagNameToType.java | 4 +--- .../jscomp/deps/Es6SortedDependencies.java | 4 ++-- .../javascript/jscomp/deps/SimpleDependencyInfo.java | 2 +- .../javascript/jscomp/gwt/client/GwtRunner.java | 8 +++----- .../javascript/jscomp/parsing/ParserRunner.java | 2 +- .../google/javascript/jscomp/regex/RegExpTree.java | 12 ++++++------ .../javascript/refactoring/ApplySuggestedFixes.java | 11 +++++------ .../javascript/refactoring/ErrorToFixMapper.java | 2 +- .../javascript/refactoring/RefasterJsScanner.java | 4 ++-- .../refactoring/examples/GoogBindToArrow.java | 3 +-- .../google/javascript/jscomp/CompilerTestCase.java | 2 +- .../google/javascript/jscomp/GoldenFileComparer.java | 2 +- .../google/javascript/jscomp/JSModuleGraphTest.java | 4 ++-- .../jscomp/deps/Es6SortedDependenciesTest.java | 5 +++-- .../google/javascript/rhino/jstype/JSTypeTest.java | 6 ++---- 25 files changed, 55 insertions(+), 60 deletions(-) diff --git a/src/com/google/javascript/jscomp/AbstractCommandLineRunner.java b/src/com/google/javascript/jscomp/AbstractCommandLineRunner.java index 652b435158c..4772d7cdad8 100644 --- a/src/com/google/javascript/jscomp/AbstractCommandLineRunner.java +++ b/src/com/google/javascript/jscomp/AbstractCommandLineRunner.java @@ -578,11 +578,11 @@ protected List createInputs( } /** - * Check that relative paths inside zip files are unique, since multiple files - * with the same path inside different zips are considered duplicate inputs. - * Parameter {@code sourceFiles} may be modified if duplicates are removed. + * Check that relative paths inside zip files are unique, since multiple files with the same path + * inside different zips are considered duplicate inputs. Parameter {@code sourceFiles} may be + * modified if duplicates are removed. */ - public static List removeDuplicateZipEntries( + public static ImmutableList removeDuplicateZipEntries( List sourceFiles, List jsModuleSpecs) throws IOException { ImmutableList.Builder errors = ImmutableList.builder(); Map sourceFilesByName = new HashMap<>(); diff --git a/src/com/google/javascript/jscomp/CheckMissingAndExtraRequires.java b/src/com/google/javascript/jscomp/CheckMissingAndExtraRequires.java index adeb67e1215..8e31de41ad2 100644 --- a/src/com/google/javascript/jscomp/CheckMissingAndExtraRequires.java +++ b/src/com/google/javascript/jscomp/CheckMissingAndExtraRequires.java @@ -140,7 +140,7 @@ private static boolean isClassOrConstantName(String name) { // Return the shortest prefix of the className that refers to a class, // or null if no part refers to a class. - private static List getClassNames(String qualifiedName) { + private static ImmutableList getClassNames(String qualifiedName) { ImmutableList.Builder classNames = ImmutableList.builder(); List parts = DOT_SPLITTER.splitToList(qualifiedName); for (int i = 0; i < parts.size(); i++) { diff --git a/src/com/google/javascript/jscomp/ChromeCodingConvention.java b/src/com/google/javascript/jscomp/ChromeCodingConvention.java index 36c31864de7..ce377855334 100644 --- a/src/com/google/javascript/jscomp/ChromeCodingConvention.java +++ b/src/com/google/javascript/jscomp/ChromeCodingConvention.java @@ -15,6 +15,7 @@ */ package com.google.javascript.jscomp; +import com.google.common.collect.ImmutableCollection; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.errorprone.annotations.Immutable; @@ -22,7 +23,6 @@ import com.google.javascript.rhino.FunctionTypeI; import com.google.javascript.rhino.Node; import com.google.javascript.rhino.NominalTypeBuilder; -import java.util.Collection; /** * Coding convention used by the Chrome team to compile Chrome's JS. @@ -60,12 +60,12 @@ public void applySingletonGetter(NominalTypeBuilder classType, FunctionTypeI get } @Override - public Collection getIndirectlyDeclaredProperties() { + public ImmutableCollection getIndirectlyDeclaredProperties() { return indirectlyDeclaredProperties; } @Override - public Collection getAssertionFunctions() { + public ImmutableCollection getAssertionFunctions() { return ImmutableList.of( new AssertionFunctionSpec("assert"), new AssertInstanceofSpec("cr.ui.decorate") diff --git a/src/com/google/javascript/jscomp/ClosureCodingConvention.java b/src/com/google/javascript/jscomp/ClosureCodingConvention.java index 01921f6f35a..cbfbdc30dfe 100644 --- a/src/com/google/javascript/jscomp/ClosureCodingConvention.java +++ b/src/com/google/javascript/jscomp/ClosureCodingConvention.java @@ -19,6 +19,7 @@ import static com.google.common.base.Preconditions.checkArgument; import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableCollection; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.errorprone.annotations.Immutable; @@ -33,7 +34,6 @@ import com.google.javascript.rhino.jstype.JSTypeNative; import com.google.javascript.rhino.jstype.JSTypeRegistry; import java.util.ArrayList; -import java.util.Collection; import java.util.List; /** @@ -388,7 +388,7 @@ public boolean isPrivate(String name) { } @Override - public Collection getAssertionFunctions() { + public ImmutableCollection getAssertionFunctions() { return ImmutableList.of( new AssertionFunctionSpec("goog.asserts.assert", JSTypeNative.TRUTHY), new AssertionFunctionSpec("goog.asserts.assertNumber", JSTypeNative.NUMBER_TYPE), @@ -471,7 +471,7 @@ private boolean matchesCacheMethodName(Node target) { } @Override - public Collection getIndirectlyDeclaredProperties() { + public ImmutableCollection getIndirectlyDeclaredProperties() { return indirectlyDeclaredProperties; } diff --git a/src/com/google/javascript/jscomp/CodePrinter.java b/src/com/google/javascript/jscomp/CodePrinter.java index 589f686ad1f..45f84e9a197 100644 --- a/src/com/google/javascript/jscomp/CodePrinter.java +++ b/src/com/google/javascript/jscomp/CodePrinter.java @@ -227,7 +227,7 @@ protected final int getCurrentLineIndex() { } /** Calculates length of each line in compiled code. */ - private static List computeLineLengths(String code) { + private static ImmutableList computeLineLengths(String code) { ImmutableList.Builder builder = ImmutableList.builder(); int lineStartPos = 0; int lineEndPos = code.indexOf('\n'); diff --git a/src/com/google/javascript/jscomp/ConformanceRules.java b/src/com/google/javascript/jscomp/ConformanceRules.java index a906f840e9d..9fcd0a5b585 100644 --- a/src/com/google/javascript/jscomp/ConformanceRules.java +++ b/src/com/google/javascript/jscomp/ConformanceRules.java @@ -23,6 +23,7 @@ import com.google.common.base.Ascii; import com.google.common.base.Joiner; import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableCollection; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.ImmutableSet; @@ -1628,7 +1629,7 @@ protected ConformanceResult checkConformance(NodeTraversal t, Node n) { return ConformanceResult.CONFORMANCE; } - private Collection getTagNames(Node tag) { + private ImmutableCollection getTagNames(Node tag) { if (tag.isString()) { return ImmutableSet.of(tag.getString().toLowerCase()); } else if (tag.isGetProp() && tag.getFirstChild().matchesQualifiedName("goog.dom.TagName")) { diff --git a/src/com/google/javascript/jscomp/GlobalTypeInfoCollector.java b/src/com/google/javascript/jscomp/GlobalTypeInfoCollector.java index 252e1a3f9e7..51b3a849523 100644 --- a/src/com/google/javascript/jscomp/GlobalTypeInfoCollector.java +++ b/src/com/google/javascript/jscomp/GlobalTypeInfoCollector.java @@ -22,6 +22,7 @@ import com.google.common.base.Preconditions; import com.google.common.collect.HashBasedTable; +import com.google.common.collect.ImmutableCollection; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.collect.LinkedHashMultimap; @@ -523,8 +524,8 @@ private void defineObjectAndFunctionIfMissing() { } } - private Collection getPropDefsFromInterface(NominalType nominalType, - String pname) { + private ImmutableCollection getPropDefsFromInterface( + NominalType nominalType, String pname) { checkArgument(nominalType.isFrozen()); checkArgument(nominalType.isInterface() || nominalType.isBuiltinObject()); if (nominalType.getPropDeclaredType(pname) == null) { diff --git a/src/com/google/javascript/jscomp/NTIScope.java b/src/com/google/javascript/jscomp/NTIScope.java index e9d154f8507..4e1161f4b2a 100644 --- a/src/com/google/javascript/jscomp/NTIScope.java +++ b/src/com/google/javascript/jscomp/NTIScope.java @@ -377,7 +377,7 @@ Set getOuterVars() { return new LinkedHashSet<>(outerVars); } - Set getLocalFunDefs() { + ImmutableSet getLocalFunDefs() { return ImmutableSet.copyOf(localFunDefs.keySet()); } @@ -490,11 +490,11 @@ NTIScope getScope(String fnName) { return s; } - Set getLocals() { + ImmutableSet getLocals() { return ImmutableSet.copyOf(locals.keySet()); } - Set getExterns() { + ImmutableSet getExterns() { return ImmutableSet.copyOf(externs.keySet()); } diff --git a/src/com/google/javascript/jscomp/PolymerPass.java b/src/com/google/javascript/jscomp/PolymerPass.java index 79de9d78a65..19e62f149f3 100644 --- a/src/com/google/javascript/jscomp/PolymerPass.java +++ b/src/com/google/javascript/jscomp/PolymerPass.java @@ -22,6 +22,7 @@ import static com.google.javascript.jscomp.PolymerPassErrors.POLYMER_MISSING_EXTERNS; import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; import com.google.javascript.jscomp.NodeTraversal.AbstractPostOrderCallback; import com.google.javascript.rhino.IR; import com.google.javascript.rhino.JSDocInfo; @@ -30,7 +31,6 @@ import com.google.javascript.rhino.Node; import com.google.javascript.rhino.Token; import java.util.HashSet; -import java.util.Map; import java.util.Set; /** @@ -48,7 +48,7 @@ final class PolymerPass extends AbstractPostOrderCallback implements HotSwapComp static final String VIRTUAL_FILE = ""; private final AbstractCompiler compiler; - private final Map tagNameMap; + private final ImmutableMap tagNameMap; private final int polymerVersion; private final boolean propertyRenamingEnabled; diff --git a/src/com/google/javascript/jscomp/SymbolTable.java b/src/com/google/javascript/jscomp/SymbolTable.java index 0116ffd1930..0257c05d8e8 100644 --- a/src/com/google/javascript/jscomp/SymbolTable.java +++ b/src/com/google/javascript/jscomp/SymbolTable.java @@ -147,7 +147,7 @@ public Iterable getReferences(Symbol symbol) { return Collections.unmodifiableCollection(symbol.references.values()); } - public List getReferenceList(Symbol symbol) { + public ImmutableList getReferenceList(Symbol symbol) { return ImmutableList.copyOf(symbol.references.values()); } diff --git a/src/com/google/javascript/jscomp/TagNameToType.java b/src/com/google/javascript/jscomp/TagNameToType.java index bde507dbd4e..87f14dd4a51 100644 --- a/src/com/google/javascript/jscomp/TagNameToType.java +++ b/src/com/google/javascript/jscomp/TagNameToType.java @@ -17,13 +17,11 @@ import com.google.common.collect.ImmutableMap; -import java.util.Map; - /** * Contains a mapping from HTML Element tag name to the javascript type of that element at runtime. */ class TagNameToType { - static Map getMap() { + static ImmutableMap getMap() { return new ImmutableMap.Builder() .put("a", "HTMLAnchorElement") .put("area", "HTMLAreaElement") diff --git a/src/com/google/javascript/jscomp/deps/Es6SortedDependencies.java b/src/com/google/javascript/jscomp/deps/Es6SortedDependencies.java index 2515f7b540f..913cafb0d43 100644 --- a/src/com/google/javascript/jscomp/deps/Es6SortedDependencies.java +++ b/src/com/google/javascript/jscomp/deps/Es6SortedDependencies.java @@ -68,7 +68,7 @@ public Es6SortedDependencies(List userOrderedInputs) { } @Override - public List getDependenciesOf(List rootInputs, boolean sorted) { + public ImmutableList getDependenciesOf(List rootInputs, boolean sorted) { checkArgument(userOrderedInputs.containsAll(rootInputs)); Set includedInputs = new HashSet<>(); @@ -105,7 +105,7 @@ public INPUT getInputProviding(String symbolName) throws MissingProvideException } @Override - public List getInputsWithoutProvides() { + public ImmutableList getInputsWithoutProvides() { return ImmutableList.copyOf(nonExportingInputs.values()); } diff --git a/src/com/google/javascript/jscomp/deps/SimpleDependencyInfo.java b/src/com/google/javascript/jscomp/deps/SimpleDependencyInfo.java index 85cc351d337..b10bd70ae79 100644 --- a/src/com/google/javascript/jscomp/deps/SimpleDependencyInfo.java +++ b/src/com/google/javascript/jscomp/deps/SimpleDependencyInfo.java @@ -92,7 +92,7 @@ public ImmutableMap getLoadFlags() { return loadFlags; } - private static Map loadFlags(boolean isModule) { + private static ImmutableMap loadFlags(boolean isModule) { return isModule ? ImmutableMap.of("module", "goog") : ImmutableMap.of(); } diff --git a/src/com/google/javascript/jscomp/gwt/client/GwtRunner.java b/src/com/google/javascript/jscomp/gwt/client/GwtRunner.java index baac9915313..897df5ab5cc 100644 --- a/src/com/google/javascript/jscomp/gwt/client/GwtRunner.java +++ b/src/com/google/javascript/jscomp/gwt/client/GwtRunner.java @@ -189,10 +189,8 @@ private static native String[] getStringArray(Flags flags, String key) /*-{ private static final class JsMap extends JavaScriptObject { protected JsMap() {} - /** - * @return This {@code JsMap} as a {@link Map}. - */ - Map asMap() { + /** @return This {@code JsMap} as a {@link Map}. */ + ImmutableMap asMap() { ImmutableMap.Builder builder = new ImmutableMap.Builder<>(); for (String key : keys(this)) { builder.put(key, get(key)); @@ -285,7 +283,7 @@ private static List createExterns(CompilerOptions.Environment enviro return DefaultExterns.prepareExterns(environment, all); } - private static List createEntryPoints(String[] entryPoints) { + private static ImmutableList createEntryPoints(String[] entryPoints) { ImmutableList.Builder builder = new ImmutableList.Builder<>(); for (String entryPoint : entryPoints) { if (entryPoint.startsWith("goog:")) { diff --git a/src/com/google/javascript/jscomp/parsing/ParserRunner.java b/src/com/google/javascript/jscomp/parsing/ParserRunner.java index e7d92686cbe..ba893ff9043 100644 --- a/src/com/google/javascript/jscomp/parsing/ParserRunner.java +++ b/src/com/google/javascript/jscomp/parsing/ParserRunner.java @@ -107,7 +107,7 @@ private static synchronized void initResourceConfig() { reservedVars = extractList(config.getString("compiler.reserved.vars")); } - private static Set extractList(String configProp) { + private static ImmutableSet extractList(String configProp) { return ImmutableSet.copyOf(Splitter.on(',').trimResults().split(configProp)); } diff --git a/src/com/google/javascript/jscomp/regex/RegExpTree.java b/src/com/google/javascript/jscomp/regex/RegExpTree.java index 68375f8a4e7..b6878f7ee40 100644 --- a/src/com/google/javascript/jscomp/regex/RegExpTree.java +++ b/src/com/google/javascript/jscomp/regex/RegExpTree.java @@ -590,7 +590,7 @@ public final int numCapturingGroups() { } @Override - public final List children() { + public final ImmutableList children() { return ImmutableList.of(); } } @@ -870,7 +870,7 @@ public int numCapturingGroups() { } @Override - public List children() { + public ImmutableList children() { return ImmutableList.of(body); } @@ -1118,7 +1118,7 @@ public int numCapturingGroups() { } @Override - public List children() { + public ImmutableList children() { return alternatives; } @@ -1189,7 +1189,7 @@ public int numCapturingGroups() { } @Override - public List children() { + public ImmutableList children() { return ImmutableList.of(body); } @@ -1246,7 +1246,7 @@ public int numCapturingGroups() { } @Override - public List children() { + public ImmutableList children() { return ImmutableList.of(body); } @@ -1746,7 +1746,7 @@ public int numCapturingGroups() { } @Override - public List children() { + public ImmutableList children() { return elements; } diff --git a/src/com/google/javascript/refactoring/ApplySuggestedFixes.java b/src/com/google/javascript/refactoring/ApplySuggestedFixes.java index f758d175099..383aca0dd90 100644 --- a/src/com/google/javascript/refactoring/ApplySuggestedFixes.java +++ b/src/com/google/javascript/refactoring/ApplySuggestedFixes.java @@ -84,13 +84,12 @@ public static void applySuggestedFixesToFiles(Iterable fixes) } /** - * Applies the provided set of suggested fixes to the provided code and returns the new code. - * The {@code filenameToCodeMap} must contain all the files that the provided fixes apply to. - * The fixes can be provided in any order, but they may not have any overlapping modifications - * for the same file. - * This function will return new code only for the files that have been modified. + * Applies the provided set of suggested fixes to the provided code and returns the new code. The + * {@code filenameToCodeMap} must contain all the files that the provided fixes apply to. The + * fixes can be provided in any order, but they may not have any overlapping modifications for the + * same file. This function will return new code only for the files that have been modified. */ - public static Map applySuggestedFixesToCode( + public static ImmutableMap applySuggestedFixesToCode( Iterable fixes, Map filenameToCodeMap) { ReplacementMap map = new ReplacementMap(); for (SuggestedFix fix : fixes) { diff --git a/src/com/google/javascript/refactoring/ErrorToFixMapper.java b/src/com/google/javascript/refactoring/ErrorToFixMapper.java index 8ea0b676b10..2ec0974c3f1 100644 --- a/src/com/google/javascript/refactoring/ErrorToFixMapper.java +++ b/src/com/google/javascript/refactoring/ErrorToFixMapper.java @@ -224,7 +224,7 @@ private static SuggestedFix getFixForReferenceToShortImportByLongName( .build(); } - private static List getFixesForImplicitlyNullableJsDoc( + private static ImmutableList getFixesForImplicitlyNullableJsDoc( JSError error, AbstractCompiler compiler) { SuggestedFix qmark = new SuggestedFix.Builder() diff --git a/src/com/google/javascript/refactoring/RefasterJsScanner.java b/src/com/google/javascript/refactoring/RefasterJsScanner.java index b426cb92b03..7b18ea350c0 100644 --- a/src/com/google/javascript/refactoring/RefasterJsScanner.java +++ b/src/com/google/javascript/refactoring/RefasterJsScanner.java @@ -130,7 +130,7 @@ public void clearTemplates() { } @Override - public List processMatch(Match match) { + public ImmutableList processMatch(Match match) { SuggestedFix.Builder fix = new SuggestedFix.Builder(); // Only replace the original source with a version serialized from the AST if the after template // is actually different. Otherwise, we might just add churn (e.g. single quotes into double @@ -325,7 +325,7 @@ List getGoogRequiresToRemove() { return getGoogRequiresFromPattern(REMOVE_GOOG_REQUIRE_PATTERN); } - private List getGoogRequiresFromPattern(Pattern pattern) { + private ImmutableList getGoogRequiresFromPattern(Pattern pattern) { JSDocInfo jsDoc = NodeUtil.getBestJSDocInfo(beforeTemplate); if (jsDoc == null) { return ImmutableList.of(); diff --git a/src/com/google/javascript/refactoring/examples/GoogBindToArrow.java b/src/com/google/javascript/refactoring/examples/GoogBindToArrow.java index 34af8dd734b..cb051beed2f 100644 --- a/src/com/google/javascript/refactoring/examples/GoogBindToArrow.java +++ b/src/com/google/javascript/refactoring/examples/GoogBindToArrow.java @@ -22,7 +22,6 @@ import com.google.javascript.refactoring.Scanner; import com.google.javascript.refactoring.SuggestedFix; import com.google.javascript.rhino.Node; -import java.util.List; /** * Replaces goog.bind(..., this) with arrow functions. The pretty-printer does not do well with @@ -58,7 +57,7 @@ public boolean matches(Node node, NodeMetadata metadata) { } @Override - public List processMatch(Match match) { + public ImmutableList processMatch(Match match) { AbstractCompiler compiler = match.getMetadata().getCompiler(); Node googBindCall = match.getNode(); Node function = googBindCall.getFirstChild().getNext(); diff --git a/test/com/google/javascript/jscomp/CompilerTestCase.java b/test/com/google/javascript/jscomp/CompilerTestCase.java index 6ac24cea96a..9a4dbd0f6f2 100644 --- a/test/com/google/javascript/jscomp/CompilerTestCase.java +++ b/test/com/google/javascript/jscomp/CompilerTestCase.java @@ -1201,7 +1201,7 @@ protected void testInternal( testInternal(compiler, inputs, expected, diagnostic, postconditions); } - private static List maybeCreateSources(String name, String srcText) { + private static ImmutableList maybeCreateSources(String name, String srcText) { if (srcText != null) { return ImmutableList.of(SourceFile.fromCode(name, srcText)); } diff --git a/test/com/google/javascript/jscomp/GoldenFileComparer.java b/test/com/google/javascript/jscomp/GoldenFileComparer.java index e71992127dc..18883b60cd7 100644 --- a/test/com/google/javascript/jscomp/GoldenFileComparer.java +++ b/test/com/google/javascript/jscomp/GoldenFileComparer.java @@ -36,7 +36,7 @@ public class GoldenFileComparer { "test/" + "com/google/javascript/jscomp/testdata/"; - private static List coverageExterns() { + private static ImmutableList coverageExterns() { SourceFile externs = SourceFile.fromCode( "externs", "function Symbol() {}; var window; var self;"); return ImmutableList.of(externs); diff --git a/test/com/google/javascript/jscomp/JSModuleGraphTest.java b/test/com/google/javascript/jscomp/JSModuleGraphTest.java index 245d8074209..7b93c1b5f1d 100644 --- a/test/com/google/javascript/jscomp/JSModuleGraphTest.java +++ b/test/com/google/javascript/jscomp/JSModuleGraphTest.java @@ -478,11 +478,11 @@ private SourceFile code( return SourceFile.fromCode(sourceName, text + source); } - private List provides(String... strings) { + private ImmutableList provides(String... strings) { return ImmutableList.copyOf(strings); } - private List requires(String... strings) { + private ImmutableList requires(String... strings) { return ImmutableList.copyOf(strings); } diff --git a/test/com/google/javascript/jscomp/deps/Es6SortedDependenciesTest.java b/test/com/google/javascript/jscomp/deps/Es6SortedDependenciesTest.java index 3c10298c3af..a135c8c8fd1 100644 --- a/test/com/google/javascript/jscomp/deps/Es6SortedDependenciesTest.java +++ b/test/com/google/javascript/jscomp/deps/Es6SortedDependenciesTest.java @@ -21,6 +21,7 @@ import com.google.common.collect.ImmutableList; import java.util.List; import junit.framework.TestCase; + /** * Tests for {@link Es6SortedDependencies} * @author nicksantos@google.com (Nick Santos) @@ -241,11 +242,11 @@ private static void assertOrder( assertThat(sorted.getSortedList()).isEqualTo(expected); } - private static List requires(String... strings) { + private static ImmutableList requires(String... strings) { return ImmutableList.copyOf(strings); } - private static List provides(String... strings) { + private static ImmutableList provides(String... strings) { return ImmutableList.copyOf(strings); } } diff --git a/test/com/google/javascript/rhino/jstype/JSTypeTest.java b/test/com/google/javascript/rhino/jstype/JSTypeTest.java index 3e0069b85b3..eae5c13681e 100644 --- a/test/com/google/javascript/rhino/jstype/JSTypeTest.java +++ b/test/com/google/javascript/rhino/jstype/JSTypeTest.java @@ -4695,10 +4695,8 @@ public void testSubtypingMostGeneralFunction() throws Exception { assertFalse(GREATEST_FUNCTION_TYPE.isSubtype(f8)); } - /** - * Types to test for symmetrical relationships. - */ - private List getTypesToTestForSymmetry() { + /** Types to test for symmetrical relationships. */ + private ImmutableList getTypesToTestForSymmetry() { return ImmutableList.of( UNKNOWN_TYPE, NULL_TYPE,