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

Unified Diff: tests/compiler/dart2js_extra/locate_single_element_1_test.dart

Issue 2284923002: Fix bug in locateSingleElement (Closed)
Patch Set: Created 4 years, 4 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_extra/locate_single_element_1_test.dart
diff --git a/tests/compiler/dart2js_extra/locate_single_element_1_test.dart b/tests/compiler/dart2js_extra/locate_single_element_1_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..5fe6e857ef2c8d63438d2ed661dc49293da189e1
--- /dev/null
+++ b/tests/compiler/dart2js_extra/locate_single_element_1_test.dart
@@ -0,0 +1,37 @@
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// Test for locateSingleElement bug.
+
+import 'package:expect/expect.dart';
+
+class T {
+ foo() => 'T.foo'; // This is the single element.
+}
+
+class C implements T {
+ // There is a warning that C does not implement 'foo'.
+}
+
+@NoInline() @AssumeDynamic()
+assumeT(x) { // returns inferred subtype(T).
+ if (x is T) return x;
+ throw "Not T";
+}
+
+var log = [];
+demo() {
+ log.add(new T()); // T is created.
+ var a = assumeT(new C()); // C is created.
+
+ // The call "a.foo()" should be a NoSuchMethodError, but a bug in
+ // locateSingleElement used to lead to T.foo being inlined. There is a single
+ // method. T.foo, that matches subtype(T), but it should be rejected because
+ // not all instantiated classes that are subtype(T) have that method.
+ log.add(a.foo());
+}
+
+main() {
+ Expect.throws(demo);
+}
« 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