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

Side by Side Diff: tests/compiler/dart2js_extra/locate_single_element_1_test.dart

Issue 2284923002: Fix bug in locateSingleElement (Closed)
Patch Set: Created 4 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 // Test for locateSingleElement bug.
6
7 import 'package:expect/expect.dart';
8
9 class T {
10 foo() => 'T.foo'; // This is the single element.
11 }
12
13 class C implements T {
14 // There is a warning that C does not implement 'foo'.
15 }
16
17 @NoInline() @AssumeDynamic()
18 assumeT(x) { // returns inferred subtype(T).
19 if (x is T) return x;
20 throw "Not T";
21 }
22
23 var log = [];
24 demo() {
25 log.add(new T()); // T is created.
26 var a = assumeT(new C()); // C is created.
27
28 // The call "a.foo()" should be a NoSuchMethodError, but a bug in
29 // locateSingleElement used to lead to T.foo being inlined. There is a single
30 // method. T.foo, that matches subtype(T), but it should be rejected because
31 // not all instantiated classes that are subtype(T) have that method.
32 log.add(a.foo());
33 }
34
35 main() {
36 Expect.throws(demo);
37 }
OLDNEW
« 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