OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import "dart:_js_helper"; | 5 import "dart:_js_helper"; |
6 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
7 | 7 |
8 makeA() native; | 8 makeA() native ; |
9 nativeFirst(x, y) native; | 9 nativeFirst(x, y) native ; |
10 | 10 |
11 void setup() native """ | 11 void setup() native """ |
12 nativeFirst = function(x, y) { return x; } | 12 nativeFirst = function(x, y) { return x; } |
13 | 13 |
14 function A() {} | 14 function A() {} |
15 makeA = function() { return new A; } | 15 makeA = function() { return new A; } |
16 """; | 16 """; |
17 | 17 |
18 | |
19 @Native("A") | 18 @Native("A") |
20 class A { | 19 class A { |
21 var _foo; | 20 var _foo; |
22 | 21 |
23 get foo => _foo; | 22 get foo => _foo; |
24 | 23 |
25 init() { | 24 init() { |
26 _foo = () => 42; | 25 _foo = () => 42; |
27 } | 26 } |
28 } | 27 } |
(...skipping 17 matching lines...) Expand all Loading... |
46 var b = new B(); | 45 var b = new B(); |
47 var c = new C(); | 46 var c = new C(); |
48 var d = new D(); | 47 var d = new D(); |
49 a = nativeFirst(a, b); | 48 a = nativeFirst(a, b); |
50 a = nativeFirst(a, c); | 49 a = nativeFirst(a, c); |
51 a = nativeFirst(a, d); | 50 a = nativeFirst(a, d); |
52 // The variable a is still an instance of class A, but dart2js can't infer | 51 // The variable a is still an instance of class A, but dart2js can't infer |
53 // that anymore. | 52 // that anymore. |
54 Expect.equals(42, a.foo()); | 53 Expect.equals(42, a.foo()); |
55 } | 54 } |
OLD | NEW |