| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 'dart:async'; | 5 import 'dart:async'; |
| 6 import 'package:expect/expect.dart'; | 6 import 'package:expect/expect.dart'; |
| 7 import 'package:async_helper/async_helper.dart'; | 7 import 'package:async_helper/async_helper.dart'; |
| 8 import 'package:compiler/src/compiler.dart'; | 8 import 'package:compiler/src/compiler.dart'; |
| 9 import 'package:compiler/src/diagnostics/messages.dart' show | 9 import 'package:compiler/src/diagnostics/messages.dart' show |
| 10 MessageKind; | 10 MessageKind; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 var future; | 38 var future; |
| 39 if (runCompiler) { | 39 if (runCompiler) { |
| 40 future = compiler.runCompiler(null, main); | 40 future = compiler.runCompiler(null, main); |
| 41 } else { | 41 } else { |
| 42 future = compiler.init(main); | 42 future = compiler.init(main); |
| 43 } | 43 } |
| 44 return future.then((_) => compiler); | 44 return future.then((_) => compiler); |
| 45 } | 45 } |
| 46 | 46 |
| 47 void expectHasBody(compiler, ElementX element) { | 47 void expectHasBody(compiler, ElementX element) { |
| 48 var node = element.parseNode(compiler); | 48 var node = element.parseNode(compiler.parsing); |
| 49 Expect.isNotNull(node, "Element isn't parseable, when a body was expected"); | 49 Expect.isNotNull(node, "Element isn't parseable, when a body was expected"); |
| 50 Expect.isNotNull(node.body); | 50 Expect.isNotNull(node.body); |
| 51 // If the element has a body it is either a Block or a Return statement, | 51 // If the element has a body it is either a Block or a Return statement, |
| 52 // both with different begin and end tokens. | 52 // both with different begin and end tokens. |
| 53 Expect.isTrue(node.body is Block || node.body is Return); | 53 Expect.isTrue(node.body is Block || node.body is Return); |
| 54 Expect.notEquals(node.body.getBeginToken(), node.body.getEndToken()); | 54 Expect.notEquals(node.body.getBeginToken(), node.body.getEndToken()); |
| 55 } | 55 } |
| 56 | 56 |
| 57 void expectHasNoBody(compiler, ElementX element) { | 57 void expectHasNoBody(compiler, ElementX element) { |
| 58 var node = element.parseNode(compiler); | 58 var node = element.parseNode(compiler.parsing); |
| 59 Expect.isNotNull(node, "Element isn't parseable, when a body was expected"); | 59 Expect.isNotNull(node, "Element isn't parseable, when a body was expected"); |
| 60 Expect.isFalse(node.hasBody()); | 60 Expect.isFalse(node.hasBody()); |
| 61 } | 61 } |
| 62 | 62 |
| 63 Element ensure(compiler, | 63 Element ensure(compiler, |
| 64 String name, | 64 String name, |
| 65 Element lookup(name), | 65 Element lookup(name), |
| 66 {bool expectIsPatched: false, | 66 {bool expectIsPatched: false, |
| 67 bool expectIsPatch: false, | 67 bool expectIsPatch: false, |
| 68 bool checkHasBody: false, | 68 bool checkHasBody: false, |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 external Class(); | 241 external Class(); |
| 242 } | 242 } |
| 243 """, | 243 """, |
| 244 """ | 244 """ |
| 245 @patch class Class { | 245 @patch class Class { |
| 246 @patch Class(); | 246 @patch Class(); |
| 247 } | 247 } |
| 248 """); | 248 """); |
| 249 var classOrigin = ensure(compiler, "Class", compiler.coreLibrary.find, | 249 var classOrigin = ensure(compiler, "Class", compiler.coreLibrary.find, |
| 250 expectIsPatched: true); | 250 expectIsPatched: true); |
| 251 classOrigin.ensureResolved(compiler); | 251 classOrigin.ensureResolved(compiler.resolution); |
| 252 var classPatch = ensure(compiler, "Class", compiler.coreLibrary.patch.find, | 252 var classPatch = ensure(compiler, "Class", compiler.coreLibrary.patch.find, |
| 253 expectIsPatch: true); | 253 expectIsPatch: true); |
| 254 | 254 |
| 255 Expect.equals(classPatch, classOrigin.patch); | 255 Expect.equals(classPatch, classOrigin.patch); |
| 256 Expect.equals(classOrigin, classPatch.origin); | 256 Expect.equals(classOrigin, classPatch.origin); |
| 257 | 257 |
| 258 var constructorOrigin = ensure(compiler, "", | 258 var constructorOrigin = ensure(compiler, "", |
| 259 (name) => classOrigin.localLookup(name), | 259 (name) => classOrigin.localLookup(name), |
| 260 expectIsPatched: true); | 260 expectIsPatched: true); |
| 261 var constructorPatch = ensure(compiler, "", | 261 var constructorPatch = ensure(compiler, "", |
| (...skipping 18 matching lines...) Expand all Loading... |
| 280 external Class._(x, y); | 280 external Class._(x, y); |
| 281 } | 281 } |
| 282 """, | 282 """, |
| 283 r""" | 283 r""" |
| 284 @patch class Class { | 284 @patch class Class { |
| 285 @patch Class._(x, y) { print('$x,$y'); } | 285 @patch Class._(x, y) { print('$x,$y'); } |
| 286 } | 286 } |
| 287 """); | 287 """); |
| 288 var classOrigin = ensure(compiler, "Class", compiler.coreLibrary.find, | 288 var classOrigin = ensure(compiler, "Class", compiler.coreLibrary.find, |
| 289 expectIsPatched: true); | 289 expectIsPatched: true); |
| 290 classOrigin.ensureResolved(compiler); | 290 classOrigin.ensureResolved(compiler.resolution); |
| 291 | 291 |
| 292 var classPatch = ensure(compiler, "Class", compiler.coreLibrary.patch.find, | 292 var classPatch = ensure(compiler, "Class", compiler.coreLibrary.patch.find, |
| 293 expectIsPatch: true); | 293 expectIsPatch: true); |
| 294 | 294 |
| 295 Expect.equals(classOrigin, classPatch.origin); | 295 Expect.equals(classOrigin, classPatch.origin); |
| 296 Expect.equals(classPatch, classOrigin.patch); | 296 Expect.equals(classPatch, classOrigin.patch); |
| 297 | 297 |
| 298 var constructorRedirecting = | 298 var constructorRedirecting = |
| 299 ensure(compiler, "", | 299 ensure(compiler, "", |
| 300 (name) => classOrigin.localLookup(name)); | 300 (name) => classOrigin.localLookup(name)); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 324 external String toString(); | 324 external String toString(); |
| 325 } | 325 } |
| 326 """, | 326 """, |
| 327 """ | 327 """ |
| 328 @patch class Class { | 328 @patch class Class { |
| 329 @patch String toString() => 'string'; | 329 @patch String toString() => 'string'; |
| 330 } | 330 } |
| 331 """); | 331 """); |
| 332 var container = ensure(compiler, "Class", compiler.coreLibrary.find, | 332 var container = ensure(compiler, "Class", compiler.coreLibrary.find, |
| 333 expectIsPatched: true); | 333 expectIsPatched: true); |
| 334 container.parseNode(compiler); | 334 container.parseNode(compiler.parsing); |
| 335 ensure(compiler, "Class", compiler.coreLibrary.patch.find, | 335 ensure(compiler, "Class", compiler.coreLibrary.patch.find, |
| 336 expectIsPatch: true); | 336 expectIsPatch: true); |
| 337 | 337 |
| 338 ensure(compiler, "toString", container.lookupLocalMember, | 338 ensure(compiler, "toString", container.lookupLocalMember, |
| 339 expectIsPatched: true, checkHasBody: true); | 339 expectIsPatched: true, checkHasBody: true); |
| 340 ensure(compiler, "toString", container.patch.lookupLocalMember, | 340 ensure(compiler, "toString", container.patch.lookupLocalMember, |
| 341 expectIsPatch: true, checkHasBody: true); | 341 expectIsPatch: true, checkHasBody: true); |
| 342 | 342 |
| 343 Expect.isTrue(compiler.warnings.isEmpty, | 343 Expect.isTrue(compiler.warnings.isEmpty, |
| 344 "Unexpected warnings: ${compiler.warnings}"); | 344 "Unexpected warnings: ${compiler.warnings}"); |
| 345 Expect.isTrue(compiler.errors.isEmpty, | 345 Expect.isTrue(compiler.errors.isEmpty, |
| 346 "Unexpected errors: ${compiler.errors}"); | 346 "Unexpected errors: ${compiler.errors}"); |
| 347 } | 347 } |
| 348 | 348 |
| 349 Future testPatchGetter() async { | 349 Future testPatchGetter() async { |
| 350 var compiler = await applyPatch( | 350 var compiler = await applyPatch( |
| 351 """ | 351 """ |
| 352 class Class { | 352 class Class { |
| 353 external int get field; | 353 external int get field; |
| 354 } | 354 } |
| 355 """, | 355 """, |
| 356 """ | 356 """ |
| 357 @patch class Class { | 357 @patch class Class { |
| 358 @patch int get field => 5; | 358 @patch int get field => 5; |
| 359 } | 359 } |
| 360 """); | 360 """); |
| 361 var container = ensure(compiler, "Class", compiler.coreLibrary.find, | 361 var container = ensure(compiler, "Class", compiler.coreLibrary.find, |
| 362 expectIsPatched: true); | 362 expectIsPatched: true); |
| 363 container.parseNode(compiler); | 363 container.parseNode(compiler.parsing); |
| 364 ensure(compiler, | 364 ensure(compiler, |
| 365 "field", | 365 "field", |
| 366 container.lookupLocalMember, | 366 container.lookupLocalMember, |
| 367 expectIsGetter: true, | 367 expectIsGetter: true, |
| 368 expectIsPatched: true, | 368 expectIsPatched: true, |
| 369 checkHasBody: true); | 369 checkHasBody: true); |
| 370 ensure(compiler, | 370 ensure(compiler, |
| 371 "field", | 371 "field", |
| 372 container.patch.lookupLocalMember, | 372 container.patch.lookupLocalMember, |
| 373 expectIsGetter: true, | 373 expectIsGetter: true, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 386 class Class { | 386 class Class { |
| 387 void regular() {} | 387 void regular() {} |
| 388 } | 388 } |
| 389 """, | 389 """, |
| 390 """ | 390 """ |
| 391 @patch class Class { | 391 @patch class Class { |
| 392 } | 392 } |
| 393 """); | 393 """); |
| 394 var container = ensure(compiler, "Class", compiler.coreLibrary.find, | 394 var container = ensure(compiler, "Class", compiler.coreLibrary.find, |
| 395 expectIsPatched: true); | 395 expectIsPatched: true); |
| 396 container.parseNode(compiler); | 396 container.parseNode(compiler.parsing); |
| 397 ensure(compiler, "Class", compiler.coreLibrary.patch.find, | 397 ensure(compiler, "Class", compiler.coreLibrary.patch.find, |
| 398 expectIsPatch: true); | 398 expectIsPatch: true); |
| 399 | 399 |
| 400 ensure(compiler, "regular", container.lookupLocalMember, | 400 ensure(compiler, "regular", container.lookupLocalMember, |
| 401 checkHasBody: true, expectIsRegular: true); | 401 checkHasBody: true, expectIsRegular: true); |
| 402 ensure(compiler, "regular", container.patch.lookupLocalMember, | 402 ensure(compiler, "regular", container.patch.lookupLocalMember, |
| 403 checkHasBody: true, expectIsRegular: true); | 403 checkHasBody: true, expectIsRegular: true); |
| 404 | 404 |
| 405 Expect.isTrue(compiler.warnings.isEmpty, | 405 Expect.isTrue(compiler.warnings.isEmpty, |
| 406 "Unexpected warnings: ${compiler.warnings}"); | 406 "Unexpected warnings: ${compiler.warnings}"); |
| 407 Expect.isTrue(compiler.errors.isEmpty, | 407 Expect.isTrue(compiler.errors.isEmpty, |
| 408 "Unexpected errors: ${compiler.errors}"); | 408 "Unexpected errors: ${compiler.errors}"); |
| 409 } | 409 } |
| 410 | 410 |
| 411 Future testGhostMember() async { | 411 Future testGhostMember() async { |
| 412 var compiler = await applyPatch( | 412 var compiler = await applyPatch( |
| 413 """ | 413 """ |
| 414 class Class { | 414 class Class { |
| 415 } | 415 } |
| 416 """, | 416 """, |
| 417 """ | 417 """ |
| 418 @patch class Class { | 418 @patch class Class { |
| 419 void ghost() {} | 419 void ghost() {} |
| 420 } | 420 } |
| 421 """); | 421 """); |
| 422 var container = ensure(compiler, "Class", compiler.coreLibrary.find, | 422 var container = ensure(compiler, "Class", compiler.coreLibrary.find, |
| 423 expectIsPatched: true); | 423 expectIsPatched: true); |
| 424 container.parseNode(compiler); | 424 container.parseNode(compiler.parsing); |
| 425 ensure(compiler, "Class", compiler.coreLibrary.patch.find, | 425 ensure(compiler, "Class", compiler.coreLibrary.patch.find, |
| 426 expectIsPatch: true); | 426 expectIsPatch: true); |
| 427 | 427 |
| 428 ensure(compiler, "ghost", container.lookupLocalMember, | 428 ensure(compiler, "ghost", container.lookupLocalMember, |
| 429 expectIsFound: false); | 429 expectIsFound: false); |
| 430 ensure(compiler, "ghost", container.patch.lookupLocalMember, | 430 ensure(compiler, "ghost", container.patch.lookupLocalMember, |
| 431 checkHasBody: true, expectIsRegular: true); | 431 checkHasBody: true, expectIsRegular: true); |
| 432 | 432 |
| 433 Expect.isTrue(compiler.warnings.isEmpty, | 433 Expect.isTrue(compiler.warnings.isEmpty, |
| 434 "Unexpected warnings: ${compiler.warnings}"); | 434 "Unexpected warnings: ${compiler.warnings}"); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 @patch void method6([String str]) {} | 482 @patch void method6([String str]) {} |
| 483 @patch void method7([String s2]) {} | 483 @patch void method7([String s2]) {} |
| 484 @patch void method8({String s2}) {} | 484 @patch void method8({String s2}) {} |
| 485 @patch void method9(int str) {} | 485 @patch void method9(int str) {} |
| 486 @patch void method10([int str]) {} | 486 @patch void method10([int str]) {} |
| 487 @patch void method11({int str}) {} | 487 @patch void method11({int str}) {} |
| 488 } | 488 } |
| 489 """); | 489 """); |
| 490 var container = ensure(compiler, "Class", compiler.coreLibrary.find, | 490 var container = ensure(compiler, "Class", compiler.coreLibrary.find, |
| 491 expectIsPatched: true); | 491 expectIsPatched: true); |
| 492 container.ensureResolved(compiler); | 492 container.ensureResolved(compiler.resolution); |
| 493 container.parseNode(compiler); | 493 container.parseNode(compiler.parsing); |
| 494 | 494 |
| 495 void expect(String methodName, List infos, List errors) { | 495 void expect(String methodName, List infos, List errors) { |
| 496 compiler.clearMessages(); | 496 compiler.clearMessages(); |
| 497 compiler.resolver.resolveMethodElement( | 497 compiler.resolver.resolveMethodElement( |
| 498 ensure(compiler, methodName, container.lookupLocalMember, | 498 ensure(compiler, methodName, container.lookupLocalMember, |
| 499 expectIsPatched: true, checkHasBody: true)); | 499 expectIsPatched: true, checkHasBody: true)); |
| 500 Expect.equals(0, compiler.warnings.length); | 500 Expect.equals(0, compiler.warnings.length); |
| 501 Expect.equals(infos.length, compiler.infos.length, | 501 Expect.equals(infos.length, compiler.infos.length, |
| 502 "Unexpected infos: ${compiler.infos} on $methodName"); | 502 "Unexpected infos: ${compiler.infos} on $methodName"); |
| 503 for (int i = 0 ; i < infos.length ; i++) { | 503 for (int i = 0 ; i < infos.length ; i++) { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 external void foo(); | 561 external void foo(); |
| 562 } | 562 } |
| 563 """, | 563 """, |
| 564 """ | 564 """ |
| 565 @patch class Class { | 565 @patch class Class { |
| 566 // @patch void foo() {} | 566 // @patch void foo() {} |
| 567 } | 567 } |
| 568 """); | 568 """); |
| 569 var container = ensure(compiler, "Class", compiler.coreLibrary.find, | 569 var container = ensure(compiler, "Class", compiler.coreLibrary.find, |
| 570 expectIsPatched: true); | 570 expectIsPatched: true); |
| 571 container.parseNode(compiler); | 571 container.parseNode(compiler.parsing); |
| 572 | 572 |
| 573 compiler.warnings.clear(); | 573 compiler.warnings.clear(); |
| 574 compiler.errors.clear(); | 574 compiler.errors.clear(); |
| 575 compiler.resolver.resolveMethodElement( | 575 compiler.resolver.resolveMethodElement( |
| 576 ensure(compiler, "foo", container.lookupLocalMember)); | 576 ensure(compiler, "foo", container.lookupLocalMember)); |
| 577 Expect.isTrue(compiler.warnings.isEmpty, | 577 Expect.isTrue(compiler.warnings.isEmpty, |
| 578 "Unexpected warnings: ${compiler.warnings}"); | 578 "Unexpected warnings: ${compiler.warnings}"); |
| 579 print('testExternalWithoutImplementationMember:${compiler.errors}'); | 579 print('testExternalWithoutImplementationMember:${compiler.errors}'); |
| 580 Expect.equals(1, compiler.errors.length); | 580 Expect.equals(1, compiler.errors.length); |
| 581 Expect.isTrue( | 581 Expect.isTrue( |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 """ | 622 """ |
| 623 class Class {} | 623 class Class {} |
| 624 """, | 624 """, |
| 625 """ | 625 """ |
| 626 @patch class Class { | 626 @patch class Class { |
| 627 @patch void foo() {} | 627 @patch void foo() {} |
| 628 } | 628 } |
| 629 """); | 629 """); |
| 630 var container = ensure(compiler, "Class", compiler.coreLibrary.find, | 630 var container = ensure(compiler, "Class", compiler.coreLibrary.find, |
| 631 expectIsPatched: true); | 631 expectIsPatched: true); |
| 632 container.parseNode(compiler); | 632 container.parseNode(compiler.parsing); |
| 633 | 633 |
| 634 Expect.isTrue(compiler.warnings.isEmpty, | 634 Expect.isTrue(compiler.warnings.isEmpty, |
| 635 "Unexpected warnings: ${compiler.warnings}"); | 635 "Unexpected warnings: ${compiler.warnings}"); |
| 636 print('testPatchNonExistingMember:${compiler.errors}'); | 636 print('testPatchNonExistingMember:${compiler.errors}'); |
| 637 Expect.equals(1, compiler.errors.length); | 637 Expect.equals(1, compiler.errors.length); |
| 638 Expect.isTrue( | 638 Expect.isTrue( |
| 639 compiler.errors[0].message.kind == MessageKind.PATCH_NON_EXISTING); | 639 compiler.errors[0].message.kind == MessageKind.PATCH_NON_EXISTING); |
| 640 } | 640 } |
| 641 | 641 |
| 642 Future testPatchNonPatchablePatch() async { | 642 Future testPatchNonPatchablePatch() async { |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 705 void foo() {} | 705 void foo() {} |
| 706 } | 706 } |
| 707 """, | 707 """, |
| 708 """ | 708 """ |
| 709 @patch class Class { | 709 @patch class Class { |
| 710 @patch void foo() {} | 710 @patch void foo() {} |
| 711 } | 711 } |
| 712 """); | 712 """); |
| 713 var container = ensure(compiler, "Class", compiler.coreLibrary.find, | 713 var container = ensure(compiler, "Class", compiler.coreLibrary.find, |
| 714 expectIsPatched: true); | 714 expectIsPatched: true); |
| 715 container.parseNode(compiler); | 715 container.parseNode(compiler.parsing); |
| 716 | 716 |
| 717 print('testPatchNonExternalMember.errors:${compiler.errors}'); | 717 print('testPatchNonExternalMember.errors:${compiler.errors}'); |
| 718 print('testPatchNonExternalMember.warnings:${compiler.warnings}'); | 718 print('testPatchNonExternalMember.warnings:${compiler.warnings}'); |
| 719 Expect.equals(1, compiler.errors.length); | 719 Expect.equals(1, compiler.errors.length); |
| 720 Expect.isTrue( | 720 Expect.isTrue( |
| 721 compiler.errors[0].message.kind == MessageKind.PATCH_NON_EXTERNAL); | 721 compiler.errors[0].message.kind == MessageKind.PATCH_NON_EXTERNAL); |
| 722 Expect.equals(0, compiler.warnings.length); | 722 Expect.equals(0, compiler.warnings.length); |
| 723 Expect.equals(1, compiler.infos.length); | 723 Expect.equals(1, compiler.infos.length); |
| 724 Expect.isTrue(compiler.infos[0].message.kind == | 724 Expect.isTrue(compiler.infos[0].message.kind == |
| 725 MessageKind.PATCH_POINT_TO_FUNCTION); | 725 MessageKind.PATCH_POINT_TO_FUNCTION); |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 859 main () { | 859 main () { |
| 860 new A(); // ensure A and B are instantiated | 860 new A(); // ensure A and B are instantiated |
| 861 new B(); | 861 new B(); |
| 862 } | 862 } |
| 863 """, | 863 """, |
| 864 runCompiler: true, analyzeOnly: true); | 864 runCompiler: true, analyzeOnly: true); |
| 865 World world = compiler.world; | 865 World world = compiler.world; |
| 866 | 866 |
| 867 ClassElement cls = ensure(compiler, "A", compiler.coreLibrary.find, | 867 ClassElement cls = ensure(compiler, "A", compiler.coreLibrary.find, |
| 868 expectIsPatched: true); | 868 expectIsPatched: true); |
| 869 cls.ensureResolved(compiler); | 869 cls.ensureResolved(compiler.resolution); |
| 870 | 870 |
| 871 ensure(compiler, "method", cls.patch.lookupLocalMember, | 871 ensure(compiler, "method", cls.patch.lookupLocalMember, |
| 872 checkHasBody: true, expectIsRegular: true); | 872 checkHasBody: true, expectIsRegular: true); |
| 873 | 873 |
| 874 ensure(compiler, "clear", cls.lookupLocalMember, | 874 ensure(compiler, "clear", cls.lookupLocalMember, |
| 875 checkHasBody: true, expectIsPatched: true); | 875 checkHasBody: true, expectIsPatched: true); |
| 876 | 876 |
| 877 compiler.phase = Compiler.PHASE_DONE_RESOLVING; | 877 compiler.phase = Compiler.PHASE_DONE_RESOLVING; |
| 878 | 878 |
| 879 // Check that a method just in the patch class is a target for a | 879 // Check that a method just in the patch class is a target for a |
| 880 // typed selector. | 880 // typed selector. |
| 881 Selector selector = | 881 Selector selector = |
| 882 new Selector.call(const PublicName('method'), CallStructure.NO_ARGS); | 882 new Selector.call(const PublicName('method'), CallStructure.NO_ARGS); |
| 883 TypeMask typeMask = new TypeMask.exact(cls, world); | 883 TypeMask typeMask = new TypeMask.exact(cls, world); |
| 884 FunctionElement method = cls.implementation.lookupLocalMember('method'); | 884 FunctionElement method = cls.implementation.lookupLocalMember('method'); |
| 885 method.computeType(compiler); | 885 method.computeType(compiler.resolution); |
| 886 Expect.isTrue(selector.applies(method, world)); | 886 Expect.isTrue(selector.applies(method, world)); |
| 887 Expect.isTrue(typeMask.canHit(method, selector, world)); | 887 Expect.isTrue(typeMask.canHit(method, selector, world)); |
| 888 | 888 |
| 889 // Check that the declaration method in the declaration class is a target | 889 // Check that the declaration method in the declaration class is a target |
| 890 // for a typed selector. | 890 // for a typed selector. |
| 891 selector = | 891 selector = |
| 892 new Selector.call(const PublicName('clear'), CallStructure.NO_ARGS); | 892 new Selector.call(const PublicName('clear'), CallStructure.NO_ARGS); |
| 893 typeMask = new TypeMask.exact(cls, world); | 893 typeMask = new TypeMask.exact(cls, world); |
| 894 method = cls.lookupLocalMember('clear'); | 894 method = cls.lookupLocalMember('clear'); |
| 895 method.computeType(compiler); | 895 method.computeType(compiler.resolution); |
| 896 Expect.isTrue(selector.applies(method, world)); | 896 Expect.isTrue(selector.applies(method, world)); |
| 897 Expect.isTrue(typeMask.canHit(method, selector, world)); | 897 Expect.isTrue(typeMask.canHit(method, selector, world)); |
| 898 | 898 |
| 899 // Check that the declaration method in the declaration class is a target | 899 // Check that the declaration method in the declaration class is a target |
| 900 // for a typed selector on a subclass. | 900 // for a typed selector on a subclass. |
| 901 cls = ensure(compiler, "B", compiler.coreLibrary.find); | 901 cls = ensure(compiler, "B", compiler.coreLibrary.find); |
| 902 cls.ensureResolved(compiler); | 902 cls.ensureResolved(compiler.resolution); |
| 903 typeMask = new TypeMask.exact(cls, world); | 903 typeMask = new TypeMask.exact(cls, world); |
| 904 Expect.isTrue(selector.applies(method, world)); | 904 Expect.isTrue(selector.applies(method, world)); |
| 905 Expect.isTrue(typeMask.canHit(method, selector, world)); | 905 Expect.isTrue(typeMask.canHit(method, selector, world)); |
| 906 } | 906 } |
| 907 | 907 |
| 908 Future testAnalyzeAllInjectedMembers() async { | 908 Future testAnalyzeAllInjectedMembers() async { |
| 909 Future expect(String patchText, [expectedWarnings]) async { | 909 Future expect(String patchText, [expectedWarnings]) async { |
| 910 if (expectedWarnings == null) expectedWarnings = []; | 910 if (expectedWarnings == null) expectedWarnings = []; |
| 911 if (expectedWarnings is! List) { | 911 if (expectedWarnings is! List) { |
| 912 expectedWarnings = <MessageKind>[expectedWarnings]; | 912 expectedWarnings = <MessageKind>[expectedWarnings]; |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1024 await testPatchNonFunction(); | 1024 await testPatchNonFunction(); |
| 1025 | 1025 |
| 1026 await testPatchAndSelector(); | 1026 await testPatchAndSelector(); |
| 1027 | 1027 |
| 1028 await testEffectiveTarget(); /// bug: ok | 1028 await testEffectiveTarget(); /// bug: ok |
| 1029 | 1029 |
| 1030 await testAnalyzeAllInjectedMembers(); | 1030 await testAnalyzeAllInjectedMembers(); |
| 1031 await testTypecheckPatchedMembers(); | 1031 await testTypecheckPatchedMembers(); |
| 1032 }); | 1032 }); |
| 1033 } | 1033 } |
| OLD | NEW |