Files
sdk/tests/language/cast2_test.dart
T
floitsch@google.com 03b7471b30 Fix access to fields that didn't exist in the class.
Say we have
class A{}
class B extends A { var x; }

and somewhere:
new A().x;

Then we would see if there was only one field 'x' in the whole type-hierarchy
(including B), but we failed to verify that the field was accessible from A.

Review URL: https://chromiumcodereview.appspot.com//10834343

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@10841 260f80e4-7a28-3924-810f-c04153c831b5
2012-08-16 17:05:19 +00:00

24 lines
496 B
Dart

// Copyright (c) 2012, 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.
// Dart test program for constructors and initializers.
// Test 'expression as Type' casts.
class C {
final int foo = 42;
}
class D extends C {
final int bar = 37;
}
main() {
Object oc = new C();
Object od = new D();
(oc as Dynamic).bar; /// 01: runtime error
}