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

Unified Diff: compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.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/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
diff --git a/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java b/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
index a6c47020b19ac7538eece7eb31b042b7b9b30027..b13120b98b1d21c74f16fd19068733a8cf2b7b39 100644
--- a/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
+++ b/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
@@ -4356,6 +4356,88 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
assertErrors(result.getErrors());
}
+ /**
+ * Don't report "no such member" if class implements "noSuchMethod" method.
+ */
+ public void test_dontReport_ifHas_noSuchMember_method() throws Exception {
+ String[] lines = {
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "class A {",
+ " noSuchMethod(String name, List args) {}",
+ "}",
+ "class B extends A {}",
+ "class C {}",
+ "main() {",
+ " new A().notExistingMethod();",
+ " new B().notExistingMethod();",
+ " new C().notExistingMethod();",
+ "}",
+ "process(x) {}",
+ ""};
+ // report by default
+ {
+ AnalyzeLibraryResult result = analyzeLibrary(lines);
+ assertErrors(
+ result.getErrors(),
+ errEx(TypeErrorCode.INTERFACE_HAS_NO_METHOD_NAMED, 8, 11, 17),
+ errEx(TypeErrorCode.INTERFACE_HAS_NO_METHOD_NAMED, 9, 11, 17),
+ errEx(TypeErrorCode.INTERFACE_HAS_NO_METHOD_NAMED, 10, 11, 17));
+ }
+ // don't report
+ {
+ compilerConfiguration = new DefaultCompilerConfiguration(new CompilerOptions() {
+ @Override
+ public boolean reportNoMemberWhenHasInterceptor() {
+ return false;
+ }
+ });
+ AnalyzeLibraryResult result = analyzeLibrary(lines);
+ assertErrors(
+ result.getErrors(),
+ errEx(TypeErrorCode.INTERFACE_HAS_NO_METHOD_NAMED, 10, 11, 17));
+ }
+ }
+
+ /**
+ * Don't report "no such member" if class implements "noSuchMethod" method.
+ */
+ public void test_dontReport_ifHas_noSuchMember_getter() throws Exception {
+ String[] lines = {
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "class A {",
+ " noSuchMethod(String name, List args) {}",
+ "}",
+ "class B extends A {}",
+ "class C {}",
+ "main() {",
+ " process( new A().notExistingGetter );",
+ " process( new B().notExistingGetter );",
+ " process( new C().notExistingGetter );",
+ "}",
+ "process(x) {}",
+ ""};
+ // report by default
+ {
+ AnalyzeLibraryResult result = analyzeLibrary(lines);
+ assertErrors(
+ result.getErrors(),
+ errEx(TypeErrorCode.NOT_A_MEMBER_OF, 8, 20, 17),
+ errEx(TypeErrorCode.NOT_A_MEMBER_OF, 9, 20, 17),
+ errEx(TypeErrorCode.NOT_A_MEMBER_OF, 10, 20, 17));
+ }
+ // don't report
+ {
+ compilerConfiguration = new DefaultCompilerConfiguration(new CompilerOptions() {
+ @Override
+ public boolean reportNoMemberWhenHasInterceptor() {
+ return false;
+ }
+ });
+ AnalyzeLibraryResult result = analyzeLibrary(lines);
+ assertErrors(result.getErrors(), errEx(TypeErrorCode.NOT_A_MEMBER_OF, 10, 20, 17));
+ }
+ }
+
private <T extends DartNode> T findNode(final Class<T> clazz, String pattern) {
final int index = testSource.indexOf(pattern);
assertTrue(index != -1);

Powered by Google App Engine
This is Rietveld 408576698