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

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

Issue 2210293002: infer null from context, this avoids bottom being introduced (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 4 months 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 analyzer.test.src.task.dart_test; 5 library analyzer.test.src.task.dart_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/token.dart'; 8 import 'package:analyzer/dart/ast/token.dart';
9 import 'package:analyzer/dart/ast/visitor.dart'; 9 import 'package:analyzer/dart/ast/visitor.dart';
10 import 'package:analyzer/dart/element/element.dart'; 10 import 'package:analyzer/dart/element/element.dart';
(...skipping 5403 matching lines...) Expand 10 before | Expand all | Expand 10 after
5414 '''); 5414 ''');
5415 computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT12); 5415 computeResult(new LibrarySpecificUnit(source, source), RESOLVED_UNIT12);
5416 CompilationUnit unit = outputs[RESOLVED_UNIT12]; 5416 CompilationUnit unit = outputs[RESOLVED_UNIT12];
5417 5417
5418 InterfaceType intType = context.typeProvider.intType; 5418 InterfaceType intType = context.typeProvider.intType;
5419 InterfaceType stringType = context.typeProvider.stringType; 5419 InterfaceType stringType = context.typeProvider.stringType;
5420 DartType bottomType = context.typeProvider.bottomType; 5420 DartType bottomType = context.typeProvider.bottomType;
5421 DartType dynamicType = context.typeProvider.dynamicType; 5421 DartType dynamicType = context.typeProvider.dynamicType;
5422 5422
5423 assertVariableDeclarationTypes( 5423 assertVariableDeclarationTypes(
5424 AstFinder.getTopLevelVariable(unit, "x"), dynamicType, bottomType); 5424 AstFinder.getTopLevelVariable(unit, "x"), dynamicType, dynamicType);
5425 assertVariableDeclarationTypes( 5425 assertVariableDeclarationTypes(
5426 AstFinder.getTopLevelVariable(unit, "y"), intType, intType); 5426 AstFinder.getTopLevelVariable(unit, "y"), intType, intType);
5427 assertVariableDeclarationTypes( 5427 assertVariableDeclarationTypes(
5428 AstFinder.getFieldInClass(unit, "A", "x"), dynamicType, bottomType); 5428 AstFinder.getFieldInClass(unit, "A", "x"), dynamicType, dynamicType);
5429 assertVariableDeclarationTypes( 5429 assertVariableDeclarationTypes(
5430 AstFinder.getFieldInClass(unit, "A", "y"), intType, intType); 5430 AstFinder.getFieldInClass(unit, "A", "y"), intType, intType);
5431 assertVariableDeclarationTypes( 5431 assertVariableDeclarationTypes(
5432 AstFinder.getFieldInClass(unit, "A", "x2"), dynamicType, bottomType); 5432 AstFinder.getFieldInClass(unit, "A", "x2"), dynamicType, dynamicType);
5433 assertVariableDeclarationTypes( 5433 assertVariableDeclarationTypes(
5434 AstFinder.getFieldInClass(unit, "A", "y2"), intType, intType); 5434 AstFinder.getFieldInClass(unit, "A", "y2"), intType, intType);
5435 5435
5436 List<Statement> statements = 5436 List<Statement> statements =
5437 AstFinder.getStatementsInTopLevelFunction(unit, "test"); 5437 AstFinder.getStatementsInTopLevelFunction(unit, "test");
5438 5438
5439 assertAssignmentStatementTypes(statements[0], dynamicType, stringType); 5439 assertAssignmentStatementTypes(statements[0], dynamicType, stringType);
5440 assertAssignmentStatementTypes(statements[1], intType, stringType); 5440 assertAssignmentStatementTypes(statements[1], intType, stringType);
5441 assertAssignmentStatementTypes(statements[2], dynamicType, stringType); 5441 assertAssignmentStatementTypes(statements[2], dynamicType, stringType);
5442 assertAssignmentStatementTypes(statements[3], intType, stringType); 5442 assertAssignmentStatementTypes(statements[3], intType, stringType);
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
5799 /** 5799 /**
5800 * Fill [errorListener] with [result] errors in the current [task]. 5800 * Fill [errorListener] with [result] errors in the current [task].
5801 */ 5801 */
5802 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) { 5802 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) {
5803 List<AnalysisError> errors = task.outputs[result] as List<AnalysisError>; 5803 List<AnalysisError> errors = task.outputs[result] as List<AnalysisError>;
5804 expect(errors, isNotNull, reason: result.name); 5804 expect(errors, isNotNull, reason: result.name);
5805 errorListener = new GatheringErrorListener(); 5805 errorListener = new GatheringErrorListener();
5806 errorListener.addAll(errors); 5806 errorListener.addAll(errors);
5807 } 5807 }
5808 } 5808 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698