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