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

Side by Side Diff: tests/language/abstract_method_test.dart

Issue 227703010: Fix instance method resolution with abstract accessors and methods (Closed) Base URL: http://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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/parser.cc ('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) 2014, 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 import "package:expect/expect.dart";
6
7 // Checks that abstract instance methods are correctly resolved.
8
9 int get length => throw "error: top-level getter called";
10 int set height(x) { throw "error: top-level setter called"; }
11 width() { throw "error: top-level function called"; }
12
13 class A {
14 int get length; // Abstract instance getter.
15 int set height(x); // Abstract instance setter.
16 int width(); // Abstract instance method.
17
18 // Must resolve to non-abstract length getter in subclass.
19 get useLength => length;
20 // Must resolve to non-abstract height setter in subclass.
21 setHeight(x) => height = x;
22 // Must resolve to non-abstract width() method in subclass.
23 useWidth() => width();
24 }
25
26 class A1 extends A {
27 int length; // Implies a length getter.
28 int height; // Implies a height setter.
29 int width() => 345;
30 A1(this.length);
31 }
32
33 main() {
34 var a = new A1(123);
35 Expect.equals(123, a.useLength);
36 a.setHeight(234);
37 Expect.equals(234, a.height);
38 Expect.equals(345, a.useWidth());
39 print([a.useLength, a.height, a.useWidth()]);
40 }
41
OLDNEW
« no previous file with comments | « runtime/vm/parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698