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

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

Issue 10915171: Don't report 'no such method' if class defines 'noSuchMethod' (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add preference Created 8 years, 3 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 a3956a14f465c0649d8136032ee814314627dd02..e0fe9123bb144fc12fe7ec63c21a8e992f38ca61 100644
--- a/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java
+++ b/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java
@@ -185,6 +185,7 @@ public class TypeAnalyzer implements DartCompilationPhase {
private final boolean developerModeChecks;
private final boolean suppressSdkWarnings;
private final boolean typeChecksForInferredTypes;
+ private final boolean reportNoMemberWhenHasInterceptor;
private final Map<DartBlock, VariableElementsRestorer> restoreOnBlockExit = Maps.newHashMap();
/**
* When we see variable assignment, we remember here old {@link Type} (if not done already) and
@@ -255,6 +256,7 @@ public class TypeAnalyzer implements DartCompilationPhase {
CompilerOptions compilerOptions = context.getCompilerConfiguration().getCompilerOptions();
this.suppressSdkWarnings = compilerOptions.suppressSdkWarnings();
this.typeChecksForInferredTypes = compilerOptions.typeChecksForInferredTypes();
+ this.reportNoMemberWhenHasInterceptor = compilerOptions.reportNoMemberWhenHasInterceptor();
}
@VisibleForTesting
@@ -630,11 +632,13 @@ public class TypeAnalyzer implements DartCompilationPhase {
}
Member member = itype.lookupMember(methodName);
if (member == null && problemTarget != null) {
- if (typeChecksForInferredTypes || !receiver.isInferred()) {
- ErrorCode code = receiver.isInferred()
- ? TypeErrorCode.INTERFACE_HAS_NO_METHOD_NAMED_INFERRED
- : TypeErrorCode.INTERFACE_HAS_NO_METHOD_NAMED;
- typeError(problemTarget, code, receiver, methodName);
+ if (reportNoMemberWhenHasInterceptor || !Elements.handlesNoSuchMethod(itype)) {
+ if (typeChecksForInferredTypes || !receiver.isInferred()) {
+ ErrorCode code = receiver.isInferred()
+ ? TypeErrorCode.INTERFACE_HAS_NO_METHOD_NAMED_INFERRED
+ : TypeErrorCode.INTERFACE_HAS_NO_METHOD_NAMED;
+ typeError(problemTarget, code, receiver, methodName);
+ }
}
return null;
}
@@ -2227,10 +2231,12 @@ public class TypeAnalyzer implements DartCompilationPhase {
String name = node.getPropertyName();
InterfaceType.Member member = cls.lookupMember(name);
if (member == null) {
- if (typeChecksForInferredTypes || !receiver.isInferred()) {
- TypeErrorCode errorCode = receiver.isInferred() ? TypeErrorCode.NOT_A_MEMBER_OF_INFERRED
- : TypeErrorCode.NOT_A_MEMBER_OF;
- typeError(node.getName(), errorCode, name, cls);
+ if (reportNoMemberWhenHasInterceptor || !Elements.handlesNoSuchMethod(cls)) {
+ if (typeChecksForInferredTypes || !receiver.isInferred()) {
+ TypeErrorCode errorCode = receiver.isInferred()
+ ? TypeErrorCode.NOT_A_MEMBER_OF_INFERRED : TypeErrorCode.NOT_A_MEMBER_OF;
+ typeError(node.getName(), errorCode, name, cls);
+ }
}
return dynamicType;
}

Powered by Google App Engine
This is Rietveld 408576698