OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013, 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 import 'dart:_foreign_helper' show JS; |
| 7 import 'dart:_js_helper' show Creates, setNativeSubclassDispatchRecord; |
| 8 import 'dart:_interceptors' show |
| 9 findInterceptorForType, findConstructorForNativeSubclassType; |
| 10 |
| 11 // Test for shadowed fields in classes that extend native classes. |
| 12 |
| 13 class N native "N" { |
| 14 N.init(); |
| 15 } |
| 16 |
| 17 class A extends N { |
| 18 var foo = 111; |
| 19 A.init() : super.init(); |
| 20 } |
| 21 |
| 22 class B extends A { |
| 23 var foo = 222; |
| 24 B.init() : super.init(); |
| 25 |
| 26 Afoo() => super.foo; |
| 27 Bfoo() => foo; |
| 28 } |
| 29 |
| 30 B makeB() native; |
| 31 |
| 32 @Creates('=Object') |
| 33 getBPrototype() native; |
| 34 |
| 35 void setup() native r""" |
| 36 function B() { } |
| 37 makeB = function(){return new B;}; |
| 38 |
| 39 getBPrototype = function(){return B.prototype;}; |
| 40 """; |
| 41 |
| 42 var inscrutable; |
| 43 |
| 44 main() { |
| 45 setup(); |
| 46 inscrutable = (x) => x; |
| 47 |
| 48 setNativeSubclassDispatchRecord(getBPrototype(), findInterceptorForType(B)); |
| 49 |
| 50 B b = makeB(); |
| 51 |
| 52 var constructor = findConstructorForNativeSubclassType(B, 'init'); |
| 53 Expect.isNotNull(constructor); |
| 54 JS('', '#(#)', constructor, b); |
| 55 |
| 56 print(b); |
| 57 |
| 58 Expect.equals(222, inscrutable(b).Bfoo()); |
| 59 Expect.equals(111, inscrutable(b).Afoo()); |
| 60 |
| 61 Expect.equals(222, b.Bfoo()); |
| 62 Expect.equals(111, b.Afoo()); |
| 63 } |
OLD | NEW |