| 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 "native_testing.dart"; | 5 import "native_testing.dart"; |
| 6 | 6 |
| 7 makeA() native; | 7 makeA() native; |
| 8 nativeFirst(x, y) native; | 8 nativeFirst(x, y) native; |
| 9 | 9 |
| 10 void setup() native """ | 10 void setup() { |
| 11 nativeFirst = function(x, y) { return x; } | 11 JS('', r""" |
| 12 (function(){ |
| 13 nativeFirst = function(x, y) { return x; }; |
| 12 | 14 |
| 13 function A() {} | 15 function A() {} |
| 14 makeA = function() { return new A; } | 16 makeA = function() { return new A() }; |
| 15 self.nativeConstructor(A); | 17 self.nativeConstructor(A); |
| 16 """; | 18 })()"""); |
| 19 } |
| 17 | 20 |
| 18 @Native("A") | 21 @Native("A") |
| 19 class A { | 22 class A { |
| 20 var _foo; | 23 var _foo; |
| 21 | 24 |
| 22 get foo => _foo; | 25 get foo => _foo; |
| 23 | 26 |
| 24 init() { | 27 init() { |
| 25 _foo = () => 42; | 28 _foo = () => 42; |
| 26 } | 29 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 46 var b = new B(); | 49 var b = new B(); |
| 47 var c = new C(); | 50 var c = new C(); |
| 48 var d = new D(); | 51 var d = new D(); |
| 49 a = nativeFirst(a, b); | 52 a = nativeFirst(a, b); |
| 50 a = nativeFirst(a, c); | 53 a = nativeFirst(a, c); |
| 51 a = nativeFirst(a, d); | 54 a = nativeFirst(a, d); |
| 52 // The variable a is still an instance of class A, but dart2js can't infer | 55 // The variable a is still an instance of class A, but dart2js can't infer |
| 53 // that anymore. | 56 // that anymore. |
| 54 Expect.equals(42, a.foo()); | 57 Expect.equals(42, a.foo()); |
| 55 } | 58 } |
| OLD | NEW |