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

Unified Diff: editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/NonErrorResolverTest.java

Issue 231473002: Fix for 16078- clarifications on the StaticWarningCode.FUNCTION_WITHOUT_CALL warning (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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: editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/NonErrorResolverTest.java
diff --git a/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/NonErrorResolverTest.java b/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/NonErrorResolverTest.java
index f4f34ea46d4ecb8a4b0bad384345b1c8714feabf..867d97997d8a189ee9abbd6de3c2a480558563e1 100644
--- a/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/NonErrorResolverTest.java
+++ b/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/NonErrorResolverTest.java
@@ -23,6 +23,38 @@ import com.google.dart.engine.parser.ParserErrorCode;
import com.google.dart.engine.source.Source;
public class NonErrorResolverTest extends ResolverTestCase {
+ public void fail_invocationOfNonFunction_proxyOnFunctionClass() throws Exception {
+ // 16078
+ //
+ // The fix would seem to be to add this code to change the else-if block in
+ // ElementResolver.isExecutableType() to
+ //
+ // ClassElement classElement = ((InterfaceType) type).getElement();
+ // if (type.isSubtypeOf(resolver.getTypeProvider().getFunctionType()) && classElement.isProxy()) {
+ // return false;
+ // }
+ // MethodElement methodElement = classElement.lookUpMethod(CALL_METHOD_NAME, definingLibrary);
+ // return methodElement != null;
+ //
+ // However, the call to isProxy() will always returns false since the metadata hasn't been set
+ // yet on Functor.
+ //
+ Source source = addSource(createSource(//
+ "@proxy",
+ "class Functor implements Function {",
+ " noSuchMethod(inv) {",
+ " return 42;",
+ " }",
+ "}",
+ "main() {",
+ " Functor f = new Functor();",
+ " f();",
+ "}"));
+ resolve(source);
+ assertErrors(source);
+ verify(source);
+ }
+
public void test_ambiguousExport() throws Exception {
Source source = addSource(createSource(//
"library L;",
@@ -1138,6 +1170,27 @@ public class NonErrorResolverTest extends ResolverTestCase {
verify(source);
}
+ public void test_functionWithoutCall_doesNotImplementFunction() throws Exception {
+ Source source = addSource(createSource(//
+ "class A {}"));
+ resolve(source);
+ assertNoErrors(source);
+ verify(source);
+ }
+
+ public void test_functionWithoutCall_withNoSuchMethod() throws Exception {
+ // 16078
+ Source source = addSource(createSource(//
+ "class A implements Function {",
+ " noSuchMethod(inv) {",
+ " return 42;",
+ " }",
+ "}"));
+ resolve(source);
+ assertNoErrors(source);
+ verify(source);
+ }
+
public void test_implicitThisReferenceInInitializer_constructorName() throws Exception {
Source source = addSource(createSource(//
"class A {",

Powered by Google App Engine
This is Rietveld 408576698