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

Side by Side Diff: pkg/analyzer/test/generated/resolver_test.dart

Issue 1161343002: Issue 23409. Don't set 'propagatedType' in (vs. after) 'name is Type'. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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
« no previous file with comments | « pkg/analyzer/pubspec.yaml ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 engine.resolver_test; 5 library engine.resolver_test;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analyzer/src/generated/ast.dart'; 9 import 'package:analyzer/src/generated/ast.dart';
10 import 'package:analyzer/src/generated/element.dart'; 10 import 'package:analyzer/src/generated/element.dart';
(...skipping 12393 matching lines...) Expand 10 before | Expand all | Expand 10 after
12404 if (p is A) { 12404 if (p is A) {
12405 return p; 12405 return p;
12406 } else { 12406 } else {
12407 return null; 12407 return null;
12408 } 12408 }
12409 }'''); 12409 }''');
12410 LibraryElement library = resolve(source); 12410 LibraryElement library = resolve(source);
12411 assertNoErrors(source); 12411 assertNoErrors(source);
12412 verify([source]); 12412 verify([source]);
12413 CompilationUnit unit = resolveCompilationUnit(source, library); 12413 CompilationUnit unit = resolveCompilationUnit(source, library);
12414 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration; 12414 // prepare A
12415 InterfaceType typeA = classA.element.type; 12415 InterfaceType typeA;
12416 {
12417 ClassDeclaration classA = unit.declarations[0] as ClassDeclaration;
12418 typeA = classA.element.type;
12419 }
12420 // verify "f"
12416 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration; 12421 FunctionDeclaration function = unit.declarations[1] as FunctionDeclaration;
12417 BlockFunctionBody body = 12422 BlockFunctionBody body =
12418 function.functionExpression.body as BlockFunctionBody; 12423 function.functionExpression.body as BlockFunctionBody;
12419 IfStatement ifStatement = body.block.statements[0] as IfStatement; 12424 IfStatement ifStatement = body.block.statements[0] as IfStatement;
12420 ReturnStatement statement = 12425 // "p is A"
12421 (ifStatement.thenStatement as Block).statements[0] as ReturnStatement; 12426 {
12422 SimpleIdentifier variableName = statement.expression as SimpleIdentifier; 12427 IsExpression isExpression = ifStatement.condition;
12423 expect(variableName.propagatedType, same(typeA)); 12428 SimpleIdentifier variableName = isExpression.expression;
12429 expect(variableName.propagatedType, isNull);
12430 }
12431 // "return p;"
12432 {
12433 ReturnStatement statement =
12434 (ifStatement.thenStatement as Block).statements[0] as ReturnStatement;
12435 SimpleIdentifier variableName = statement.expression as SimpleIdentifier;
12436 expect(variableName.propagatedType, same(typeA));
12437 }
12424 } 12438 }
12425 12439
12426 void test_is_if_lessSpecific() { 12440 void test_is_if_lessSpecific() {
12427 Source source = addSource(r''' 12441 Source source = addSource(r'''
12428 class A {} 12442 class A {}
12429 A f(A p) { 12443 A f(A p) {
12430 if (p is String) { 12444 if (p is String) {
12431 return p; 12445 return p;
12432 } else { 12446 } else {
12433 return null; 12447 return null;
(...skipping 1363 matching lines...) Expand 10 before | Expand all | Expand 10 after
13797 // check propagated type 13811 // check propagated type
13798 FunctionType propagatedType = node.propagatedType as FunctionType; 13812 FunctionType propagatedType = node.propagatedType as FunctionType;
13799 expect(propagatedType.returnType, test.typeProvider.stringType); 13813 expect(propagatedType.returnType, test.typeProvider.stringType);
13800 } on AnalysisException catch (e, stackTrace) { 13814 } on AnalysisException catch (e, stackTrace) {
13801 thrownException[0] = new CaughtException(e, stackTrace); 13815 thrownException[0] = new CaughtException(e, stackTrace);
13802 } 13816 }
13803 } 13817 }
13804 return null; 13818 return null;
13805 } 13819 }
13806 } 13820 }
OLDNEW
« no previous file with comments | « pkg/analyzer/pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698