22// for details. All rights reserved. Use of this source code is governed by a
33// BSD-style license that can be found in the LICENSE file.
44
5- import 'package:analyzer/dart/analysis/features.dart' ;
65import 'package:analyzer/dart/ast/ast.dart' ;
76import 'package:analyzer/dart/ast/visitor.dart' ;
87import 'package:analyzer/dart/element/element.dart' ;
@@ -28,9 +27,6 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<void> {
2827 /// The resolver driving the resolution and type analysis.
2928 final ResolverVisitor _resolver;
3029
31- /// The feature set that should be used to resolve types.
32- final FeatureSet _featureSet;
33-
3430 final MigrationResolutionHooks _migrationResolutionHooks;
3531
3632 /// The object providing access to the types defined by the language.
@@ -48,17 +44,13 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<void> {
4844 /// [_resolver] based on the
4945 ///
5046 /// @param resolver the resolver driving this participant
51- StaticTypeAnalyzer (this ._resolver, this ._featureSet, this ._flowAnalysis,
52- this ._migrationResolutionHooks) {
47+ StaticTypeAnalyzer (
48+ this ._resolver, this ._flowAnalysis, this . _migrationResolutionHooks) {
5349 _typeProvider = _resolver.typeProvider;
5450 _typeSystem = _resolver.typeSystem;
5551 _dynamicType = _typeProvider.dynamicType;
5652 }
5753
58- /// Is `true` if the library being analyzed is non-nullable by default.
59- bool get _isNonNullableByDefault =>
60- _featureSet.isEnabled (Feature .non_nullable);
61-
6254 /// Given a constructor for a generic type, returns the equivalent generic
6355 /// function type that we could use to forward to the constructor, or for a
6456 /// non-generic type simply returns the constructor type.
@@ -111,7 +103,7 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<void> {
111103 /// `String` .</blockquote>
112104 @override
113105 void visitAdjacentStrings (AdjacentStrings node) {
114- recordStaticType (node, _nonNullable ( _typeProvider.stringType) );
106+ recordStaticType (node, _typeProvider.stringType);
115107 }
116108
117109 /// The Dart Language Specification, 12.32: <blockquote>... the cast expression <i>e as T</i> ...
@@ -140,7 +132,7 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<void> {
140132 /// bool.</blockquote>
141133 @override
142134 void visitBooleanLiteral (BooleanLiteral node) {
143- recordStaticType (node, _nonNullable ( _typeProvider.boolType) );
135+ recordStaticType (node, _typeProvider.boolType);
144136 }
145137
146138 /// The Dart Language Specification, 12.15.2: <blockquote>A cascaded method invocation expression
@@ -167,7 +159,7 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<void> {
167159 /// double.</blockquote>
168160 @override
169161 void visitDoubleLiteral (DoubleLiteral node) {
170- recordStaticType (node, _nonNullable ( _typeProvider.doubleType) );
162+ recordStaticType (node, _typeProvider.doubleType);
171163 }
172164
173165 @override
@@ -242,9 +234,9 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<void> {
242234 if (context == null ||
243235 _typeSystem.isAssignableTo2 (_typeProvider.intType, context) ||
244236 ! _typeSystem.isAssignableTo2 (_typeProvider.doubleType, context)) {
245- recordStaticType (node, _nonNullable ( _typeProvider.intType) );
237+ recordStaticType (node, _typeProvider.intType);
246238 } else {
247- recordStaticType (node, _nonNullable ( _typeProvider.doubleType) );
239+ recordStaticType (node, _typeProvider.doubleType);
248240 }
249241 }
250242
@@ -254,7 +246,7 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<void> {
254246 /// The static type of an is-expression is `bool` .</blockquote>
255247 @override
256248 void visitIsExpression (IsExpression node) {
257- recordStaticType (node, _nonNullable ( _typeProvider.boolType) );
249+ recordStaticType (node, _typeProvider.boolType);
258250 }
259251
260252 @override
@@ -292,14 +284,14 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<void> {
292284 /// `String` .</blockquote>
293285 @override
294286 void visitSimpleStringLiteral (SimpleStringLiteral node) {
295- recordStaticType (node, _nonNullable ( _typeProvider.stringType) );
287+ recordStaticType (node, _typeProvider.stringType);
296288 }
297289
298290 /// The Dart Language Specification, 12.5: <blockquote>The static type of a string literal is
299291 /// `String` .</blockquote>
300292 @override
301293 void visitStringInterpolation (StringInterpolation node) {
302- recordStaticType (node, _nonNullable ( _typeProvider.stringType) );
294+ recordStaticType (node, _typeProvider.stringType);
303295 }
304296
305297 @override
@@ -316,7 +308,7 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<void> {
316308
317309 @override
318310 void visitSymbolLiteral (SymbolLiteral node) {
319- recordStaticType (node, _nonNullable ( _typeProvider.symbolType) );
311+ recordStaticType (node, _typeProvider.symbolType);
320312 }
321313
322314 /// The Dart Language Specification, 12.10: <blockquote>The static type of `this` is the
@@ -461,13 +453,4 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<void> {
461453 constructor.staticElement = constructorElement;
462454 }
463455 }
464-
465- /// Return the non-nullable variant of the [type] if NNBD is enabled, otherwise
466- /// return the type itself.
467- DartType _nonNullable (DartType type) {
468- if (_isNonNullableByDefault) {
469- return _typeSystem.promoteToNonNull (type);
470- }
471- return type;
472- }
473456}
0 commit comments