Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1091)

Unified Diff: compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java

Issue 10546161: Issue 3516. Make displaying warning for inferred types configurable (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java
diff --git a/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java b/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java
index c7815476b0e5446c4e45510b222881d4cb364309..cdb2895eae079fef914027a640a05124a1fbb2b0 100644
--- a/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java
+++ b/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java
@@ -13,6 +13,7 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
import com.google.common.collect.Sets;
+import com.google.dart.compiler.CommandLineOptions.CompilerOptions;
import com.google.dart.compiler.DartCompilationError;
import com.google.dart.compiler.DartCompilationPhase;
import com.google.dart.compiler.DartCompilerContext;
@@ -180,6 +181,7 @@ public class TypeAnalyzer implements DartCompilationPhase {
private final InterfaceType dynamicIteratorType;
private final boolean developerModeChecks;
private final boolean suppressSdkWarnings;
+ private final boolean suppressNoMemberWarningForInferredTypes;
/**
* Keeps track of the number of nested catches, used to detect re-throws
@@ -203,8 +205,9 @@ public class TypeAnalyzer implements DartCompilationPhase {
this.nullType = typeProvider.getNullType();
this.functionType = typeProvider.getFunctionType();
this.dynamicIteratorType = typeProvider.getIteratorType(dynamicType);
- this.suppressSdkWarnings = context.getCompilerConfiguration().getCompilerOptions()
- .suppressSdkWarnings();
+ CompilerOptions compilerOptions = context.getCompilerConfiguration().getCompilerOptions();
+ this.suppressSdkWarnings = compilerOptions.suppressSdkWarnings();
+ this.suppressNoMemberWarningForInferredTypes = compilerOptions.suppressNoMemberWarningForInferredTypes();
}
@VisibleForTesting
@@ -508,8 +511,10 @@ public class TypeAnalyzer implements DartCompilationPhase {
}
Member member = itype.lookupMember(methodName);
if (member == null) {
- typeError(diagnosticNode, TypeErrorCode.INTERFACE_HAS_NO_METHOD_NAMED,
- receiver, methodName);
+ if (!receiver.isInferred() || !suppressNoMemberWarningForInferredTypes) {
+ typeError(diagnosticNode, TypeErrorCode.INTERFACE_HAS_NO_METHOD_NAMED, receiver,
+ methodName);
+ }
return null;
}
return member;
@@ -816,7 +821,10 @@ public class TypeAnalyzer implements DartCompilationPhase {
break;
}
default:
- return typeError(diagnosticNode, TypeErrorCode.NOT_A_METHOD_IN, name, receiver);
+ if (!receiver.isInferred() || !suppressNoMemberWarningForInferredTypes) {
+ typeError(diagnosticNode, TypeErrorCode.NOT_A_METHOD_IN, name, receiver);
+ }
+ return dynamicType;
}
return checkArguments(diagnosticNode, argumentNodes, argumentTypes.iterator(), ftype);
}
@@ -1830,7 +1838,10 @@ public class TypeAnalyzer implements DartCompilationPhase {
String name = node.getPropertyName();
InterfaceType.Member member = cls.lookupMember(name);
if (member == null) {
- return typeError(node.getName(), TypeErrorCode.NOT_A_MEMBER_OF, name, cls);
+ if (!receiver.isInferred() || !suppressNoMemberWarningForInferredTypes) {
+ typeError(node.getName(), TypeErrorCode.NOT_A_MEMBER_OF, name, cls);
+ }
+ return dynamicType;
}
element = member.getElement();
node.setElement(element);

Powered by Google App Engine
This is Rietveld 408576698