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

Unified Diff: tests/language/src/FieldOverrideTest.dart

Issue 8859002: Overriding fields is now permissable. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 years 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/src/FieldOverrideTest.dart
diff --git a/tests/language/src/FieldOverrideTest.dart b/tests/language/src/FieldOverrideTest.dart
index 95a4c26417e634ae44febdd52e193a85a771f217..27816c420d6918f70e404d25c917430c8501d839 100644
--- a/tests/language/src/FieldOverrideTest.dart
+++ b/tests/language/src/FieldOverrideTest.dart
@@ -1,12 +1,13 @@
// Copyright (c) 2011, 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.
-
+// VMOptions=--enable_type_checks
// Test overriding of fields.
-interface A {}
-interface B1 extends A {}
-interface B2 extends A {}
+
+class A {}
+class B1 extends A {}
+class B2 extends A {}
class Super {
Super() : super();
@@ -17,15 +18,29 @@ class Super {
class Sub extends Super {
Sub() : super();
- A field; /// 01: compile-time error
+ A field;
}
class SubSub extends Super {
SubSub() : super();
- B2 field; /// 02: compile-time error
+ // B2 not assignable to B1
+ B2 field; /// 01: static type error
zundel 2011/12/07 19:44:56 ??? Dartc's type checker flags this as: tests/l
ahe 2011/12/08 08:53:46 Would you mind filing a specification bug?
}
main() {
- new SubSub();
+ SubSub val1 = new SubSub();
+ val1.field = new B2();
+ Expect.equals(true, val1.field is B2);
+
+ Sub val2 = new Sub();
+ val2.field = new A();
+ Expect.equals(true, val2.field is A);
+ Expect.equals(false, val2.field is B1);
+ Expect.equals(false, val2.field is B2);
+
+ Super val3 = new Super();
+ val3.field = new B1();
+ Expect.equals(true, val3.field is B1);
+ Expect.equals(false, val3.field is B2);
}
« tests/language/language.status ('K') | « tests/language/src/FieldNegativeTest.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698