| 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 // Check that native fields are not incorrectly renamed. | 5 // Verify that native fields on classes are not renamed by the minifier. |
| 6 | |
| 7 class A native "*A" { | 6 class A native "*A" { |
| 8 int myLongPropertyName; | 7 int myLongPropertyName; |
| 9 int getValue; | 8 int getValue; |
| 10 | 9 |
| 11 int method(int z) => myLongPropertyName; | 10 int method(int z) => myLongPropertyName; |
| 12 } | 11 } |
| 13 | 12 |
| 14 | 13 |
| 15 // This code is inside the setup function, so the function names are not | |
| 16 // accessible, but the makeA variable is global through the magic of JS scoping. | |
| 17 // The contents of this are of course not analyzable by the compiler. | |
| 18 void setup() native r""" | 14 void setup() native r""" |
| 19 function getter() { | 15 function getter() { |
| 20 return ++this.getValue; | 16 return ++this.getValue; |
| 21 } | 17 } |
| 22 | 18 |
| 23 function setter(x) { | 19 function setter(x) { |
| 24 this.getValue += 10; | 20 this.getValue += 10; |
| 25 } | 21 } |
| 26 | 22 |
| 27 function A(){ | 23 function A(){ |
| (...skipping 26 matching lines...) Expand all Loading... |
| 54 // Inside this 'if' the compiler knows that a2 is an A, so it is tempted | 50 // Inside this 'if' the compiler knows that a2 is an A, so it is tempted |
| 55 // to access myLongPropertyName directly, using its minified name. But | 51 // to access myLongPropertyName directly, using its minified name. But |
| 56 // renaming of native properties can only work using getters and setters | 52 // renaming of native properties can only work using getters and setters |
| 57 // that access the original name. | 53 // that access the original name. |
| 58 a2.myLongPropertyName = 21; | 54 a2.myLongPropertyName = 21; |
| 59 int gotten = a2.myLongPropertyName; | 55 int gotten = a2.myLongPropertyName; |
| 60 Expect.equals(11, gotten); | 56 Expect.equals(11, gotten); |
| 61 } | 57 } |
| 62 } | 58 } |
| 63 | 59 |
| OLD | NEW |