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

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

Issue 11411236: Don't warn if inferred type is too generic - such as Object or Collection. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month 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
« no previous file with comments | « no previous file | compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 c6fc65acb3a2d7214ed7608e51e655fb504fff79..3bd09973ceefdb7d6b713bf52ad2ef3b79727cb4 100644
--- a/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java
+++ b/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java
@@ -663,7 +663,8 @@ public class TypeAnalyzer implements DartCompilationPhase {
// report problem
if (member == null && problemTarget != null) {
if (reportNoMemberWhenHasInterceptor || !Elements.handlesNoSuchMethod(itype)) {
- if (typeChecksForInferredTypes || !TypeQuality.isInferred(receiver)) {
+ if (typeChecksForInferredTypes && !isTooGenericInferredType(receiver)
+ || !TypeQuality.isInferred(receiver)) {
ErrorCode code = TypeQuality.isInferred(receiver)
? TypeErrorCode.INTERFACE_HAS_NO_METHOD_NAMED_INFERRED
: TypeErrorCode.INTERFACE_HAS_NO_METHOD_NAMED;
@@ -2374,7 +2375,8 @@ public class TypeAnalyzer implements DartCompilationPhase {
// report "not a member"
if (member == null) {
if (reportNoMemberWhenHasInterceptor || !Elements.handlesNoSuchMethod(cls)) {
- if (typeChecksForInferredTypes || !TypeQuality.isInferred(receiver)) {
+ if (typeChecksForInferredTypes && !isTooGenericInferredType(receiver)
+ || !TypeQuality.isInferred(receiver)) {
TypeErrorCode errorCode = TypeQuality.isInferred(receiver)
? TypeErrorCode.NOT_A_MEMBER_OF_INFERRED : TypeErrorCode.NOT_A_MEMBER_OF;
typeError(node.getName(), errorCode, name, cls);
@@ -3622,4 +3624,18 @@ public class TypeAnalyzer implements DartCompilationPhase {
&& Elements.isCoreLibrarySource(type.getElement().getSourceInfo().getSource())
&& type.getElement().getName().equals(name);
}
+
+ /**
+ * Sometimes inferred type is too generic - such as "Object" or "Collection", so there are no
+ * reason to reports problems.
+ */
+ private static boolean isTooGenericInferredType(Type type) {
+ if (TypeQuality.of(type) == TypeQuality.INFERRED) {
+ String typeName = type.getElement().getName();
+ if ("Object".equals(typeName) || "Collection".equals(typeName)) {
+ return true;
+ }
+ }
+ return false;
+ }
}
« no previous file with comments | « no previous file | compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698