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:_js_helper' show Creates, setNativeSubclassDispatchRecord; |
| 7 import 'dart:_interceptors' show findInterceptorForType; |
| 8 |
| 9 // Test calling convention of methods introduced on subclasses of native |
| 10 // classes. |
| 11 |
| 12 doFoo(r, x) => '$x,${r.oof()}'; |
| 13 |
| 14 class A native "A" { |
| 15 foo(x) => (doFoo)(this, x); |
| 16 } |
| 17 |
| 18 class B extends A { |
| 19 // [oof] is introduced only on this subclass of a native class. It should |
| 20 // have interceptor calling convention. |
| 21 oof() => 'B'; |
| 22 } |
| 23 |
| 24 B makeB() native; |
| 25 |
| 26 @Creates('=Object') |
| 27 getBPrototype() native; |
| 28 |
| 29 void setup() native r""" |
| 30 function A() {} |
| 31 function B() {} |
| 32 makeA = function(){return new A;}; |
| 33 makeB = function(){return new B;}; |
| 34 |
| 35 getBPrototype = function(){return B.prototype;}; |
| 36 """; |
| 37 |
| 38 main() { |
| 39 setup(); |
| 40 |
| 41 setNativeSubclassDispatchRecord(getBPrototype(), findInterceptorForType(B)); |
| 42 |
| 43 B b = makeB(); |
| 44 Expect.equals('1,B', b.foo(1)); |
| 45 } |
OLD | NEW |