Skip to content

Commit d388b95

Browse files
committed
[NEW TYPE INFERENCE] Add an option to not emit warnings, for development/profiling only.
------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=70351176
1 parent be639c4 commit d388b95

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

src/com/google/javascript/jscomp/NewTypeInference.java

+9-4
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,11 @@ public class NewTypeInference implements CompilerPass {
197197
public static class WarningReporter {
198198
AbstractCompiler compiler;
199199
WarningReporter(AbstractCompiler compiler) { this.compiler = compiler; }
200-
void add(JSError warning) { compiler.report(warning); }
200+
void add(JSError warning) {
201+
if (!JSType.mockToString) {
202+
compiler.report(warning);
203+
}
204+
}
201205
}
202206

203207
private WarningReporter warnings;
@@ -213,9 +217,10 @@ public static class WarningReporter {
213217
static final String GETTER_PREFIX = "%getter_fun";
214218
static final String SETTER_PREFIX = "%setter_fun";
215219
private JSType arrayType, regexpType; // used for array and regexp literals
216-
private static boolean debugging = false;
217220
private final boolean isClosurePassOn;
218-
// Used for profiling during development
221+
222+
// Used only for development
223+
private static boolean showDebuggingPrints = false;
219224
static boolean measureMem = false;
220225
private static long peakMem = 0;
221226

@@ -278,7 +283,7 @@ private boolean isArrayType(JSType t) {
278283
}
279284

280285
private static void println(Object ... objs) {
281-
if (debugging) {
286+
if (showDebuggingPrints) {
282287
StringBuilder b = new StringBuilder();
283288
for (Object obj : objs) {
284289
b.append(obj == null ? "null" : obj.toString());

src/com/google/javascript/jscomp/newtypes/JSType.java

+6
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ public abstract class JSType {
6262
// eg, it can be a prop of a formal whose decl type is a record type.
6363
static String GENERIC_LOCATION = "%";
6464

65+
// Used only for development
66+
public static boolean mockToString = false;
67+
6568
private static JSType makeType(int mask, String location,
6669
ImmutableSet<ObjectType> objs, String typeVar,
6770
ImmutableSet<EnumType> enums) {
@@ -990,6 +993,9 @@ static List<JSType> fixLengthOfTypeList(
990993

991994
@Override
992995
public String toString() {
996+
if (mockToString) {
997+
return "";
998+
}
993999
return appendTo(new StringBuilder()).toString();
9941000
}
9951001

0 commit comments

Comments
 (0)