| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 library dart2js.kernel.impact_test; | 5 library dart2js.kernel.impact_test; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'package:async_helper/async_helper.dart'; | 8 import 'package:async_helper/async_helper.dart'; |
| 9 import 'package:compiler/src/commandline_options.dart'; | 9 import 'package:compiler/src/commandline_options.dart'; |
| 10 import 'package:compiler/src/common.dart'; | 10 import 'package:compiler/src/common.dart'; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 testNull(); | 32 testNull(); |
| 33 testTrue(); | 33 testTrue(); |
| 34 testFalse(); | 34 testFalse(); |
| 35 testInt(); | 35 testInt(); |
| 36 testDouble(); | 36 testDouble(); |
| 37 testString(); | 37 testString(); |
| 38 testStringInterpolation(); | 38 testStringInterpolation(); |
| 39 testStringInterpolationConst(); | 39 testStringInterpolationConst(); |
| 40 testStringJuxtaposition(); | 40 testStringJuxtaposition(); |
| 41 testSymbol(); | 41 testSymbol(); |
| 42 testTypeLiteral(); |
| 43 testBoolFromEnvironment(); |
| 42 testEmptyListLiteral(); | 44 testEmptyListLiteral(); |
| 43 testEmptyListLiteralDynamic(); | 45 testEmptyListLiteralDynamic(); |
| 44 testEmptyListLiteralTyped(); | 46 testEmptyListLiteralTyped(); |
| 45 testEmptyListLiteralConstant(); | 47 testEmptyListLiteralConstant(); |
| 46 testNonEmptyListLiteral(); | 48 testNonEmptyListLiteral(); |
| 47 testEmptyMapLiteral(); | 49 testEmptyMapLiteral(); |
| 48 testEmptyMapLiteralDynamic(); | 50 testEmptyMapLiteralDynamic(); |
| 49 testEmptyMapLiteralTyped(); | 51 testEmptyMapLiteralTyped(); |
| 50 testEmptyMapLiteralConstant(); | 52 testEmptyMapLiteralConstant(); |
| 51 testNonEmptyMapLiteral(); | 53 testNonEmptyMapLiteral(); |
| 52 testNot(); | 54 testNot(); |
| 53 testUnaryMinus(); | 55 testUnaryMinus(); |
| 54 testConditional(); | 56 testConditional(); |
| 55 testPostInc(null); | 57 testPostInc(null); |
| 56 testPostDec(null); | 58 testPostDec(null); |
| 57 testPreInc(null); | 59 testPreInc(null); |
| 58 testPreDec(null); | 60 testPreDec(null); |
| 59 testIs(null); | 61 testIs(); |
| 60 testIsGeneric(null); | 62 testIsGeneric(); |
| 61 testIsGenericRaw(null); | 63 testIsGenericRaw(); |
| 62 testIsGenericDynamic(null); | 64 testIsGenericDynamic(); |
| 63 testIsNot(null); | 65 testIsNot(); |
| 64 testIsNotGeneric(null); | 66 testIsNotGeneric(); |
| 65 testIsNotGenericRaw(null); | 67 testIsNotGenericRaw(); |
| 66 testIsNotGenericDynamic(null); | 68 testIsNotGenericDynamic(); |
| 67 testIsTypedef(null); | 69 testIsTypedef(); |
| 68 testIsTypedefGeneric(null); | 70 testIsTypedefGeneric(); |
| 69 testIsTypedefGenericRaw(null); | 71 testIsTypedefGenericRaw(); |
| 70 testIsTypedefGenericDynamic(null); | 72 testIsTypedefGenericDynamic(); |
| 71 testAs(null); | 73 testIsTypedefDeep(); |
| 72 testAsGeneric(null); | 74 testAs(); |
| 73 testAsGenericRaw(null); | 75 testAsGeneric(); |
| 74 testAsGenericDynamic(null); | 76 testAsGenericRaw(); |
| 77 testAsGenericDynamic(); |
| 75 testThrow(); | 78 testThrow(); |
| 79 testIfNotNull(null); |
| 80 testIfNotNullSet(null); |
| 76 testIfNull(null); | 81 testIfNull(null); |
| 77 testSetIfNull(null); | 82 testSetIfNull(null); |
| 78 testSyncStar(); | 83 testSyncStar(); |
| 79 testAsync(); | 84 testAsync(); |
| 80 testAsyncStar(); | 85 testAsyncStar(); |
| 81 testIfThen(); | 86 testIfThen(); |
| 82 testIfThenElse(); | 87 testIfThenElse(); |
| 83 testForIn(null); | 88 testForIn(null); |
| 84 testForInTyped(null); | 89 testForInTyped(null); |
| 85 testAsyncForIn(null); | 90 testAsyncForIn(null); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 100 testTopLevelSetterSetTyped(); | 105 testTopLevelSetterSetTyped(); |
| 101 testTopLevelField(); | 106 testTopLevelField(); |
| 102 testTopLevelFieldLazy(); | 107 testTopLevelFieldLazy(); |
| 103 testTopLevelFieldConst(); | 108 testTopLevelFieldConst(); |
| 104 testTopLevelFieldFinal(); | 109 testTopLevelFieldFinal(); |
| 105 testTopLevelFieldTyped(); | 110 testTopLevelFieldTyped(); |
| 106 testTopLevelFieldGeneric1(); | 111 testTopLevelFieldGeneric1(); |
| 107 testTopLevelFieldGeneric2(); | 112 testTopLevelFieldGeneric2(); |
| 108 testTopLevelFieldGeneric3(); | 113 testTopLevelFieldGeneric3(); |
| 109 testTopLevelFieldWrite(); | 114 testTopLevelFieldWrite(); |
| 115 testStaticFunctionGet(); |
| 110 testDynamicInvoke(null); | 116 testDynamicInvoke(null); |
| 111 testDynamicGet(null); | 117 testDynamicGet(null); |
| 112 testDynamicSet(null); | 118 testDynamicSet(null); |
| 113 testLocalWithoutInitializer(); | 119 testLocalWithoutInitializer(); |
| 114 testLocalWithInitializer(); | 120 testLocalWithInitializer(); |
| 115 testLocalWithInitializerTyped(); | 121 testLocalWithInitializerTyped(); |
| 116 testLocalFunction(); | 122 testLocalFunction(); |
| 117 testLocalFunctionTyped(); | 123 testLocalFunctionTyped(); |
| 118 testLocalFunctionInvoke(); | 124 testLocalFunctionInvoke(); |
| 119 testLocalFunctionGet(); | 125 testLocalFunctionGet(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 136 testRedirectingFactoryInvokeGenericRaw(); | 142 testRedirectingFactoryInvokeGenericRaw(); |
| 137 testRedirectingFactoryInvokeGenericDynamic(); | 143 testRedirectingFactoryInvokeGenericDynamic(); |
| 138 testConstRedirectingFactoryInvoke(); | 144 testConstRedirectingFactoryInvoke(); |
| 139 testConstRedirectingFactoryInvokeGeneric(); | 145 testConstRedirectingFactoryInvokeGeneric(); |
| 140 testConstRedirectingFactoryInvokeGenericRaw(); | 146 testConstRedirectingFactoryInvokeGenericRaw(); |
| 141 testConstRedirectingFactoryInvokeGenericDynamic(); | 147 testConstRedirectingFactoryInvokeGenericDynamic(); |
| 142 testImplicitConstructor(); | 148 testImplicitConstructor(); |
| 143 testFactoryConstructor(); | 149 testFactoryConstructor(); |
| 144 testDefaultValuesPositional(); | 150 testDefaultValuesPositional(); |
| 145 testDefaultValuesNamed(); | 151 testDefaultValuesNamed(); |
| 152 testFieldInitializer1(); |
| 153 testFieldInitializer2(); |
| 154 testInstanceFieldWithInitializer(); |
| 155 testInstanceFieldTyped(); |
| 156 testThisInitializer(); |
| 157 testSuperInitializer(); |
| 158 testGenericClass(); |
| 159 testSuperCall(); |
| 160 testSuperGet(); |
| 161 testSuperFieldSet(); |
| 162 testSuperSetterSet(); |
| 163 testSuperClosurization(); |
| 164 testForwardingConstructor(); |
| 165 testForwardingConstructorTyped(); |
| 166 testForwardingConstructorGeneric(); |
| 167 testEnum(); |
| 146 } | 168 } |
| 147 | 169 |
| 148 testEmpty() {} | 170 testEmpty() {} |
| 149 testNull() => null; | 171 testNull() => null; |
| 150 testTrue() => true; | 172 testTrue() => true; |
| 151 testFalse() => false; | 173 testFalse() => false; |
| 152 testInt() => 42; | 174 testInt() => 42; |
| 153 testDouble() => 37.5; | 175 testDouble() => 37.5; |
| 154 testString() => 'foo'; | 176 testString() => 'foo'; |
| 155 testStringInterpolation() => '${0}'; | 177 testStringInterpolation() => '${0}'; |
| 156 testStringInterpolationConst() { | 178 testStringInterpolationConst() { |
| 157 const b = '${0}'; | 179 const b = '${0}'; |
| 158 } | 180 } |
| 159 testStringJuxtaposition() => 'a' 'b'; | 181 testStringJuxtaposition() => 'a' 'b'; |
| 160 testSymbol() => #main; | 182 testSymbol() => #main; |
| 183 testTypeLiteral() => Object; |
| 184 testBoolFromEnvironment() => const bool.fromEnvironment('FOO'); |
| 161 testEmptyListLiteral() => []; | 185 testEmptyListLiteral() => []; |
| 162 testEmptyListLiteralDynamic() => <dynamic>[]; | 186 testEmptyListLiteralDynamic() => <dynamic>[]; |
| 163 testEmptyListLiteralTyped() => <String>[]; | 187 testEmptyListLiteralTyped() => <String>[]; |
| 164 testEmptyListLiteralConstant() => const []; | 188 testEmptyListLiteralConstant() => const []; |
| 165 testNonEmptyListLiteral() => [0]; | 189 testNonEmptyListLiteral() => [0]; |
| 166 testEmptyMapLiteral() => {}; | 190 testEmptyMapLiteral() => {}; |
| 167 testEmptyMapLiteralDynamic() => <dynamic, dynamic>{}; | 191 testEmptyMapLiteralDynamic() => <dynamic, dynamic>{}; |
| 168 testEmptyMapLiteralTyped() => <String, int>{}; | 192 testEmptyMapLiteralTyped() => <String, int>{}; |
| 169 testEmptyMapLiteralConstant() => const {}; | 193 testEmptyMapLiteralConstant() => const {}; |
| 170 testNonEmptyMapLiteral() => {0: true}; | 194 testNonEmptyMapLiteral() => {0: true}; |
| 171 testNot() => !false; | 195 testNot() => !false; |
| 172 testUnaryMinus() => -1; | 196 testUnaryMinus() => -1; |
| 173 testConditional() => true ? 1 : ''; | 197 testConditional() => true ? 1 : ''; |
| 174 testPostInc(o) => o++; | 198 testPostInc(o) => o++; |
| 175 testPostDec(o) => o--; | 199 testPostDec(o) => o--; |
| 176 testPreInc(o) => ++o; | 200 testPreInc(o) => ++o; |
| 177 testPreDec(o) => --o; | 201 testPreDec(o) => --o; |
| 178 | 202 |
| 179 testIs(o) => o is Class; | 203 testIs() => null is Class; |
| 180 testIsGeneric(o) => o is GenericClass<int, String>; | 204 testIsGeneric() => null is GenericClass<int, String>; |
| 181 testIsGenericRaw(o) => o is GenericClass; | 205 testIsGenericRaw() => null is GenericClass; |
| 182 testIsGenericDynamic(o) => o is GenericClass<dynamic, dynamic>; | 206 testIsGenericDynamic() => null is GenericClass<dynamic, dynamic>; |
| 183 testIsNot(o) => o is! Class; | 207 testIsNot() => null is! Class; |
| 184 testIsNotGeneric(o) => o is! GenericClass<int, String>; | 208 testIsNotGeneric() => null is! GenericClass<int, String>; |
| 185 testIsNotGenericRaw(o) => o is! GenericClass; | 209 testIsNotGenericRaw() => null is! GenericClass; |
| 186 testIsNotGenericDynamic(o) => o is! GenericClass<dynamic, dynamic>; | 210 testIsNotGenericDynamic() => null is! GenericClass<dynamic, dynamic>; |
| 187 testIsTypedef(o) => o is Typedef; | 211 testIsTypedef() => null is Typedef; |
| 188 testIsTypedefGeneric(o) => o is GenericTypedef<int, String>; | 212 testIsTypedefGeneric() => null is GenericTypedef<int, String>; |
| 189 testIsTypedefGenericRaw(o) => o is GenericTypedef; | 213 testIsTypedefGenericRaw() => null is GenericTypedef; |
| 190 testIsTypedefGenericDynamic(o) => o is GenericTypedef<dynamic, dynamic>; | 214 testIsTypedefGenericDynamic() => null is GenericTypedef<dynamic, dynamic>; |
| 191 testAs(o) => o as Class; | 215 testIsTypedefDeep() => null is List<GenericTypedef<int, GenericTypedef>>; |
| 192 testAsGeneric(o) => o as GenericClass<int, String>; | 216 testAs() => null as Class; |
| 193 testAsGenericRaw(o) => o as GenericClass; | 217 testAsGeneric() => null as GenericClass<int, String>; |
| 194 testAsGenericDynamic(o) => o as GenericClass<dynamic, dynamic>; | 218 testAsGenericRaw() => null as GenericClass; |
| 219 testAsGenericDynamic() => null as GenericClass<dynamic, dynamic>; |
| 195 testThrow() => throw ''; | 220 testThrow() => throw ''; |
| 221 testIfNotNull(o) => o?.foo; |
| 222 testIfNotNullSet(o) => o?.foo = 42; |
| 196 testIfNull(o) => o ?? 42; | 223 testIfNull(o) => o ?? 42; |
| 197 testSetIfNull(o) => o ??= 42; | 224 testSetIfNull(o) => o ??= 42; |
| 198 | 225 |
| 199 testSyncStar() sync* {} | 226 testSyncStar() sync* {} |
| 200 testAsync() async {} | 227 testAsync() async {} |
| 201 testAsyncStar() async* {} | 228 testAsyncStar() async* {} |
| 202 testIfThen() { | 229 testIfThen() { |
| 203 if (false) return 42; | 230 if (false) return 42; |
| 204 return 1; | 231 return 1; |
| 205 } | 232 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 testSwitchWithoutFallthrough(o) { | 264 testSwitchWithoutFallthrough(o) { |
| 238 switch (o) { | 265 switch (o) { |
| 239 case 0: | 266 case 0: |
| 240 case 1: | 267 case 1: |
| 241 o = 2; | 268 o = 2; |
| 242 break; | 269 break; |
| 243 case 2: | 270 case 2: |
| 244 o = 3; | 271 o = 3; |
| 245 return; | 272 return; |
| 246 case 3: | 273 case 3: |
| 274 throw ''; |
| 275 case 4: |
| 247 default: | 276 default: |
| 248 } | 277 } |
| 249 } | 278 } |
| 250 testSwitchWithFallthrough(o) { | 279 testSwitchWithFallthrough(o) { |
| 251 switch (o) { | 280 switch (o) { |
| 252 case 0: | 281 case 0: |
| 253 case 1: | 282 case 1: |
| 254 o = 2; | 283 o = 2; |
| 255 case 2: | 284 case 2: |
| 256 o = 3; | 285 o = 3; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 testTopLevelFieldFinal() => topLevelFieldFinal; | 349 testTopLevelFieldFinal() => topLevelFieldFinal; |
| 321 int topLevelFieldTyped; | 350 int topLevelFieldTyped; |
| 322 testTopLevelFieldTyped() => topLevelFieldTyped; | 351 testTopLevelFieldTyped() => topLevelFieldTyped; |
| 323 GenericClass topLevelFieldGeneric1; | 352 GenericClass topLevelFieldGeneric1; |
| 324 testTopLevelFieldGeneric1() => topLevelFieldGeneric1; | 353 testTopLevelFieldGeneric1() => topLevelFieldGeneric1; |
| 325 GenericClass<dynamic, dynamic> topLevelFieldGeneric2; | 354 GenericClass<dynamic, dynamic> topLevelFieldGeneric2; |
| 326 testTopLevelFieldGeneric2() => topLevelFieldGeneric2; | 355 testTopLevelFieldGeneric2() => topLevelFieldGeneric2; |
| 327 GenericClass<int, String> topLevelFieldGeneric3; | 356 GenericClass<int, String> topLevelFieldGeneric3; |
| 328 testTopLevelFieldGeneric3() => topLevelFieldGeneric3; | 357 testTopLevelFieldGeneric3() => topLevelFieldGeneric3; |
| 329 testTopLevelFieldWrite() => topLevelField = 3; | 358 testTopLevelFieldWrite() => topLevelField = 3; |
| 359 class StaticFunctionGetClass { |
| 360 static foo() {} |
| 361 } |
| 362 testStaticFunctionGet() => StaticFunctionGetClass.foo; |
| 363 |
| 330 testDynamicInvoke(o) { | 364 testDynamicInvoke(o) { |
| 331 o.f1(0); | 365 o.f1(0); |
| 332 o.f2(1); | 366 o.f2(1); |
| 333 o.f3(2, 3); | 367 o.f3(2, 3); |
| 334 o.f4(4, 5, 6); | 368 o.f4(4, 5, 6); |
| 335 o.f5(7); | 369 o.f5(7); |
| 336 o.f6(8, b: 9); | 370 o.f6(8, b: 9); |
| 337 o.f7(10, c: 11); | 371 o.f7(10, c: 11); |
| 338 o.f8(12, b: 13, c: 14); | 372 o.f8(12, b: 13, c: 14); |
| 339 o.f9(15, c: 16, b: 17); | 373 o.f9(15, c: 16, b: 17); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 const GenericClass<dynamic, dynamic>.redirect(); | 460 const GenericClass<dynamic, dynamic>.redirect(); |
| 427 } | 461 } |
| 428 class ClassImplicitConstructor {} | 462 class ClassImplicitConstructor {} |
| 429 testImplicitConstructor() => new ClassImplicitConstructor(); | 463 testImplicitConstructor() => new ClassImplicitConstructor(); |
| 430 class ClassFactoryConstructor { | 464 class ClassFactoryConstructor { |
| 431 factory ClassFactoryConstructor() => null; | 465 factory ClassFactoryConstructor() => null; |
| 432 } | 466 } |
| 433 testFactoryConstructor() => new ClassFactoryConstructor(); | 467 testFactoryConstructor() => new ClassFactoryConstructor(); |
| 434 testDefaultValuesPositional([bool value = false]) {} | 468 testDefaultValuesPositional([bool value = false]) {} |
| 435 testDefaultValuesNamed({bool value: false}) {} | 469 testDefaultValuesNamed({bool value: false}) {} |
| 470 |
| 471 class ClassFieldInitializer1 { |
| 472 var field; |
| 473 ClassFieldInitializer1(this.field); |
| 474 } |
| 475 testFieldInitializer1() => new ClassFieldInitializer1(42); |
| 476 class ClassFieldInitializer2 { |
| 477 var field; |
| 478 ClassFieldInitializer2(value) : field = value; |
| 479 } |
| 480 testFieldInitializer2() => new ClassFieldInitializer2(42); |
| 481 class ClassInstanceFieldWithInitializer { |
| 482 var field = false; |
| 483 } |
| 484 testInstanceFieldWithInitializer() => new ClassInstanceFieldWithInitializer(); |
| 485 class ClassInstanceFieldTyped { |
| 486 int field; |
| 487 } |
| 488 testInstanceFieldTyped() => new ClassInstanceFieldTyped(); |
| 489 class ClassGeneric<T> { |
| 490 ClassGeneric(T arg); |
| 491 } |
| 492 class ClassThisInitializer { |
| 493 ClassThisInitializer() : this.internal(); |
| 494 ClassThisInitializer.internal(); |
| 495 } |
| 496 testThisInitializer() => new ClassThisInitializer(); |
| 497 class ClassSuperInitializer extends ClassThisInitializer { |
| 498 ClassSuperInitializer() : super.internal(); |
| 499 } |
| 500 testSuperInitializer() => new ClassSuperInitializer(); |
| 501 testGenericClass() => new ClassGeneric<int>(0); |
| 502 class Super1 { |
| 503 foo() {} |
| 504 } |
| 505 class Sub1 extends Super1 { |
| 506 Sub1() { |
| 507 super.foo(); |
| 508 } |
| 509 } |
| 510 testSuperCall() => new Sub1(); |
| 511 class Super2 { |
| 512 var foo; |
| 513 } |
| 514 class Sub2 extends Super2 { |
| 515 Sub2() { |
| 516 super.foo; |
| 517 } |
| 518 } |
| 519 testSuperGet() => new Sub2(); |
| 520 class Super3 { |
| 521 var foo; |
| 522 } |
| 523 class Sub3 extends Super3 { |
| 524 Sub3() { |
| 525 super.foo = 42; |
| 526 } |
| 527 } |
| 528 testSuperFieldSet() => new Sub3(); |
| 529 class Super4 { |
| 530 set foo(_) {} |
| 531 } |
| 532 class Sub4 extends Super4 { |
| 533 Sub4() { |
| 534 super.foo = 42; |
| 535 } |
| 536 } |
| 537 testSuperSetterSet() => new Sub4(); |
| 538 class Super5 { |
| 539 foo() {} |
| 540 } |
| 541 class Sub5 extends Super5 { |
| 542 Sub5() { |
| 543 super.foo; |
| 544 } |
| 545 } |
| 546 testSuperClosurization() => new Sub5(); |
| 547 |
| 548 class EmptyMixin {} |
| 549 class ForwardingConstructorSuperClass { |
| 550 ForwardingConstructorSuperClass(arg); |
| 551 } |
| 552 class ForwardingConstructorClass = |
| 553 ForwardingConstructorSuperClass with EmptyMixin; |
| 554 testForwardingConstructor() => new ForwardingConstructorClass(null); |
| 555 |
| 556 class ForwardingConstructorTypedSuperClass { |
| 557 ForwardingConstructorTypedSuperClass(int arg); |
| 558 } |
| 559 class ForwardingConstructorTypedClass = |
| 560 ForwardingConstructorTypedSuperClass with EmptyMixin; |
| 561 testForwardingConstructorTyped() => new ForwardingConstructorTypedClass(null); |
| 562 |
| 563 class ForwardingConstructorGenericSuperClass<T> { |
| 564 ForwardingConstructorGenericSuperClass(T arg); |
| 565 } |
| 566 class ForwardingConstructorGenericClass<S> = |
| 567 ForwardingConstructorGenericSuperClass<S> with EmptyMixin; |
| 568 testForwardingConstructorGeneric() { |
| 569 new ForwardingConstructorGenericClass<int>(null); |
| 570 } |
| 571 |
| 572 enum Enum { A } |
| 573 testEnum() => Enum.A; |
| 436 ''', | 574 ''', |
| 437 'helper.dart': ''' | 575 'helper.dart': ''' |
| 438 class Class { | 576 class Class { |
| 439 const Class.generative(); | 577 const Class.generative(); |
| 440 factory Class.fact() => null; | 578 factory Class.fact() => null; |
| 441 const factory Class.redirect() = Class.generative; | 579 const factory Class.redirect() = Class.generative; |
| 442 } | 580 } |
| 443 class GenericClass<X, Y> { | 581 class GenericClass<X, Y> { |
| 444 const GenericClass.generative(); | 582 const GenericClass.generative(); |
| 445 factory GenericClass.fact() => null; | 583 factory GenericClass.fact() => null; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 ResolutionWorldImpactBuilder builder = | 637 ResolutionWorldImpactBuilder builder = |
| 500 new ResolutionWorldImpactBuilder('Lax impact of ${element}'); | 638 new ResolutionWorldImpactBuilder('Lax impact of ${element}'); |
| 501 for (StaticUse staticUse in impact.staticUses) { | 639 for (StaticUse staticUse in impact.staticUses) { |
| 502 switch (staticUse.kind) { | 640 switch (staticUse.kind) { |
| 503 case StaticUseKind.CONST_CONSTRUCTOR_INVOKE: | 641 case StaticUseKind.CONST_CONSTRUCTOR_INVOKE: |
| 504 ConstructorElement constructor = staticUse.element; | 642 ConstructorElement constructor = staticUse.element; |
| 505 ConstructorElement effectiveTarget = constructor.effectiveTarget; | 643 ConstructorElement effectiveTarget = constructor.effectiveTarget; |
| 506 DartType effectiveTargetType = | 644 DartType effectiveTargetType = |
| 507 constructor.computeEffectiveTargetType(staticUse.type); | 645 constructor.computeEffectiveTargetType(staticUse.type); |
| 508 builder.registerStaticUse(new StaticUse.constConstructorInvoke( | 646 builder.registerStaticUse(new StaticUse.constConstructorInvoke( |
| 509 effectiveTarget, null, effectiveTargetType)); | 647 effectiveTarget.declaration, null, effectiveTargetType)); |
| 510 break; | 648 break; |
| 511 default: | 649 default: |
| 512 builder.registerStaticUse(staticUse); | 650 builder.registerStaticUse(staticUse); |
| 513 break; | 651 break; |
| 514 } | 652 } |
| 515 } | 653 } |
| 516 impact.dynamicUses.forEach(builder.registerDynamicUse); | 654 impact.dynamicUses.forEach(builder.registerDynamicUse); |
| 517 for (TypeUse typeUse in impact.typeUses) { | 655 for (TypeUse typeUse in impact.typeUses) { |
| 518 if (typeUse.type.isTypedef) { | 656 builder.registerTypeUse(new TypeUse.internal( |
| 519 typeUse = new TypeUse.internal(typeUse.type.unaliased, typeUse.kind); | 657 const Unaliaser().visit(typeUse.type), typeUse.kind)); |
| 520 } | |
| 521 builder.registerTypeUse(typeUse); | |
| 522 } | 658 } |
| 523 impact.constantLiterals.forEach(builder.registerConstantLiteral); | 659 impact.constantLiterals.forEach(builder.registerConstantLiteral); |
| 524 impact.constSymbolNames.forEach(builder.registerConstSymbolName); | 660 impact.constSymbolNames.forEach(builder.registerConstSymbolName); |
| 525 impact.listLiterals.forEach(builder.registerListLiteral); | 661 impact.listLiterals.forEach(builder.registerListLiteral); |
| 526 impact.mapLiterals.forEach(builder.registerMapLiteral); | 662 impact.mapLiterals.forEach(builder.registerMapLiteral); |
| 527 for (Feature feature in impact.features) { | 663 for (Feature feature in impact.features) { |
| 528 switch (feature) { | 664 switch (feature) { |
| 529 case Feature.STRING_INTERPOLATION: | 665 case Feature.STRING_INTERPOLATION: |
| 530 case Feature.STRING_JUXTAPOSITION: | 666 case Feature.STRING_JUXTAPOSITION: |
| 531 // These are both converted into a string concatenation in kernel so | 667 // These are both converted into a string concatenation in kernel so |
| (...skipping 12 matching lines...) Expand all Loading... |
| 544 builder.registerFeature(Feature.THROW_EXPRESSION); | 680 builder.registerFeature(Feature.THROW_EXPRESSION); |
| 545 break; | 681 break; |
| 546 default: | 682 default: |
| 547 builder.registerFeature(feature); | 683 builder.registerFeature(feature); |
| 548 break; | 684 break; |
| 549 } | 685 } |
| 550 } | 686 } |
| 551 impact.nativeData.forEach(builder.registerNativeData); | 687 impact.nativeData.forEach(builder.registerNativeData); |
| 552 return builder; | 688 return builder; |
| 553 } | 689 } |
| 690 |
| 691 /// Visitor the performers unaliasing of all typedefs nested within a |
| 692 /// [DartType]. |
| 693 class Unaliaser extends BaseDartTypeVisitor<dynamic, DartType> { |
| 694 const Unaliaser(); |
| 695 |
| 696 @override |
| 697 DartType visit(DartType type, [_]) => type.accept(this, null); |
| 698 |
| 699 @override |
| 700 DartType visitType(DartType type, _) => type; |
| 701 |
| 702 List<DartType> visitList(List<DartType> types) => types.map(visit).toList(); |
| 703 |
| 704 @override |
| 705 DartType visitInterfaceType(InterfaceType type, _) { |
| 706 return type.createInstantiation(visitList(type.typeArguments)); |
| 707 } |
| 708 |
| 709 @override |
| 710 DartType visitTypedefType(TypedefType type, _) { |
| 711 return visit(type.unaliased); |
| 712 } |
| 713 |
| 714 @override |
| 715 DartType visitFunctionType(FunctionType type, _) { |
| 716 return new FunctionType.synthesized( |
| 717 visit(type.returnType), |
| 718 visitList(type.parameterTypes), |
| 719 visitList(type.optionalParameterTypes), |
| 720 type.namedParameters, |
| 721 visitList(type.namedParameterTypes)); |
| 722 } |
| 723 } |
| OLD | NEW |