| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 // Check that native fields are not incorrectly renamed. | 8 // Check that native fields are not incorrectly renamed. |
| 9 | 9 |
| 10 @Native("A") | 10 @Native("A") |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 writeable: false | 37 writeable: false |
| 38 } | 38 } |
| 39 }); | 39 }); |
| 40 a.getValue = 0; | 40 a.getValue = 0; |
| 41 return a; | 41 return a; |
| 42 } | 42 } |
| 43 | 43 |
| 44 makeA = function(){return new A;}; | 44 makeA = function(){return new A;}; |
| 45 """; | 45 """; |
| 46 | 46 |
| 47 A makeA() native { return new A(); } | 47 A makeA() native; |
| 48 | 48 |
| 49 main() { | 49 main() { |
| 50 setup(); | 50 setup(); |
| 51 var a = makeA(); | 51 var a = makeA(); |
| 52 a.myLongPropertyName = 21; | 52 a.myLongPropertyName = 21; |
| 53 int gotten = a.myLongPropertyName; | 53 int gotten = a.myLongPropertyName; |
| 54 Expect.equals(11, gotten); | 54 Expect.equals(11, gotten); |
| 55 | 55 |
| 56 var a2 = makeA(); | 56 var a2 = makeA(); |
| 57 if (a2 is A) { | 57 if (a2 is A) { |
| 58 // Inside this 'if' the compiler knows that a2 is an A, so it is tempted | 58 // Inside this 'if' the compiler knows that a2 is an A, so it is tempted |
| 59 // to access myLongPropertyName directly, using its minified name. But | 59 // to access myLongPropertyName directly, using its minified name. But |
| 60 // renaming of native properties can only work using getters and setters | 60 // renaming of native properties can only work using getters and setters |
| 61 // that access the original name. | 61 // that access the original name. |
| 62 a2.myLongPropertyName = 21; | 62 a2.myLongPropertyName = 21; |
| 63 int gotten = a2.myLongPropertyName; | 63 int gotten = a2.myLongPropertyName; |
| 64 Expect.equals(11, gotten); | 64 Expect.equals(11, gotten); |
| 65 } | 65 } |
| 66 } | 66 } |
| OLD | NEW |