@@ -52,7 +52,7 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<void> {
52
52
/**
53
53
* The type system in use for static type analysis.
54
54
*/
55
- TypeSystem _typeSystem;
55
+ Dart2TypeSystem _typeSystem;
56
56
57
57
/**
58
58
* The type representing the type 'dynamic'.
@@ -124,12 +124,11 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<void> {
124
124
FormalParameterList node, DartType functionType) {
125
125
bool inferred = false ;
126
126
if (node != null && functionType is FunctionType ) {
127
- var ts = _typeSystem as Dart2TypeSystem ;
128
127
void inferType (ParameterElementImpl p, DartType inferredType) {
129
128
// Check that there is no declared type, and that we have not already
130
129
// inferred a type in some fashion.
131
130
if (p.hasImplicitType && (p.type == null || p.type.isDynamic)) {
132
- inferredType = ts .upperBoundForType (inferredType);
131
+ inferredType = _typeSystem .upperBoundForType (inferredType);
133
132
if (inferredType.isDartCoreNull) {
134
133
inferredType = _typeProvider.objectType;
135
134
}
@@ -202,8 +201,7 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<void> {
202
201
HintCode .INFERENCE_FAILURE_ON_COLLECTION_LITERAL , node, ['List' ]);
203
202
}
204
203
205
- var typeArguments =
206
- (_typeSystem as Dart2TypeSystem ).inferGenericFunctionOrType (
204
+ var typeArguments = _typeSystem.inferGenericFunctionOrType (
207
205
typeParameters: typeParameters,
208
206
parameters: parameters,
209
207
declaredReturnType: element.thisType,
@@ -227,8 +225,7 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<void> {
227
225
}
228
226
229
227
var element = _typeProvider.mapElement;
230
- var typeArguments =
231
- (_typeSystem as Dart2TypeSystem ).inferGenericFunctionOrType (
228
+ var typeArguments = _typeSystem.inferGenericFunctionOrType (
232
229
typeParameters: element.typeParameters,
233
230
parameters: const [],
234
231
declaredReturnType: element.thisType,
@@ -251,8 +248,7 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<void> {
251
248
}
252
249
253
250
var element = _typeProvider.setElement;
254
- var typeArguments =
255
- (_typeSystem as Dart2TypeSystem ).inferGenericFunctionOrType (
251
+ var typeArguments = _typeSystem.inferGenericFunctionOrType (
256
252
typeParameters: element.typeParameters,
257
253
parameters: const [],
258
254
declaredReturnType: element.thisType,
@@ -1674,11 +1670,9 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<void> {
1674
1670
ArgumentList argumentList,
1675
1671
AstNode errorNode,
1676
1672
{bool isConst: false }) {
1677
- TypeSystem ts = _typeSystem;
1678
1673
if (typeArguments == null &&
1679
1674
fnType is FunctionType &&
1680
- fnType.typeFormals.isNotEmpty &&
1681
- ts is Dart2TypeSystem ) {
1675
+ fnType.typeFormals.isNotEmpty) {
1682
1676
// Get the parameters that correspond to the uninstantiated generic.
1683
1677
List <ParameterElement > rawParameters =
1684
1678
ResolverVisitor .resolveArgumentsToParameters (
@@ -1693,7 +1687,7 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<void> {
1693
1687
argTypes.add (argumentList.arguments[i].staticType);
1694
1688
}
1695
1689
}
1696
- var typeArgs = ts .inferGenericFunctionOrType (
1690
+ var typeArgs = _typeSystem .inferGenericFunctionOrType (
1697
1691
typeParameters: fnType.typeFormals,
1698
1692
parameters: params,
1699
1693
declaredReturnType: fnType.returnType,
@@ -1996,12 +1990,9 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<void> {
1996
1990
SimpleIdentifier identifier,
1997
1991
DartType tearOffType,
1998
1992
) {
1999
- TypeSystem ts = _typeSystem;
2000
1993
var context = InferenceContext .getContext (expression);
2001
- if (context is FunctionType &&
2002
- tearOffType is FunctionType &&
2003
- ts is Dart2TypeSystem ) {
2004
- var typeArguments = ts.inferFunctionTypeInstantiation (
1994
+ if (context is FunctionType && tearOffType is FunctionType ) {
1995
+ var typeArguments = _typeSystem.inferFunctionTypeInstantiation (
2005
1996
context,
2006
1997
tearOffType,
2007
1998
errorReporter: _resolver.errorReporter,
@@ -2134,8 +2125,7 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<void> {
2134
2125
argumentTypes[2 * i + 1 ] = inferredTypes[i].valueType ?? dynamicType;
2135
2126
}
2136
2127
2137
- var typeArguments =
2138
- (_typeSystem as Dart2TypeSystem ).inferGenericFunctionOrType (
2128
+ var typeArguments = _typeSystem.inferGenericFunctionOrType (
2139
2129
typeParameters: typeParameters,
2140
2130
parameters: parameters,
2141
2131
declaredReturnType: element.thisType,
@@ -2166,8 +2156,7 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<void> {
2166
2156
argumentTypes[i] = inferredTypes[i].elementType ?? dynamicType;
2167
2157
}
2168
2158
2169
- var typeArguments =
2170
- (_typeSystem as Dart2TypeSystem ).inferGenericFunctionOrType (
2159
+ var typeArguments = _typeSystem.inferGenericFunctionOrType (
2171
2160
typeParameters: typeParameters,
2172
2161
parameters: parameters,
2173
2162
declaredReturnType: element.thisType,
0 commit comments