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

Unified Diff: tests/language/no_such_method_subtype_test.dart

Issue 23447011: A typed selector needs no such method handling if at least one of its implemented subtype (in case … (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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: tests/language/no_such_method_subtype_test.dart
===================================================================
--- tests/language/no_such_method_subtype_test.dart (revision 0)
+++ tests/language/no_such_method_subtype_test.dart (revision 0)
@@ -0,0 +1,27 @@
+// Copyright (c) 2013, 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.
+
+import "package:expect/expect.dart";
+
+class A {
+ foo() => 42;
+}
+
+class B implements A {
+ noSuchMethod(im) => 84;
+}
+
+main() {
+ var a = [new A(), new B()];
+ var b = a[1];
+ if (b is A) {
+ // `b.foo()` will create a typed selector whose receiver type is a
+ // subtype of `A`. Because not all subtypes of `A` implement
+ // `foo`, dart2js must generate a `noSuchMethod` stub for `foo` in
+ // the top Object class.
+ Expect.equals(84, b.foo());
+ return;
+ }
+ Expect.fail('Should not be here');
+}

Powered by Google App Engine
This is Rietveld 408576698