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

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

Issue 1371813002: infer field formal parameter types (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 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/lib/src/task/strong_mode.dart ('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) 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.strong_mode_test; 5 library test.src.task.strong_mode_test;
6 6
7 import 'package:analyzer/src/generated/ast.dart'; 7 import 'package:analyzer/src/generated/ast.dart';
8 import 'package:analyzer/src/generated/element.dart'; 8 import 'package:analyzer/src/generated/element.dart';
9 import 'package:analyzer/src/generated/source.dart'; 9 import 'package:analyzer/src/generated/source.dart';
10 import 'package:analyzer/src/task/strong_mode.dart'; 10 import 'package:analyzer/src/task/strong_mode.dart';
(...skipping 940 matching lines...) Expand 10 before | Expand all | Expand 10 after
951 MethodElement methodB = classB.getMethod(methodName); 951 MethodElement methodB = classB.getMethod(methodName);
952 expect(methodB.returnType.isDynamic, isTrue); 952 expect(methodB.returnType.isDynamic, isTrue);
953 expect(methodB.type.typeArguments, [typeBE]); 953 expect(methodB.type.typeArguments, [typeBE]);
954 954
955 inferrer.inferCompilationUnit(unit); 955 inferrer.inferCompilationUnit(unit);
956 956
957 expect(methodB.returnType, classB.typeParameters[0].type); 957 expect(methodB.returnType, classB.typeParameters[0].type);
958 expect(methodB.type.typeArguments, [typeBE], 958 expect(methodB.type.typeArguments, [typeBE],
959 reason: 'function type should still have type arguments'); 959 reason: 'function type should still have type arguments');
960 } 960 }
961
962 void test_inferCompilationUnit_fieldFormal() {
963 InstanceMemberInferrer inferrer = createInferrer;
964 String fieldName = 'f';
965 CompilationUnitElement unit = resolve('''
966 class A {
967 final $fieldName = 0;
968 A([this.$fieldName = 'hello']);
969 }
970 ''');
971 ClassElement classA = unit.getType('A');
972 FieldElement fieldA = classA.getField(fieldName);
973 FieldFormalParameterElement paramA =
974 classA.unnamedConstructor.parameters[0];
975 expect(fieldA.type.isDynamic, isTrue);
976 expect(paramA.type.isDynamic, isTrue);
977
978 inferrer.inferCompilationUnit(unit);
979
980 DartType intType = inferrer.typeProvider.intType;
981 expect(fieldA.type, intType);
982 expect(paramA.type, intType);
983 }
961 } 984 }
962 985
963 @reflectiveTest 986 @reflectiveTest
964 class VariableGathererTest extends AbstractContextTest { 987 class VariableGathererTest extends AbstractContextTest {
965 void test_creation_withFilter() { 988 void test_creation_withFilter() {
966 VariableFilter filter = (variable) => true; 989 VariableFilter filter = (variable) => true;
967 VariableGatherer gatherer = new VariableGatherer(filter); 990 VariableGatherer gatherer = new VariableGatherer(filter);
968 expect(gatherer, isNotNull); 991 expect(gatherer, isNotNull);
969 expect(gatherer.filter, filter); 992 expect(gatherer.filter, filter);
970 } 993 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1021 } 1044 }
1022 } 1045 }
1023 } 1046 }
1024 '''); 1047 ''');
1025 CompilationUnit unit = context.resolveCompilationUnit2(source, source); 1048 CompilationUnit unit = context.resolveCompilationUnit2(source, source);
1026 VariableGatherer gatherer = new VariableGatherer(filter); 1049 VariableGatherer gatherer = new VariableGatherer(filter);
1027 unit.accept(gatherer); 1050 unit.accept(gatherer);
1028 return gatherer.results; 1051 return gatherer.results;
1029 } 1052 }
1030 } 1053 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/task/strong_mode.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698