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

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

Issue 12088044: Issue 8169. Type inferred from 'query' is 'inferred exact'. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Don't report problem when member exists, but not the unique. Created 7 years, 11 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 cd9238ec31dfa7962c2a750d0bd4a9ba905685e9..8e46ff93ecdcca8650f53f8ee65c4e87c6538070 100644
--- a/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java
+++ b/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java
@@ -656,16 +656,21 @@ public class TypeAnalyzer implements DartCompilationPhase {
member = itype.lookupMember("setter " + methodName);
}
// is "receiver" is inferred, attempt to find member in one of the subtypes
+ boolean hasMemberInSubClasses = false;
if (member == null) {
if (TypeQuality.of(receiver) == TypeQuality.INFERRED && receiver instanceof InterfaceType) {
- member = ((InterfaceType) receiver).lookupSubTypeMember(methodName);
+ List<Member> subMembers = ((InterfaceType) receiver).lookupSubTypeMembers(methodName);
+ hasMemberInSubClasses = !subMembers.isEmpty();
+ if (subMembers.size() == 1) {
+ member = subMembers.get(0);
+ }
}
}
// report problem
if (member == null && problemTarget != null) {
if (reportNoMemberWhenHasInterceptor || !Elements.handlesNoSuchMethod(itype)) {
- if (typeChecksForInferredTypes && !isTooGenericInferredType(receiver)
- || !TypeQuality.isInferred(receiver)) {
+ if (typeChecksForInferredTypes && !hasMemberInSubClasses
+ && !isTooGenericInferredType(receiver) || !TypeQuality.isInferred(receiver)) {
ErrorCode code = TypeQuality.isInferred(receiver)
? TypeErrorCode.INTERFACE_HAS_NO_METHOD_NAMED_INFERRED
: TypeErrorCode.INTERFACE_HAS_NO_METHOD_NAMED;
@@ -2396,16 +2401,22 @@ public class TypeAnalyzer implements DartCompilationPhase {
}
}
// is "receiver" is inferred, attempt to find member in one of the subtypes
+ // is "receiver" is inferred, attempt to find member in one of the subtypes
Brian Wilkerson 2013/01/29 18:32:33 In code review, this line appears to be duplicated
+ boolean hasMemberInSubClasses = false;
if (member == null) {
if (TypeQuality.of(receiver) == TypeQuality.INFERRED && receiver instanceof InterfaceType) {
- member = ((InterfaceType) receiver).lookupSubTypeMember(name);
+ List<Member> subMembers = ((InterfaceType) receiver).lookupSubTypeMembers(name);
+ hasMemberInSubClasses = !subMembers.isEmpty();
+ if (subMembers.size() == 1) {
+ member = subMembers.get(0);
+ }
}
}
// report "not a member"
if (member == null) {
if (reportNoMemberWhenHasInterceptor || !Elements.handlesNoSuchMethod(cls)) {
- if (typeChecksForInferredTypes && !isTooGenericInferredType(receiver)
- || !TypeQuality.isInferred(receiver)) {
+ if (typeChecksForInferredTypes && !hasMemberInSubClasses
+ && !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);
@@ -2448,7 +2459,10 @@ public class TypeAnalyzer implements DartCompilationPhase {
{
getterMember = cls.lookupMember(name);
if (getterMember == null && TypeQuality.of(cls) == TypeQuality.INFERRED) {
- getterMember = cls.lookupSubTypeMember(name);
+ List<Member> members = cls.lookupSubTypeMembers(name);
+ if (members.size() == 1) {
+ getterMember = members.get(0);
+ }
}
}
{

Powered by Google App Engine
This is Rietveld 408576698