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

Unified Diff: tests/compiler/dart2js/simple_inferrer_no_such_method_test.dart

Issue 1020853007: Don't bailout of type inference for simple NSM implementations (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 9 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
« no previous file with comments | « pkg/compiler/lib/src/types/flat_type_mask.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js/simple_inferrer_no_such_method_test.dart
diff --git a/tests/compiler/dart2js/simple_inferrer_no_such_method_test.dart b/tests/compiler/dart2js/simple_inferrer_no_such_method_test.dart
index 9e3a9875ba20d0585c739eb68484b466c8b4d736..3f913502f07bd341c9524fe00a6eaa09979badfb 100644
--- a/tests/compiler/dart2js/simple_inferrer_no_such_method_test.dart
+++ b/tests/compiler/dart2js/simple_inferrer_no_such_method_test.dart
@@ -6,6 +6,7 @@ import 'package:expect/expect.dart';
import "package:async_helper/async_helper.dart";
import 'compiler_helper.dart';
+import 'package:compiler/src/types/types.dart';
import 'parser_helper.dart';
import 'type_mask_test_helper.dart';
@@ -94,6 +95,72 @@ main() {
}
""";
+const String TEST3 = """
+class A {
+ // We may ignore this for type inference because syntactically it always
+ // throws an exception.
+ noSuchMethod(im) => throw 'foo';
+}
+
+class B extends A {
+ foo() => {};
+}
+
+class C extends B {
+ foo() => {};
+}
+
+var a = [new B(), new C()][0];
+test1() => new A().foo();
+test2() => a.foo();
+test3() => new B().foo();
+test4() => new C().foo();
+test5() => (a ? new A() : new B()).foo();
+test6() => (a ? new B() : new C()).foo();
+
+main() {
+ test1();
+ test2();
+ test3();
+ test4();
+ test5();
+ test6();
+}
+""";
+
+const String TEST4 = """
+class A {
+ // We may ignore this for type inference because it forwards to a default
+ // noSuchMethod implementation, which always throws an exception.
+ noSuchMethod(im) => super.noSuchMethod(im);
+}
+
+class B extends A {
+ foo() => {};
+}
+
+class C extends B {
+ foo() => {};
+}
+
+var a = [new B(), new C()][0];
+test1() => new A().foo();
+test2() => a.foo();
+test3() => new B().foo();
+test4() => new C().foo();
+test5() => (a ? new A() : new B()).foo();
+test6() => (a ? new B() : new C()).foo();
+
+main() {
+ test1();
+ test2();
+ test3();
+ test4();
+ test5();
+ test6();
+}
+""";
+
main() {
Uri uri = new Uri(scheme: 'source');
@@ -134,4 +201,24 @@ main() {
checkReturn(compiler2, 'test10', compiler2.typesTask.numType);
checkReturn(compiler2, 'test11', compiler2.typesTask.doubleType);
}));
+
+ var compiler3 = compilerFor(TEST3, uri);
+ asyncTest(() => compiler3.runCompiler(uri).then((_) {
+ checkReturn(compiler3, 'test1', const TypeMask.nonNullEmpty());
+ checkReturn(compiler3, 'test2', compiler3.typesTask.mapType);
+ checkReturn(compiler3, 'test3', compiler3.typesTask.mapType);
+ checkReturn(compiler3, 'test4', compiler3.typesTask.mapType);
+ checkReturn(compiler3, 'test5', compiler3.typesTask.mapType);
+ checkReturn(compiler3, 'test6', compiler3.typesTask.mapType);
+ }));
+
+ var compiler4 = compilerFor(TEST4, uri);
+ asyncTest(() => compiler4.runCompiler(uri).then((_) {
+ checkReturn(compiler4, 'test1', const TypeMask.nonNullEmpty());
+ checkReturn(compiler4, 'test2', compiler4.typesTask.mapType);
+ checkReturn(compiler4, 'test3', compiler4.typesTask.mapType);
+ checkReturn(compiler4, 'test4', compiler4.typesTask.mapType);
+ checkReturn(compiler4, 'test5', compiler4.typesTask.mapType);
+ checkReturn(compiler4, 'test6', compiler4.typesTask.mapType);
+ }));
}
« no previous file with comments | « pkg/compiler/lib/src/types/flat_type_mask.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698