| 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 "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
| 6 | 6 |
| 7 @AssumeDynamic() | 7 @AssumeDynamic() |
| 8 @NoInline() | 8 @NoInline() |
| 9 confuse(x) => x; | 9 confuse(x) => x; |
| 10 | 10 |
| 11 class A { | 11 class A { |
| 12 bar([var optional = 1]) => 498 + optional; | 12 bar([var optional = 1]) => 498 + optional; |
| 13 bar2({namedOptional: 2}) => 40 + namedOptional; | 13 bar2({ namedOptional: 2 }) => 40 + namedOptional; |
| 14 bar3(x, [var optional = 3]) => x + 498 + optional; | 14 bar3(x, [var optional = 3]) => x + 498 + optional; |
| 15 bar4(x, {namedOptional: 4}) => 422 + x + namedOptional; | 15 bar4(x, { namedOptional: 4 }) => 422 + x + namedOptional; |
| 16 | 16 |
| 17 // Gee is the same as bar, but we make sure that gee is used. Potentially | 17 // Gee is the same as bar, but we make sure that gee is used. Potentially |
| 18 // this yields different code if the redirecting stub exists. | 18 // this yields different code if the redirecting stub exists. |
| 19 gee([var optional = 1]) => 498 + optional; | 19 gee([var optional = 1]) => 498 + optional; |
| 20 gee2({namedOptional: 2}) => 40 + namedOptional; | 20 gee2({ namedOptional: 2 }) => 40 + namedOptional; |
| 21 gee3(x, [var optional = 3]) => x + 498 + optional; | 21 gee3(x, [var optional = 3]) => x + 498 + optional; |
| 22 gee4(x, {namedOptional: 4}) => 422 + x + namedOptional; | 22 gee4(x, { namedOptional: 4 }) => 422 + x + namedOptional; |
| 23 | 23 |
| 24 // Use identifiers that could be intercepted. | 24 // Use identifiers that could be intercepted. |
| 25 add([var optional = 33]) => 1234 + optional; | 25 add([var optional = 33]) => 1234 + optional; |
| 26 trim({namedOptional: 22}) => 1313 + namedOptional; | 26 trim({ namedOptional: 22 }) => 1313 + namedOptional; |
| 27 sublist(x, [optional = 44]) => 4321 + optional + x; | 27 sublist(x, [optional = 44]) => 4321 + optional + x; |
| 28 splitMapJoin(x, {onMatch: 55, onNonMatch: 66}) => | 28 splitMapJoin(x, { onMatch: 55, onNonMatch: 66}) => |
| 29 111 + x + onMatch + onNonMatch; | 29 111 + x + onMatch + onNonMatch; |
| 30 | 30 |
| 31 // Other interceptable identifiers, but all of them are used. | 31 // Other interceptable identifiers, but all of them are used. |
| 32 shuffle([var optional = 121]) => 12342 + optional; | 32 shuffle([var optional = 121]) => 12342 + optional; |
| 33 toList({growable: 2233}) => 13131 + growable; | 33 toList({ growable: 2233 }) => 13131 + growable; |
| 34 lastIndexOf(x, [optional = 424]) => 14321 + optional + x; | 34 lastIndexOf(x, [optional = 424]) => 14321 + optional + x; |
| 35 lastWhere(x, {orElse: 555}) => x + 1213 + 555; | 35 lastWhere(x, { orElse: 555 }) => x + 1213 + 555; |
| 36 } | 36 } |
| 37 | 37 |
| 38 class B extends A { | 38 class B extends A { |
| 39 // The closure `super.bar` is invoked without the optional argument. | 39 // The closure `super.bar` is invoked without the optional argument. |
| 40 // Dart2js must not generate a `bar$0 => bar$1(null)` closure, since that | 40 // Dart2js must not generate a `bar$0 => bar$1(null)` closure, since that |
| 41 // would redirect to B's `bar$1`. Instead it must enforce that `bar$0` in | 41 // would redirect to B's `bar$1`. Instead it must enforce that `bar$0` in |
| 42 // `A` redirects to A's bar$1. | 42 // `A` redirects to A's bar$1. |
| 43 foo() => confuse(super.bar)(); | 43 foo() => confuse(super.bar)(); |
| 44 foo2() => confuse(super.bar)(2); | 44 foo2() => confuse(super.bar)(2); |
| 45 foo3() => confuse(super.bar2)(); | 45 foo3() => confuse(super.bar2)(); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 bar2({ namedOptional }) => -1; // //# 01: continued | 80 bar2({ namedOptional }) => -1; // //# 01: continued |
| 81 bar3(x, [var optional]) => -1; // //# 01: continued | 81 bar3(x, [var optional]) => -1; // //# 01: continued |
| 82 bar4(x, { namedOptional }) => -1; //# 01: continued | 82 bar4(x, { namedOptional }) => -1; //# 01: continued |
| 83 | 83 |
| 84 gee([var optional]) => -1; // //# 01: continued | 84 gee([var optional]) => -1; // //# 01: continued |
| 85 gee2({ namedOptional }) => -1; // //# 01: continued | 85 gee2({ namedOptional }) => -1; // //# 01: continued |
| 86 gee3(x, [var optional]) => -1; // //# 01: continued | 86 gee3(x, [var optional]) => -1; // //# 01: continued |
| 87 gee4(x, { namedOptional }) => -1; //# 01: continued | 87 gee4(x, { namedOptional }) => -1; //# 01: continued |
| 88 | 88 |
| 89 add([var optional = 33]) => -1; | 89 add([var optional = 33]) => -1; |
| 90 trim({namedOptional: 22}) => -1; | 90 trim({ namedOptional: 22 }) => -1; |
| 91 sublist(x, [optional = 44]) => -1; | 91 sublist(x, [optional = 44]) => -1; |
| 92 splitMapJoin(x, {onMatch: 55, onNonMatch: 66}) => -1; | 92 splitMapJoin(x, { onMatch: 55, onNonMatch: 66}) => -1; |
| 93 | 93 |
| 94 shuffle([var optional = 121]) => -1; | 94 shuffle([var optional = 121]) => -1; |
| 95 toList({growable: 2233}) => -1; | 95 toList({ growable: 2233 }) => -1; |
| 96 lastIndexOf(x, [optional = 424]) => -1; | 96 lastIndexOf(x, [optional = 424]) => -1; |
| 97 lastWhere(x, {orElse: 555}) => -1; | 97 lastWhere(x, { orElse: 555 }) => -1; |
| 98 } | 98 } |
| 99 | 99 |
| 100 main() { | 100 main() { |
| 101 var list = [new A(), new B(), [], "foo"]; | 101 var list = [new A(), new B(), [], "foo" ]; |
| 102 var a = list[confuse(0)]; | 102 var a = list[confuse(0)]; |
| 103 var b = list[confuse(1)]; | 103 var b = list[confuse(1)]; |
| 104 var ignored = list[confuse(2)]; | 104 var ignored = list[confuse(2)]; |
| 105 var ignored2 = list[confuse(3)]; | 105 var ignored2 = list[confuse(3)]; |
| 106 | 106 |
| 107 var t = b.gee() + b.gee2() + b.gee3(9) + b.gee4(19); | 107 var t = b.gee() + b.gee2() + b.gee3(9) + b.gee4(19); |
| 108 Expect.equals(-4, t); //# 01: continued | 108 Expect.equals(-4, t); //# 01: continued |
| 109 t = b.shuffle() + b.toList() + b.lastIndexOf(1) + b.lastWhere(2); | 109 t = b.shuffle() + b.toList() + b.lastIndexOf(1) + b.lastWhere(2); |
| 110 Expect.equals(-4, t); | 110 Expect.equals(-4, t); |
| 111 | 111 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 138 | 138 |
| 139 Expect.equals(12463, b.fooIntercept21()); | 139 Expect.equals(12463, b.fooIntercept21()); |
| 140 Expect.equals(12344, b.fooIntercept22()); | 140 Expect.equals(12344, b.fooIntercept22()); |
| 141 Expect.equals(15364, b.fooIntercept23()); | 141 Expect.equals(15364, b.fooIntercept23()); |
| 142 Expect.equals(13208, b.fooIntercept24()); | 142 Expect.equals(13208, b.fooIntercept24()); |
| 143 Expect.equals(14742, b.fooIntercept25()); | 143 Expect.equals(14742, b.fooIntercept25()); |
| 144 Expect.equals(14291, b.fooIntercept26()); | 144 Expect.equals(14291, b.fooIntercept26()); |
| 145 Expect.equals(1768, b.fooIntercept27()); | 145 Expect.equals(1768, b.fooIntercept27()); |
| 146 Expect.equals(1771, b.fooIntercept28()); | 146 Expect.equals(1771, b.fooIntercept28()); |
| 147 } | 147 } |
| OLD | NEW |