| 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(); | |
| 44 testEmptyListLiteral(); | 42 testEmptyListLiteral(); |
| 45 testEmptyListLiteralDynamic(); | 43 testEmptyListLiteralDynamic(); |
| 46 testEmptyListLiteralTyped(); | 44 testEmptyListLiteralTyped(); |
| 47 testEmptyListLiteralConstant(); | 45 testEmptyListLiteralConstant(); |
| 48 testNonEmptyListLiteral(); | 46 testNonEmptyListLiteral(); |
| 49 testEmptyMapLiteral(); | 47 testEmptyMapLiteral(); |
| 50 testEmptyMapLiteralDynamic(); | 48 testEmptyMapLiteralDynamic(); |
| 51 testEmptyMapLiteralTyped(); | 49 testEmptyMapLiteralTyped(); |
| 52 testEmptyMapLiteralConstant(); | 50 testEmptyMapLiteralConstant(); |
| 53 testNonEmptyMapLiteral(); | 51 testNonEmptyMapLiteral(); |
| 54 testNot(); | 52 testNot(); |
| 55 testUnaryMinus(); | 53 testUnaryMinus(); |
| 56 testConditional(); | 54 testConditional(); |
| 57 testPostInc(null); | 55 testPostInc(null); |
| 58 testPostDec(null); | 56 testPostDec(null); |
| 59 testPreInc(null); | 57 testPreInc(null); |
| 60 testPreDec(null); | 58 testPreDec(null); |
| 61 testIs(); | 59 testIs(null); |
| 62 testIsGeneric(); | 60 testIsGeneric(null); |
| 63 testIsGenericRaw(); | 61 testIsGenericRaw(null); |
| 64 testIsGenericDynamic(); | 62 testIsGenericDynamic(null); |
| 65 testIsNot(); | 63 testIsNot(null); |
| 66 testIsNotGeneric(); | 64 testIsNotGeneric(null); |
| 67 testIsNotGenericRaw(); | 65 testIsNotGenericRaw(null); |
| 68 testIsNotGenericDynamic(); | 66 testIsNotGenericDynamic(null); |
| 69 testIsTypedef(); | 67 testIsTypedef(null); |
| 70 testIsTypedefGeneric(); | 68 testIsTypedefGeneric(null); |
| 71 testIsTypedefGenericRaw(); | 69 testIsTypedefGenericRaw(null); |
| 72 testIsTypedefGenericDynamic(); | 70 testIsTypedefGenericDynamic(null); |
| 73 testIsTypedefDeep(); | 71 testAs(null); |
| 74 testAs(); | 72 testAsGeneric(null); |
| 75 testAsGeneric(); | 73 testAsGenericRaw(null); |
| 76 testAsGenericRaw(); | 74 testAsGenericDynamic(null); |
| 77 testAsGenericDynamic(); | |
| 78 testThrow(); | 75 testThrow(); |
| 79 testIfNotNull(null); | |
| 80 testIfNotNullSet(null); | |
| 81 testIfNull(null); | 76 testIfNull(null); |
| 82 testSetIfNull(null); | 77 testSetIfNull(null); |
| 83 testSyncStar(); | 78 testSyncStar(); |
| 84 testAsync(); | 79 testAsync(); |
| 85 testAsyncStar(); | 80 testAsyncStar(); |
| 86 testIfThen(); | 81 testIfThen(); |
| 87 testIfThenElse(); | 82 testIfThenElse(); |
| 88 testForIn(null); | 83 testForIn(null); |
| 89 testForInTyped(null); | 84 testForInTyped(null); |
| 90 testAsyncForIn(null); | 85 testAsyncForIn(null); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 105 testTopLevelSetterSetTyped(); | 100 testTopLevelSetterSetTyped(); |
| 106 testTopLevelField(); | 101 testTopLevelField(); |
| 107 testTopLevelFieldLazy(); | 102 testTopLevelFieldLazy(); |
| 108 testTopLevelFieldConst(); | 103 testTopLevelFieldConst(); |
| 109 testTopLevelFieldFinal(); | 104 testTopLevelFieldFinal(); |
| 110 testTopLevelFieldTyped(); | 105 testTopLevelFieldTyped(); |
| 111 testTopLevelFieldGeneric1(); | 106 testTopLevelFieldGeneric1(); |
| 112 testTopLevelFieldGeneric2(); | 107 testTopLevelFieldGeneric2(); |
| 113 testTopLevelFieldGeneric3(); | 108 testTopLevelFieldGeneric3(); |
| 114 testTopLevelFieldWrite(); | 109 testTopLevelFieldWrite(); |
| 115 testStaticFunctionGet(); | |
| 116 testDynamicInvoke(null); | 110 testDynamicInvoke(null); |
| 117 testDynamicGet(null); | 111 testDynamicGet(null); |
| 118 testDynamicSet(null); | 112 testDynamicSet(null); |
| 119 testLocalWithoutInitializer(); | 113 testLocalWithoutInitializer(); |
| 120 testLocalWithInitializer(); | 114 testLocalWithInitializer(); |
| 121 testLocalWithInitializerTyped(); | 115 testLocalWithInitializerTyped(); |
| 122 testLocalFunction(); | 116 testLocalFunction(); |
| 123 testLocalFunctionTyped(); | 117 testLocalFunctionTyped(); |
| 124 testLocalFunctionInvoke(); | 118 testLocalFunctionInvoke(); |
| 125 testLocalFunctionGet(); | 119 testLocalFunctionGet(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 142 testRedirectingFactoryInvokeGenericRaw(); | 136 testRedirectingFactoryInvokeGenericRaw(); |
| 143 testRedirectingFactoryInvokeGenericDynamic(); | 137 testRedirectingFactoryInvokeGenericDynamic(); |
| 144 testConstRedirectingFactoryInvoke(); | 138 testConstRedirectingFactoryInvoke(); |
| 145 testConstRedirectingFactoryInvokeGeneric(); | 139 testConstRedirectingFactoryInvokeGeneric(); |
| 146 testConstRedirectingFactoryInvokeGenericRaw(); | 140 testConstRedirectingFactoryInvokeGenericRaw(); |
| 147 testConstRedirectingFactoryInvokeGenericDynamic(); | 141 testConstRedirectingFactoryInvokeGenericDynamic(); |
| 148 testImplicitConstructor(); | 142 testImplicitConstructor(); |
| 149 testFactoryConstructor(); | 143 testFactoryConstructor(); |
| 150 testDefaultValuesPositional(); | 144 testDefaultValuesPositional(); |
| 151 testDefaultValuesNamed(); | 145 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(); | |
| 168 } | 146 } |
| 169 | 147 |
| 170 testEmpty() {} | 148 testEmpty() {} |
| 171 testNull() => null; | 149 testNull() => null; |
| 172 testTrue() => true; | 150 testTrue() => true; |
| 173 testFalse() => false; | 151 testFalse() => false; |
| 174 testInt() => 42; | 152 testInt() => 42; |
| 175 testDouble() => 37.5; | 153 testDouble() => 37.5; |
| 176 testString() => 'foo'; | 154 testString() => 'foo'; |
| 177 testStringInterpolation() => '${0}'; | 155 testStringInterpolation() => '${0}'; |
| 178 testStringInterpolationConst() { | 156 testStringInterpolationConst() { |
| 179 const b = '${0}'; | 157 const b = '${0}'; |
| 180 } | 158 } |
| 181 testStringJuxtaposition() => 'a' 'b'; | 159 testStringJuxtaposition() => 'a' 'b'; |
| 182 testSymbol() => #main; | 160 testSymbol() => #main; |
| 183 testTypeLiteral() => Object; | |
| 184 testBoolFromEnvironment() => const bool.fromEnvironment('FOO'); | |
| 185 testEmptyListLiteral() => []; | 161 testEmptyListLiteral() => []; |
| 186 testEmptyListLiteralDynamic() => <dynamic>[]; | 162 testEmptyListLiteralDynamic() => <dynamic>[]; |
| 187 testEmptyListLiteralTyped() => <String>[]; | 163 testEmptyListLiteralTyped() => <String>[]; |
| 188 testEmptyListLiteralConstant() => const []; | 164 testEmptyListLiteralConstant() => const []; |
| 189 testNonEmptyListLiteral() => [0]; | 165 testNonEmptyListLiteral() => [0]; |
| 190 testEmptyMapLiteral() => {}; | 166 testEmptyMapLiteral() => {}; |
| 191 testEmptyMapLiteralDynamic() => <dynamic, dynamic>{}; | 167 testEmptyMapLiteralDynamic() => <dynamic, dynamic>{}; |
| 192 testEmptyMapLiteralTyped() => <String, int>{}; | 168 testEmptyMapLiteralTyped() => <String, int>{}; |
| 193 testEmptyMapLiteralConstant() => const {}; | 169 testEmptyMapLiteralConstant() => const {}; |
| 194 testNonEmptyMapLiteral() => {0: true}; | 170 testNonEmptyMapLiteral() => {0: true}; |
| 195 testNot() => !false; | 171 testNot() => !false; |
| 196 testUnaryMinus() => -1; | 172 testUnaryMinus() => -1; |
| 197 testConditional() => true ? 1 : ''; | 173 testConditional() => true ? 1 : ''; |
| 198 testPostInc(o) => o++; | 174 testPostInc(o) => o++; |
| 199 testPostDec(o) => o--; | 175 testPostDec(o) => o--; |
| 200 testPreInc(o) => ++o; | 176 testPreInc(o) => ++o; |
| 201 testPreDec(o) => --o; | 177 testPreDec(o) => --o; |
| 202 | 178 |
| 203 testIs() => null is Class; | 179 testIs(o) => o is Class; |
| 204 testIsGeneric() => null is GenericClass<int, String>; | 180 testIsGeneric(o) => o is GenericClass<int, String>; |
| 205 testIsGenericRaw() => null is GenericClass; | 181 testIsGenericRaw(o) => o is GenericClass; |
| 206 testIsGenericDynamic() => null is GenericClass<dynamic, dynamic>; | 182 testIsGenericDynamic(o) => o is GenericClass<dynamic, dynamic>; |
| 207 testIsNot() => null is! Class; | 183 testIsNot(o) => o is! Class; |
| 208 testIsNotGeneric() => null is! GenericClass<int, String>; | 184 testIsNotGeneric(o) => o is! GenericClass<int, String>; |
| 209 testIsNotGenericRaw() => null is! GenericClass; | 185 testIsNotGenericRaw(o) => o is! GenericClass; |
| 210 testIsNotGenericDynamic() => null is! GenericClass<dynamic, dynamic>; | 186 testIsNotGenericDynamic(o) => o is! GenericClass<dynamic, dynamic>; |
| 211 testIsTypedef() => null is Typedef; | 187 testIsTypedef(o) => o is Typedef; |
| 212 testIsTypedefGeneric() => null is GenericTypedef<int, String>; | 188 testIsTypedefGeneric(o) => o is GenericTypedef<int, String>; |
| 213 testIsTypedefGenericRaw() => null is GenericTypedef; | 189 testIsTypedefGenericRaw(o) => o is GenericTypedef; |
| 214 testIsTypedefGenericDynamic() => null is GenericTypedef<dynamic, dynamic>; | 190 testIsTypedefGenericDynamic(o) => o is GenericTypedef<dynamic, dynamic>; |
| 215 testIsTypedefDeep() => null is List<GenericTypedef<int, GenericTypedef>>; | 191 testAs(o) => o as Class; |
| 216 testAs() => null as Class; | 192 testAsGeneric(o) => o as GenericClass<int, String>; |
| 217 testAsGeneric() => null as GenericClass<int, String>; | 193 testAsGenericRaw(o) => o as GenericClass; |
| 218 testAsGenericRaw() => null as GenericClass; | 194 testAsGenericDynamic(o) => o as GenericClass<dynamic, dynamic>; |
| 219 testAsGenericDynamic() => null as GenericClass<dynamic, dynamic>; | |
| 220 testThrow() => throw ''; | 195 testThrow() => throw ''; |
| 221 testIfNotNull(o) => o?.foo; | |
| 222 testIfNotNullSet(o) => o?.foo = 42; | |
| 223 testIfNull(o) => o ?? 42; | 196 testIfNull(o) => o ?? 42; |
| 224 testSetIfNull(o) => o ??= 42; | 197 testSetIfNull(o) => o ??= 42; |
| 225 | 198 |
| 226 testSyncStar() sync* {} | 199 testSyncStar() sync* {} |
| 227 testAsync() async {} | 200 testAsync() async {} |
| 228 testAsyncStar() async* {} | 201 testAsyncStar() async* {} |
| 229 testIfThen() { | 202 testIfThen() { |
| 230 if (false) return 42; | 203 if (false) return 42; |
| 231 return 1; | 204 return 1; |
| 232 } | 205 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 testSwitchWithoutFallthrough(o) { | 237 testSwitchWithoutFallthrough(o) { |
| 265 switch (o) { | 238 switch (o) { |
| 266 case 0: | 239 case 0: |
| 267 case 1: | 240 case 1: |
| 268 o = 2; | 241 o = 2; |
| 269 break; | 242 break; |
| 270 case 2: | 243 case 2: |
| 271 o = 3; | 244 o = 3; |
| 272 return; | 245 return; |
| 273 case 3: | 246 case 3: |
| 274 throw ''; | |
| 275 case 4: | |
| 276 default: | 247 default: |
| 277 } | 248 } |
| 278 } | 249 } |
| 279 testSwitchWithFallthrough(o) { | 250 testSwitchWithFallthrough(o) { |
| 280 switch (o) { | 251 switch (o) { |
| 281 case 0: | 252 case 0: |
| 282 case 1: | 253 case 1: |
| 283 o = 2; | 254 o = 2; |
| 284 case 2: | 255 case 2: |
| 285 o = 3; | 256 o = 3; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 testTopLevelFieldFinal() => topLevelFieldFinal; | 320 testTopLevelFieldFinal() => topLevelFieldFinal; |
| 350 int topLevelFieldTyped; | 321 int topLevelFieldTyped; |
| 351 testTopLevelFieldTyped() => topLevelFieldTyped; | 322 testTopLevelFieldTyped() => topLevelFieldTyped; |
| 352 GenericClass topLevelFieldGeneric1; | 323 GenericClass topLevelFieldGeneric1; |
| 353 testTopLevelFieldGeneric1() => topLevelFieldGeneric1; | 324 testTopLevelFieldGeneric1() => topLevelFieldGeneric1; |
| 354 GenericClass<dynamic, dynamic> topLevelFieldGeneric2; | 325 GenericClass<dynamic, dynamic> topLevelFieldGeneric2; |
| 355 testTopLevelFieldGeneric2() => topLevelFieldGeneric2; | 326 testTopLevelFieldGeneric2() => topLevelFieldGeneric2; |
| 356 GenericClass<int, String> topLevelFieldGeneric3; | 327 GenericClass<int, String> topLevelFieldGeneric3; |
| 357 testTopLevelFieldGeneric3() => topLevelFieldGeneric3; | 328 testTopLevelFieldGeneric3() => topLevelFieldGeneric3; |
| 358 testTopLevelFieldWrite() => topLevelField = 3; | 329 testTopLevelFieldWrite() => topLevelField = 3; |
| 359 class StaticFunctionGetClass { | |
| 360 static foo() {} | |
| 361 } | |
| 362 testStaticFunctionGet() => StaticFunctionGetClass.foo; | |
| 363 | |
| 364 testDynamicInvoke(o) { | 330 testDynamicInvoke(o) { |
| 365 o.f1(0); | 331 o.f1(0); |
| 366 o.f2(1); | 332 o.f2(1); |
| 367 o.f3(2, 3); | 333 o.f3(2, 3); |
| 368 o.f4(4, 5, 6); | 334 o.f4(4, 5, 6); |
| 369 o.f5(7); | 335 o.f5(7); |
| 370 o.f6(8, b: 9); | 336 o.f6(8, b: 9); |
| 371 o.f7(10, c: 11); | 337 o.f7(10, c: 11); |
| 372 o.f8(12, b: 13, c: 14); | 338 o.f8(12, b: 13, c: 14); |
| 373 o.f9(15, c: 16, b: 17); | 339 o.f9(15, c: 16, b: 17); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 const GenericClass<dynamic, dynamic>.redirect(); | 426 const GenericClass<dynamic, dynamic>.redirect(); |
| 461 } | 427 } |
| 462 class ClassImplicitConstructor {} | 428 class ClassImplicitConstructor {} |
| 463 testImplicitConstructor() => new ClassImplicitConstructor(); | 429 testImplicitConstructor() => new ClassImplicitConstructor(); |
| 464 class ClassFactoryConstructor { | 430 class ClassFactoryConstructor { |
| 465 factory ClassFactoryConstructor() => null; | 431 factory ClassFactoryConstructor() => null; |
| 466 } | 432 } |
| 467 testFactoryConstructor() => new ClassFactoryConstructor(); | 433 testFactoryConstructor() => new ClassFactoryConstructor(); |
| 468 testDefaultValuesPositional([bool value = false]) {} | 434 testDefaultValuesPositional([bool value = false]) {} |
| 469 testDefaultValuesNamed({bool value: false}) {} | 435 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; | |
| 574 ''', | 436 ''', |
| 575 'helper.dart': ''' | 437 'helper.dart': ''' |
| 576 class Class { | 438 class Class { |
| 577 const Class.generative(); | 439 const Class.generative(); |
| 578 factory Class.fact() => null; | 440 factory Class.fact() => null; |
| 579 const factory Class.redirect() = Class.generative; | 441 const factory Class.redirect() = Class.generative; |
| 580 } | 442 } |
| 581 class GenericClass<X, Y> { | 443 class GenericClass<X, Y> { |
| 582 const GenericClass.generative(); | 444 const GenericClass.generative(); |
| 583 factory GenericClass.fact() => null; | 445 factory GenericClass.fact() => null; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 595 Compiler compiler = compilerFor( | 457 Compiler compiler = compilerFor( |
| 596 entryPoint: entryPoint, | 458 entryPoint: entryPoint, |
| 597 memorySourceFiles: SOURCE, | 459 memorySourceFiles: SOURCE, |
| 598 options: [ | 460 options: [ |
| 599 Flags.analyzeAll, | 461 Flags.analyzeAll, |
| 600 Flags.useKernel, | 462 Flags.useKernel, |
| 601 Flags.enableAssertMessage | 463 Flags.enableAssertMessage |
| 602 ]); | 464 ]); |
| 603 compiler.resolution.retainCachesForTesting = true; | 465 compiler.resolution.retainCachesForTesting = true; |
| 604 await compiler.run(entryPoint); | 466 await compiler.run(entryPoint); |
| 605 compiler.libraryLoader.libraries.forEach((LibraryElement library) { | 467 checkLibrary(compiler, compiler.mainApp); |
| 606 checkLibrary(compiler, library); | |
| 607 }); | |
| 608 }); | 468 }); |
| 609 } | 469 } |
| 610 | 470 |
| 611 void checkLibrary(Compiler compiler, LibraryElement library) { | 471 void checkLibrary(Compiler compiler, LibraryElement library) { |
| 612 library.forEachLocalMember((AstElement element) { | 472 library.forEachLocalMember((AstElement element) { |
| 613 if (element.isClass) { | 473 if (element.isClass) { |
| 614 ClassElement cls = element; | 474 ClassElement cls = element; |
| 615 cls.forEachLocalMember((AstElement member) { | 475 cls.forEachLocalMember((AstElement member) { |
| 616 checkElement(compiler, member); | 476 checkElement(compiler, member); |
| 617 }); | 477 }); |
| 618 } else if (element.isTypedef) { | 478 } else if (element.isTypedef) { |
| 619 // Skip typedefs. | 479 // Skip typedefs. |
| 620 } else { | 480 } else { |
| 621 checkElement(compiler, element); | 481 checkElement(compiler, element); |
| 622 } | 482 } |
| 623 }); | 483 }); |
| 624 } | 484 } |
| 625 | 485 |
| 626 void checkElement(Compiler compiler, AstElement element) { | 486 void checkElement(Compiler compiler, AstElement element) { |
| 627 if (compiler.backend.isNative(element)) { | |
| 628 // Skip native functions for now; kernel does not provide their | |
| 629 // signature which we need to derive their native behavior. | |
| 630 return; | |
| 631 } | |
| 632 if (element.isConstructor) { | |
| 633 ConstructorElement constructor = element; | |
| 634 if (constructor.isRedirectingFactory) { | |
| 635 // Skip redirecting constructors for now; they might not be supported. | |
| 636 return; | |
| 637 } | |
| 638 } | |
| 639 ResolutionImpact astImpact = compiler.resolution.getResolutionImpact(element); | 487 ResolutionImpact astImpact = compiler.resolution.getResolutionImpact(element); |
| 640 astImpact = laxImpact(compiler, element, astImpact); | 488 astImpact = laxImpact(compiler, element, astImpact); |
| 641 ResolutionImpact kernelImpact = build(compiler, element.resolvedAst); | 489 ResolutionImpact kernelImpact = build(compiler, element.resolvedAst); |
| 642 Expect.isNotNull(kernelImpact, 'No impact computed for $element'); | 490 Expect.isNotNull(kernelImpact, 'No impact computed for $element'); |
| 643 testResolutionImpactEquivalence( | 491 testResolutionImpactEquivalence( |
| 644 astImpact, kernelImpact, const CheckStrategy()); | 492 astImpact, kernelImpact, const CheckStrategy()); |
| 645 } | 493 } |
| 646 | 494 |
| 647 /// Lax the precision of [impact] to meet expectancy of the corresponding impact | 495 /// Lax the precision of [impact] to meet expectancy of the corresponding impact |
| 648 /// generated from kernel. | 496 /// generated from kernel. |
| 649 ResolutionImpact laxImpact( | 497 ResolutionImpact laxImpact( |
| 650 Compiler compiler, AstElement element, ResolutionImpact impact) { | 498 Compiler compiler, AstElement element, ResolutionImpact impact) { |
| 651 ResolutionWorldImpactBuilder builder = | 499 ResolutionWorldImpactBuilder builder = |
| 652 new ResolutionWorldImpactBuilder('Lax impact of ${element}'); | 500 new ResolutionWorldImpactBuilder('Lax impact of ${element}'); |
| 653 for (StaticUse staticUse in impact.staticUses) { | 501 for (StaticUse staticUse in impact.staticUses) { |
| 654 switch (staticUse.kind) { | 502 switch (staticUse.kind) { |
| 655 case StaticUseKind.CONST_CONSTRUCTOR_INVOKE: | 503 case StaticUseKind.CONST_CONSTRUCTOR_INVOKE: |
| 656 ConstructorElement constructor = staticUse.element; | 504 ConstructorElement constructor = staticUse.element; |
| 657 ConstructorElement effectiveTarget = constructor.effectiveTarget; | 505 ConstructorElement effectiveTarget = constructor.effectiveTarget; |
| 658 DartType effectiveTargetType = | 506 DartType effectiveTargetType = |
| 659 constructor.computeEffectiveTargetType(staticUse.type); | 507 constructor.computeEffectiveTargetType(staticUse.type); |
| 660 builder.registerStaticUse(new StaticUse.constConstructorInvoke( | 508 builder.registerStaticUse(new StaticUse.constConstructorInvoke( |
| 661 effectiveTarget.declaration, null, effectiveTargetType)); | 509 effectiveTarget, null, effectiveTargetType)); |
| 662 break; | 510 break; |
| 663 default: | 511 default: |
| 664 builder.registerStaticUse(staticUse); | 512 builder.registerStaticUse(staticUse); |
| 665 break; | 513 break; |
| 666 } | 514 } |
| 667 } | 515 } |
| 668 impact.dynamicUses.forEach(builder.registerDynamicUse); | 516 impact.dynamicUses.forEach(builder.registerDynamicUse); |
| 669 for (TypeUse typeUse in impact.typeUses) { | 517 for (TypeUse typeUse in impact.typeUses) { |
| 670 builder.registerTypeUse(new TypeUse.internal( | 518 if (typeUse.type.isTypedef) { |
| 671 const Unaliaser().visit(typeUse.type), typeUse.kind)); | 519 typeUse = new TypeUse.internal(typeUse.type.unaliased, typeUse.kind); |
| 520 } |
| 521 builder.registerTypeUse(typeUse); |
| 672 } | 522 } |
| 673 impact.constantLiterals.forEach(builder.registerConstantLiteral); | 523 impact.constantLiterals.forEach(builder.registerConstantLiteral); |
| 674 impact.constSymbolNames.forEach(builder.registerConstSymbolName); | 524 impact.constSymbolNames.forEach(builder.registerConstSymbolName); |
| 675 impact.listLiterals.forEach(builder.registerListLiteral); | 525 impact.listLiterals.forEach(builder.registerListLiteral); |
| 676 impact.mapLiterals.forEach(builder.registerMapLiteral); | 526 impact.mapLiterals.forEach(builder.registerMapLiteral); |
| 677 for (Feature feature in impact.features) { | 527 for (Feature feature in impact.features) { |
| 678 switch (feature) { | 528 switch (feature) { |
| 679 case Feature.STRING_INTERPOLATION: | 529 case Feature.STRING_INTERPOLATION: |
| 680 case Feature.STRING_JUXTAPOSITION: | 530 case Feature.STRING_JUXTAPOSITION: |
| 681 // These are both converted into a string concatenation in kernel so | 531 // These are both converted into a string concatenation in kernel so |
| (...skipping 12 matching lines...) Expand all Loading... |
| 694 builder.registerFeature(Feature.THROW_EXPRESSION); | 544 builder.registerFeature(Feature.THROW_EXPRESSION); |
| 695 break; | 545 break; |
| 696 default: | 546 default: |
| 697 builder.registerFeature(feature); | 547 builder.registerFeature(feature); |
| 698 break; | 548 break; |
| 699 } | 549 } |
| 700 } | 550 } |
| 701 impact.nativeData.forEach(builder.registerNativeData); | 551 impact.nativeData.forEach(builder.registerNativeData); |
| 702 return builder; | 552 return builder; |
| 703 } | 553 } |
| 704 | |
| 705 /// Visitor the performers unaliasing of all typedefs nested within a | |
| 706 /// [DartType]. | |
| 707 class Unaliaser extends BaseDartTypeVisitor<dynamic, DartType> { | |
| 708 const Unaliaser(); | |
| 709 | |
| 710 @override | |
| 711 DartType visit(DartType type, [_]) => type.accept(this, null); | |
| 712 | |
| 713 @override | |
| 714 DartType visitType(DartType type, _) => type; | |
| 715 | |
| 716 List<DartType> visitList(List<DartType> types) => types.map(visit).toList(); | |
| 717 | |
| 718 @override | |
| 719 DartType visitInterfaceType(InterfaceType type, _) { | |
| 720 return type.createInstantiation(visitList(type.typeArguments)); | |
| 721 } | |
| 722 | |
| 723 @override | |
| 724 DartType visitTypedefType(TypedefType type, _) { | |
| 725 return visit(type.unaliased); | |
| 726 } | |
| 727 | |
| 728 @override | |
| 729 DartType visitFunctionType(FunctionType type, _) { | |
| 730 return new FunctionType.synthesized( | |
| 731 visit(type.returnType), | |
| 732 visitList(type.parameterTypes), | |
| 733 visitList(type.optionalParameterTypes), | |
| 734 type.namedParameters, | |
| 735 visitList(type.namedParameterTypes)); | |
| 736 } | |
| 737 } | |
| OLD | NEW |