| 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 analyzer.test.generated.strong_mode_test; | 5 library analyzer.test.generated.strong_mode_test; |
| 6 | 6 |
| 7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
| 8 import 'package:analyzer/dart/ast/resolution_accessors.dart'; |
| 8 import 'package:analyzer/dart/element/element.dart'; | 9 import 'package:analyzer/dart/element/element.dart'; |
| 9 import 'package:analyzer/dart/element/type.dart'; | 10 import 'package:analyzer/dart/element/type.dart'; |
| 10 import 'package:analyzer/src/dart/element/element.dart'; | 11 import 'package:analyzer/src/dart/element/element.dart'; |
| 11 import 'package:analyzer/src/error/codes.dart'; | 12 import 'package:analyzer/src/error/codes.dart'; |
| 12 import 'package:analyzer/src/generated/engine.dart'; | 13 import 'package:analyzer/src/generated/engine.dart'; |
| 13 import 'package:analyzer/src/generated/source_io.dart'; | 14 import 'package:analyzer/src/generated/source_io.dart'; |
| 14 import 'package:test/test.dart'; | 15 import 'package:test/test.dart'; |
| 15 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 16 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| 16 | 17 |
| 17 import '../utils.dart'; | 18 import '../utils.dart'; |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 '''; | 301 '''; |
| 301 CompilationUnit unit = resolveSource(code); | 302 CompilationUnit unit = resolveSource(code); |
| 302 | 303 |
| 303 ConstructorDeclaration constructor = | 304 ConstructorDeclaration constructor = |
| 304 AstFinder.getConstructorInClass(unit, "A", null); | 305 AstFinder.getConstructorInClass(unit, "A", null); |
| 305 BlockFunctionBody body = constructor.body; | 306 BlockFunctionBody body = constructor.body; |
| 306 ReturnStatement stmt = body.block.statements[0]; | 307 ReturnStatement stmt = body.block.statements[0]; |
| 307 InstanceCreationExpression exp = stmt.expression; | 308 InstanceCreationExpression exp = stmt.expression; |
| 308 ClassElement elementB = AstFinder.getClass(unit, "B").element; | 309 ClassElement elementB = AstFinder.getClass(unit, "B").element; |
| 309 ClassElement elementA = AstFinder.getClass(unit, "A").element; | 310 ClassElement elementA = AstFinder.getClass(unit, "A").element; |
| 310 expect(exp.constructorName.type.type.element, elementB); | 311 expect(typeForTypeName(exp.constructorName.type).element, elementB); |
| 311 _isInstantiationOf(_hasElement(elementB))( | 312 _isInstantiationOf(_hasElement(elementB))( |
| 312 [_isType(elementA.typeParameters[0].type)])(exp.staticType); | 313 [_isType(elementA.typeParameters[0].type)])(exp.staticType); |
| 313 } | 314 } |
| 314 | 315 |
| 315 void test_fieldDeclaration_propagation() { | 316 void test_fieldDeclaration_propagation() { |
| 316 String code = r''' | 317 String code = r''' |
| 317 class A { | 318 class A { |
| 318 List<String> f0 = ["hello"]; | 319 List<String> f0 = ["hello"]; |
| 319 } | 320 } |
| 320 '''; | 321 '''; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 FunctionDeclaration inner = | 353 FunctionDeclaration inner = |
| 353 (statements[0] as FunctionDeclarationStatement).functionDeclaration; | 354 (statements[0] as FunctionDeclarationStatement).functionDeclaration; |
| 354 BlockFunctionBody body0 = inner.functionExpression.body; | 355 BlockFunctionBody body0 = inner.functionExpression.body; |
| 355 ReturnStatement return0 = body0.block.statements[0]; | 356 ReturnStatement return0 = body0.block.statements[0]; |
| 356 Expression anon0 = return0.expression; | 357 Expression anon0 = return0.expression; |
| 357 FunctionType type0 = anon0.staticType; | 358 FunctionType type0 = anon0.staticType; |
| 358 expect(type0.returnType, typeProvider.intType); | 359 expect(type0.returnType, typeProvider.intType); |
| 359 expect(type0.normalParameterTypes[0], typeProvider.stringType); | 360 expect(type0.normalParameterTypes[0], typeProvider.stringType); |
| 360 | 361 |
| 361 FunctionExpression anon1 = (statements[1] as ReturnStatement).expression; | 362 FunctionExpression anon1 = (statements[1] as ReturnStatement).expression; |
| 362 FunctionType type1 = anon1.element.type; | 363 FunctionType type1 = elementForFunctionExpression(anon1).type; |
| 363 expect(type1.returnType, typeProvider.intType); | 364 expect(type1.returnType, typeProvider.intType); |
| 364 expect(type1.normalParameterTypes[0], typeProvider.intType); | 365 expect(type1.normalParameterTypes[0], typeProvider.intType); |
| 365 } | 366 } |
| 366 | 367 |
| 367 void test_functionLiteral_assignment_typedArguments() { | 368 void test_functionLiteral_assignment_typedArguments() { |
| 368 String code = r''' | 369 String code = r''' |
| 369 typedef T Function2<S, T>(S x); | 370 typedef T Function2<S, T>(S x); |
| 370 | 371 |
| 371 void main () { | 372 void main () { |
| 372 Function2<int, String> l0 = (int x) => null; | 373 Function2<int, String> l0 = (int x) => null; |
| 373 Function2<int, String> l1 = (int x) => "hello"; | 374 Function2<int, String> l1 = (int x) => "hello"; |
| 374 Function2<int, String> l2 = (String x) => "hello"; | 375 Function2<int, String> l2 = (String x) => "hello"; |
| 375 Function2<int, String> l3 = (int x) => 3; | 376 Function2<int, String> l3 = (int x) => 3; |
| 376 Function2<int, String> l4 = (int x) {return 3;}; | 377 Function2<int, String> l4 = (int x) {return 3;}; |
| 377 } | 378 } |
| 378 '''; | 379 '''; |
| 379 CompilationUnit unit = resolveSource(code); | 380 CompilationUnit unit = resolveSource(code); |
| 380 List<Statement> statements = | 381 List<Statement> statements = |
| 381 AstFinder.getStatementsInTopLevelFunction(unit, "main"); | 382 AstFinder.getStatementsInTopLevelFunction(unit, "main"); |
| 382 DartType literal(int i) { | 383 DartType literal(int i) { |
| 383 VariableDeclarationStatement stmt = statements[i]; | 384 VariableDeclarationStatement stmt = statements[i]; |
| 384 VariableDeclaration decl = stmt.variables.variables[0]; | 385 VariableDeclaration decl = stmt.variables.variables[0]; |
| 385 FunctionExpression exp = decl.initializer; | 386 FunctionExpression exp = decl.initializer; |
| 386 return exp.element.type; | 387 return elementForFunctionExpression(exp).type; |
| 387 } | 388 } |
| 388 | 389 |
| 389 _isFunction2Of(_isInt, _isString)(literal(0)); | 390 _isFunction2Of(_isInt, _isString)(literal(0)); |
| 390 _isFunction2Of(_isInt, _isString)(literal(1)); | 391 _isFunction2Of(_isInt, _isString)(literal(1)); |
| 391 _isFunction2Of(_isString, _isString)(literal(2)); | 392 _isFunction2Of(_isString, _isString)(literal(2)); |
| 392 _isFunction2Of(_isInt, _isInt)(literal(3)); | 393 _isFunction2Of(_isInt, _isInt)(literal(3)); |
| 393 _isFunction2Of(_isInt, _isString)(literal(4)); | 394 _isFunction2Of(_isInt, _isString)(literal(4)); |
| 394 } | 395 } |
| 395 | 396 |
| 396 void test_functionLiteral_assignment_unTypedArguments() { | 397 void test_functionLiteral_assignment_unTypedArguments() { |
| 397 String code = r''' | 398 String code = r''' |
| 398 typedef T Function2<S, T>(S x); | 399 typedef T Function2<S, T>(S x); |
| 399 | 400 |
| 400 void main () { | 401 void main () { |
| 401 Function2<int, String> l0 = (x) => null; | 402 Function2<int, String> l0 = (x) => null; |
| 402 Function2<int, String> l1 = (x) => "hello"; | 403 Function2<int, String> l1 = (x) => "hello"; |
| 403 Function2<int, String> l2 = (x) => "hello"; | 404 Function2<int, String> l2 = (x) => "hello"; |
| 404 Function2<int, String> l3 = (x) => 3; | 405 Function2<int, String> l3 = (x) => 3; |
| 405 Function2<int, String> l4 = (x) {return 3;}; | 406 Function2<int, String> l4 = (x) {return 3;}; |
| 406 } | 407 } |
| 407 '''; | 408 '''; |
| 408 CompilationUnit unit = resolveSource(code); | 409 CompilationUnit unit = resolveSource(code); |
| 409 List<Statement> statements = | 410 List<Statement> statements = |
| 410 AstFinder.getStatementsInTopLevelFunction(unit, "main"); | 411 AstFinder.getStatementsInTopLevelFunction(unit, "main"); |
| 411 DartType literal(int i) { | 412 DartType literal(int i) { |
| 412 VariableDeclarationStatement stmt = statements[i]; | 413 VariableDeclarationStatement stmt = statements[i]; |
| 413 VariableDeclaration decl = stmt.variables.variables[0]; | 414 VariableDeclaration decl = stmt.variables.variables[0]; |
| 414 FunctionExpression exp = decl.initializer; | 415 FunctionExpression exp = decl.initializer; |
| 415 return exp.element.type; | 416 return elementForFunctionExpression(exp).type; |
| 416 } | 417 } |
| 417 | 418 |
| 418 _isFunction2Of(_isInt, _isString)(literal(0)); | 419 _isFunction2Of(_isInt, _isString)(literal(0)); |
| 419 _isFunction2Of(_isInt, _isString)(literal(1)); | 420 _isFunction2Of(_isInt, _isString)(literal(1)); |
| 420 _isFunction2Of(_isInt, _isString)(literal(2)); | 421 _isFunction2Of(_isInt, _isString)(literal(2)); |
| 421 _isFunction2Of(_isInt, _isInt)(literal(3)); | 422 _isFunction2Of(_isInt, _isInt)(literal(3)); |
| 422 _isFunction2Of(_isInt, _isString)(literal(4)); | 423 _isFunction2Of(_isInt, _isString)(literal(4)); |
| 423 } | 424 } |
| 424 | 425 |
| 425 void test_functionLiteral_body_propagation() { | 426 void test_functionLiteral_body_propagation() { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 (new Mapper<int, String>().map)((int x) {return 3;}); | 471 (new Mapper<int, String>().map)((int x) {return 3;}); |
| 471 } | 472 } |
| 472 '''; | 473 '''; |
| 473 CompilationUnit unit = resolveSource(code); | 474 CompilationUnit unit = resolveSource(code); |
| 474 List<Statement> statements = | 475 List<Statement> statements = |
| 475 AstFinder.getStatementsInTopLevelFunction(unit, "main"); | 476 AstFinder.getStatementsInTopLevelFunction(unit, "main"); |
| 476 DartType literal(int i) { | 477 DartType literal(int i) { |
| 477 ExpressionStatement stmt = statements[i]; | 478 ExpressionStatement stmt = statements[i]; |
| 478 FunctionExpressionInvocation invk = stmt.expression; | 479 FunctionExpressionInvocation invk = stmt.expression; |
| 479 FunctionExpression exp = invk.argumentList.arguments[0]; | 480 FunctionExpression exp = invk.argumentList.arguments[0]; |
| 480 return exp.element.type; | 481 return elementForFunctionExpression(exp).type; |
| 481 } | 482 } |
| 482 | 483 |
| 483 _isFunction2Of(_isInt, _isString)(literal(0)); | 484 _isFunction2Of(_isInt, _isString)(literal(0)); |
| 484 _isFunction2Of(_isInt, _isString)(literal(1)); | 485 _isFunction2Of(_isInt, _isString)(literal(1)); |
| 485 _isFunction2Of(_isString, _isString)(literal(2)); | 486 _isFunction2Of(_isString, _isString)(literal(2)); |
| 486 _isFunction2Of(_isInt, _isInt)(literal(3)); | 487 _isFunction2Of(_isInt, _isInt)(literal(3)); |
| 487 _isFunction2Of(_isInt, _isString)(literal(4)); | 488 _isFunction2Of(_isInt, _isString)(literal(4)); |
| 488 } | 489 } |
| 489 | 490 |
| 490 void test_functionLiteral_functionExpressionInvocation_unTypedArguments() { | 491 void test_functionLiteral_functionExpressionInvocation_unTypedArguments() { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 501 (new Mapper<int, String>().map)((x) {return 3;}); | 502 (new Mapper<int, String>().map)((x) {return 3;}); |
| 502 } | 503 } |
| 503 '''; | 504 '''; |
| 504 CompilationUnit unit = resolveSource(code); | 505 CompilationUnit unit = resolveSource(code); |
| 505 List<Statement> statements = | 506 List<Statement> statements = |
| 506 AstFinder.getStatementsInTopLevelFunction(unit, "main"); | 507 AstFinder.getStatementsInTopLevelFunction(unit, "main"); |
| 507 DartType literal(int i) { | 508 DartType literal(int i) { |
| 508 ExpressionStatement stmt = statements[i]; | 509 ExpressionStatement stmt = statements[i]; |
| 509 FunctionExpressionInvocation invk = stmt.expression; | 510 FunctionExpressionInvocation invk = stmt.expression; |
| 510 FunctionExpression exp = invk.argumentList.arguments[0]; | 511 FunctionExpression exp = invk.argumentList.arguments[0]; |
| 511 return exp.element.type; | 512 return elementForFunctionExpression(exp).type; |
| 512 } | 513 } |
| 513 | 514 |
| 514 _isFunction2Of(_isInt, _isString)(literal(0)); | 515 _isFunction2Of(_isInt, _isString)(literal(0)); |
| 515 _isFunction2Of(_isInt, _isString)(literal(1)); | 516 _isFunction2Of(_isInt, _isString)(literal(1)); |
| 516 _isFunction2Of(_isInt, _isString)(literal(2)); | 517 _isFunction2Of(_isInt, _isString)(literal(2)); |
| 517 _isFunction2Of(_isInt, _isInt)(literal(3)); | 518 _isFunction2Of(_isInt, _isInt)(literal(3)); |
| 518 _isFunction2Of(_isInt, _isString)(literal(4)); | 519 _isFunction2Of(_isInt, _isString)(literal(4)); |
| 519 } | 520 } |
| 520 | 521 |
| 521 void test_functionLiteral_functionInvocation_typedArguments() { | 522 void test_functionLiteral_functionInvocation_typedArguments() { |
| 522 String code = r''' | 523 String code = r''' |
| 523 String map(String mapper(int x)) => mapper(null); | 524 String map(String mapper(int x)) => mapper(null); |
| 524 | 525 |
| 525 void main () { | 526 void main () { |
| 526 map((int x) => null); | 527 map((int x) => null); |
| 527 map((int x) => "hello"); | 528 map((int x) => "hello"); |
| 528 map((String x) => "hello"); | 529 map((String x) => "hello"); |
| 529 map((int x) => 3); | 530 map((int x) => 3); |
| 530 map((int x) {return 3;}); | 531 map((int x) {return 3;}); |
| 531 } | 532 } |
| 532 '''; | 533 '''; |
| 533 CompilationUnit unit = resolveSource(code); | 534 CompilationUnit unit = resolveSource(code); |
| 534 List<Statement> statements = | 535 List<Statement> statements = |
| 535 AstFinder.getStatementsInTopLevelFunction(unit, "main"); | 536 AstFinder.getStatementsInTopLevelFunction(unit, "main"); |
| 536 DartType literal(int i) { | 537 DartType literal(int i) { |
| 537 ExpressionStatement stmt = statements[i]; | 538 ExpressionStatement stmt = statements[i]; |
| 538 MethodInvocation invk = stmt.expression; | 539 MethodInvocation invk = stmt.expression; |
| 539 FunctionExpression exp = invk.argumentList.arguments[0]; | 540 FunctionExpression exp = invk.argumentList.arguments[0]; |
| 540 return exp.element.type; | 541 return elementForFunctionExpression(exp).type; |
| 541 } | 542 } |
| 542 | 543 |
| 543 _isFunction2Of(_isInt, _isString)(literal(0)); | 544 _isFunction2Of(_isInt, _isString)(literal(0)); |
| 544 _isFunction2Of(_isInt, _isString)(literal(1)); | 545 _isFunction2Of(_isInt, _isString)(literal(1)); |
| 545 _isFunction2Of(_isString, _isString)(literal(2)); | 546 _isFunction2Of(_isString, _isString)(literal(2)); |
| 546 _isFunction2Of(_isInt, _isInt)(literal(3)); | 547 _isFunction2Of(_isInt, _isInt)(literal(3)); |
| 547 _isFunction2Of(_isInt, _isString)(literal(4)); | 548 _isFunction2Of(_isInt, _isString)(literal(4)); |
| 548 } | 549 } |
| 549 | 550 |
| 550 void test_functionLiteral_functionInvocation_unTypedArguments() { | 551 void test_functionLiteral_functionInvocation_unTypedArguments() { |
| 551 String code = r''' | 552 String code = r''' |
| 552 String map(String mapper(int x)) => mapper(null); | 553 String map(String mapper(int x)) => mapper(null); |
| 553 | 554 |
| 554 void main () { | 555 void main () { |
| 555 map((x) => null); | 556 map((x) => null); |
| 556 map((x) => "hello"); | 557 map((x) => "hello"); |
| 557 map((x) => "hello"); | 558 map((x) => "hello"); |
| 558 map((x) => 3); | 559 map((x) => 3); |
| 559 map((x) {return 3;}); | 560 map((x) {return 3;}); |
| 560 } | 561 } |
| 561 '''; | 562 '''; |
| 562 CompilationUnit unit = resolveSource(code); | 563 CompilationUnit unit = resolveSource(code); |
| 563 List<Statement> statements = | 564 List<Statement> statements = |
| 564 AstFinder.getStatementsInTopLevelFunction(unit, "main"); | 565 AstFinder.getStatementsInTopLevelFunction(unit, "main"); |
| 565 DartType literal(int i) { | 566 DartType literal(int i) { |
| 566 ExpressionStatement stmt = statements[i]; | 567 ExpressionStatement stmt = statements[i]; |
| 567 MethodInvocation invk = stmt.expression; | 568 MethodInvocation invk = stmt.expression; |
| 568 FunctionExpression exp = invk.argumentList.arguments[0]; | 569 FunctionExpression exp = invk.argumentList.arguments[0]; |
| 569 return exp.element.type; | 570 return elementForFunctionExpression(exp).type; |
| 570 } | 571 } |
| 571 | 572 |
| 572 _isFunction2Of(_isInt, _isString)(literal(0)); | 573 _isFunction2Of(_isInt, _isString)(literal(0)); |
| 573 _isFunction2Of(_isInt, _isString)(literal(1)); | 574 _isFunction2Of(_isInt, _isString)(literal(1)); |
| 574 _isFunction2Of(_isInt, _isString)(literal(2)); | 575 _isFunction2Of(_isInt, _isString)(literal(2)); |
| 575 _isFunction2Of(_isInt, _isInt)(literal(3)); | 576 _isFunction2Of(_isInt, _isInt)(literal(3)); |
| 576 _isFunction2Of(_isInt, _isString)(literal(4)); | 577 _isFunction2Of(_isInt, _isString)(literal(4)); |
| 577 } | 578 } |
| 578 | 579 |
| 579 void test_functionLiteral_methodInvocation_typedArguments() { | 580 void test_functionLiteral_methodInvocation_typedArguments() { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 590 new Mapper<int, String>().map((int x) {return 3;}); | 591 new Mapper<int, String>().map((int x) {return 3;}); |
| 591 } | 592 } |
| 592 '''; | 593 '''; |
| 593 CompilationUnit unit = resolveSource(code); | 594 CompilationUnit unit = resolveSource(code); |
| 594 List<Statement> statements = | 595 List<Statement> statements = |
| 595 AstFinder.getStatementsInTopLevelFunction(unit, "main"); | 596 AstFinder.getStatementsInTopLevelFunction(unit, "main"); |
| 596 DartType literal(int i) { | 597 DartType literal(int i) { |
| 597 ExpressionStatement stmt = statements[i]; | 598 ExpressionStatement stmt = statements[i]; |
| 598 MethodInvocation invk = stmt.expression; | 599 MethodInvocation invk = stmt.expression; |
| 599 FunctionExpression exp = invk.argumentList.arguments[0]; | 600 FunctionExpression exp = invk.argumentList.arguments[0]; |
| 600 return exp.element.type; | 601 return elementForFunctionExpression(exp).type; |
| 601 } | 602 } |
| 602 | 603 |
| 603 _isFunction2Of(_isInt, _isString)(literal(0)); | 604 _isFunction2Of(_isInt, _isString)(literal(0)); |
| 604 _isFunction2Of(_isInt, _isString)(literal(1)); | 605 _isFunction2Of(_isInt, _isString)(literal(1)); |
| 605 _isFunction2Of(_isString, _isString)(literal(2)); | 606 _isFunction2Of(_isString, _isString)(literal(2)); |
| 606 _isFunction2Of(_isInt, _isInt)(literal(3)); | 607 _isFunction2Of(_isInt, _isInt)(literal(3)); |
| 607 _isFunction2Of(_isInt, _isString)(literal(4)); | 608 _isFunction2Of(_isInt, _isString)(literal(4)); |
| 608 } | 609 } |
| 609 | 610 |
| 610 void test_functionLiteral_methodInvocation_unTypedArguments() { | 611 void test_functionLiteral_methodInvocation_unTypedArguments() { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 621 new Mapper<int, String>().map((x) {return 3;}); | 622 new Mapper<int, String>().map((x) {return 3;}); |
| 622 } | 623 } |
| 623 '''; | 624 '''; |
| 624 CompilationUnit unit = resolveSource(code); | 625 CompilationUnit unit = resolveSource(code); |
| 625 List<Statement> statements = | 626 List<Statement> statements = |
| 626 AstFinder.getStatementsInTopLevelFunction(unit, "main"); | 627 AstFinder.getStatementsInTopLevelFunction(unit, "main"); |
| 627 DartType literal(int i) { | 628 DartType literal(int i) { |
| 628 ExpressionStatement stmt = statements[i]; | 629 ExpressionStatement stmt = statements[i]; |
| 629 MethodInvocation invk = stmt.expression; | 630 MethodInvocation invk = stmt.expression; |
| 630 FunctionExpression exp = invk.argumentList.arguments[0]; | 631 FunctionExpression exp = invk.argumentList.arguments[0]; |
| 631 return exp.element.type; | 632 return elementForFunctionExpression(exp).type; |
| 632 } | 633 } |
| 633 | 634 |
| 634 _isFunction2Of(_isInt, _isString)(literal(0)); | 635 _isFunction2Of(_isInt, _isString)(literal(0)); |
| 635 _isFunction2Of(_isInt, _isString)(literal(1)); | 636 _isFunction2Of(_isInt, _isString)(literal(1)); |
| 636 _isFunction2Of(_isInt, _isString)(literal(2)); | 637 _isFunction2Of(_isInt, _isString)(literal(2)); |
| 637 _isFunction2Of(_isInt, _isInt)(literal(3)); | 638 _isFunction2Of(_isInt, _isInt)(literal(3)); |
| 638 _isFunction2Of(_isInt, _isString)(literal(4)); | 639 _isFunction2Of(_isInt, _isString)(literal(4)); |
| 639 } | 640 } |
| 640 | 641 |
| 641 void test_functionLiteral_unTypedArgument_propagation() { | 642 void test_functionLiteral_unTypedArgument_propagation() { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 699 } | 700 } |
| 700 '''; | 701 '''; |
| 701 CompilationUnit unit = resolveSource(code); | 702 CompilationUnit unit = resolveSource(code); |
| 702 | 703 |
| 703 Asserter<InterfaceType> assertListOfInt = _isListOf(_isInt); | 704 Asserter<InterfaceType> assertListOfInt = _isListOf(_isInt); |
| 704 Asserter<InterfaceType> assertMapOfIntToListOfInt = | 705 Asserter<InterfaceType> assertMapOfIntToListOfInt = |
| 705 _isMapOf(_isInt, (DartType type) => assertListOfInt(type)); | 706 _isMapOf(_isInt, (DartType type) => assertListOfInt(type)); |
| 706 | 707 |
| 707 VariableDeclaration mapB = AstFinder.getFieldInClass(unit, "B", "map"); | 708 VariableDeclaration mapB = AstFinder.getFieldInClass(unit, "B", "map"); |
| 708 MethodDeclaration mapC = AstFinder.getMethodInClass(unit, "C", "map"); | 709 MethodDeclaration mapC = AstFinder.getMethodInClass(unit, "C", "map"); |
| 709 assertMapOfIntToListOfInt(mapB.element.type); | 710 assertMapOfIntToListOfInt(elementForVariableDeclaration(mapB).type); |
| 710 assertMapOfIntToListOfInt(mapC.element.returnType); | 711 assertMapOfIntToListOfInt(elementForMethodDeclaration(mapC).returnType); |
| 711 | 712 |
| 712 MapLiteral mapLiteralB = mapB.initializer; | 713 MapLiteral mapLiteralB = mapB.initializer; |
| 713 MapLiteral mapLiteralC = (mapC.body as ExpressionFunctionBody).expression; | 714 MapLiteral mapLiteralC = (mapC.body as ExpressionFunctionBody).expression; |
| 714 assertMapOfIntToListOfInt(mapLiteralB.staticType); | 715 assertMapOfIntToListOfInt(mapLiteralB.staticType); |
| 715 assertMapOfIntToListOfInt(mapLiteralC.staticType); | 716 assertMapOfIntToListOfInt(mapLiteralC.staticType); |
| 716 | 717 |
| 717 ListLiteral listLiteralB = mapLiteralB.entries[0].value; | 718 ListLiteral listLiteralB = mapLiteralB.entries[0].value; |
| 718 ListLiteral listLiteralC = mapLiteralC.entries[0].value; | 719 ListLiteral listLiteralC = mapLiteralC.entries[0].value; |
| 719 assertListOfInt(listLiteralB.staticType); | 720 assertListOfInt(listLiteralB.staticType); |
| 720 assertListOfInt(listLiteralC.staticType); | 721 assertListOfInt(listLiteralC.staticType); |
| (...skipping 1680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2401 main() { | 2402 main() { |
| 2402 var v = x; | 2403 var v = x; |
| 2403 v; // marker | 2404 v; // marker |
| 2404 } | 2405 } |
| 2405 int x = 3; | 2406 int x = 3; |
| 2406 '''; | 2407 '''; |
| 2407 assertPropagatedAssignedType(code, typeProvider.intType, null); | 2408 assertPropagatedAssignedType(code, typeProvider.intType, null); |
| 2408 assertTypeOfMarkedExpression(code, typeProvider.intType, null); | 2409 assertTypeOfMarkedExpression(code, typeProvider.intType, null); |
| 2409 } | 2410 } |
| 2410 } | 2411 } |
| OLD | NEW |