Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(143)

Side by Side Diff: pkg/analyzer/test/src/task/dart_test.dart

Issue 1465303002: Propagate types for import/export closure before resolving. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 test.src.task.dart_test; 5 library test.src.task.dart_test;
6 6
7 import 'package:analyzer/src/context/cache.dart'; 7 import 'package:analyzer/src/context/cache.dart';
8 import 'package:analyzer/src/generated/ast.dart'; 8 import 'package:analyzer/src/generated/ast.dart';
9 import 'package:analyzer/src/generated/constant.dart'; 9 import 'package:analyzer/src/generated/constant.dart';
10 import 'package:analyzer/src/generated/element.dart'; 10 import 'package:analyzer/src/generated/element.dart';
(...skipping 3519 matching lines...) Expand 10 before | Expand all | Expand 10 after
3530 3530
3531 FunctionDeclaration f = unit.declarations[0]; 3531 FunctionDeclaration f = unit.declarations[0];
3532 _assertResolved(f.functionExpression.body); 3532 _assertResolved(f.functionExpression.body);
3533 3533
3534 MethodDeclaration m = (unit.declarations[1] as ClassDeclaration).members[0]; 3534 MethodDeclaration m = (unit.declarations[1] as ClassDeclaration).members[0];
3535 _assertResolved(m.body); 3535 _assertResolved(m.body);
3536 3536
3537 expect(outputs[RESOLVE_UNIT_ERRORS], hasLength(0)); 3537 expect(outputs[RESOLVE_UNIT_ERRORS], hasLength(0));
3538 } 3538 }
3539 3539
3540 void test_perform_ensurePropagatedVariableTypes() {
3541 newSource(
3542 '/lib.dart',
3543 '''
3544 class A {
3545 final v = 1;
3546 }
3547 ''');
3548 AnalysisTarget source = newSource(
3549 '/test.dart',
3550 '''
3551 import 'lib.dart';
3552 main(A a) {
3553 a.v.isEven;
3554 }
3555 ''');
3556 computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT10,
3557 matcher: isResolveUnitTask);
3558 expect(outputs[RESOLVE_UNIT_ERRORS], hasLength(0));
3559 CompilationUnit unit = outputs[RESOLVED_UNIT10];
3560 FunctionDeclaration main = unit.declarations[0];
3561 BlockFunctionBody body = main.functionExpression.body;
3562 ExpressionStatement statement = body.block.statements.single;
3563 Expression expression = statement.expression;
3564 expect(expression.bestType, context.typeProvider.boolType);
3565 }
3566
3540 void _assertResolved(FunctionBody body) { 3567 void _assertResolved(FunctionBody body) {
3541 ResolutionVerifier verifier = new ResolutionVerifier(); 3568 ResolutionVerifier verifier = new ResolutionVerifier();
3542 body.accept(verifier); 3569 body.accept(verifier);
3543 verifier.assertResolved(); 3570 verifier.assertResolved();
3544 } 3571 }
3545 } 3572 }
3546 3573
3547 @reflectiveTest 3574 @reflectiveTest
3548 class ResolveUnitTypeNamesTaskTest extends _AbstractDartTaskTest { 3575 class ResolveUnitTypeNamesTaskTest extends _AbstractDartTaskTest {
3549 test_perform() { 3576 test_perform() {
(...skipping 1043 matching lines...) Expand 10 before | Expand all | Expand 10 after
4593 /** 4620 /**
4594 * Fill [errorListener] with [result] errors in the current [task]. 4621 * Fill [errorListener] with [result] errors in the current [task].
4595 */ 4622 */
4596 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) { 4623 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) {
4597 List<AnalysisError> errors = task.outputs[result]; 4624 List<AnalysisError> errors = task.outputs[result];
4598 expect(errors, isNotNull, reason: result.name); 4625 expect(errors, isNotNull, reason: result.name);
4599 errorListener = new GatheringErrorListener(); 4626 errorListener = new GatheringErrorListener();
4600 errorListener.addAll(errors); 4627 errorListener.addAll(errors);
4601 } 4628 }
4602 } 4629 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/generated/resolver_test.dart ('k') | pkg/analyzer/tool/task_dependency_graph/tasks.dot » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698