Deprecate 'DartType.isDynamic', use 'is DynamicType' instead.
Change-Id: Ia3660a0d38f01a590dd3e034f40dbdb5a432638a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/300042 Reviewed-by: Samuel Rawlins <srawlins@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
committed by
Commit Queue
parent
e4d754d5b6
commit
ec330b47de
@@ -223,7 +223,7 @@ class DartUnitHighlightsComputer {
|
||||
var element = node.writeOrReadElement;
|
||||
if (element is LocalVariableElement) {
|
||||
var elementType = element.type;
|
||||
if (elementType.isDynamic) {
|
||||
if (elementType is DynamicType) {
|
||||
var type = node.inDeclarationContext()
|
||||
? HighlightRegionType.DYNAMIC_LOCAL_VARIABLE_DECLARATION
|
||||
: HighlightRegionType.DYNAMIC_LOCAL_VARIABLE_REFERENCE;
|
||||
@@ -232,7 +232,7 @@ class DartUnitHighlightsComputer {
|
||||
}
|
||||
if (element is ParameterElement) {
|
||||
var elementType = element.type;
|
||||
if (elementType.isDynamic) {
|
||||
if (elementType is DynamicType) {
|
||||
var type = node.inDeclarationContext()
|
||||
? HighlightRegionType.DYNAMIC_PARAMETER_DECLARATION
|
||||
: HighlightRegionType.DYNAMIC_PARAMETER_REFERENCE;
|
||||
@@ -601,7 +601,7 @@ class DartUnitHighlightsComputer {
|
||||
|
||||
static bool _isDynamicExpression(Expression e) {
|
||||
var type = e.staticType;
|
||||
return type != null && type.isDynamic;
|
||||
return type != null && type is DynamicType;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1162,7 +1162,7 @@ class _DartUnitHighlightsComputerVisitor extends RecursiveAstVisitor<void> {
|
||||
void visitNamedType(NamedType node) {
|
||||
var type = node.type;
|
||||
if (type != null) {
|
||||
var isDynamic = type.isDynamic && node.name2.lexeme == 'dynamic';
|
||||
var isDynamic = type is DynamicType && node.name2.lexeme == 'dynamic';
|
||||
var isNever = type is NeverType;
|
||||
if (isDynamic || isNever) {
|
||||
computer._addRegion_token(
|
||||
|
||||
@@ -173,7 +173,7 @@ class DartUnitHoverComputer {
|
||||
staticType = element.type;
|
||||
} else if (parent is MethodInvocation && parent.methodName == node) {
|
||||
staticType = parent.staticInvokeType;
|
||||
if (staticType != null && staticType.isDynamic) {
|
||||
if (staticType != null && staticType is DynamicType) {
|
||||
staticType = null;
|
||||
}
|
||||
} else if (node is PatternFieldName && parent is PatternField) {
|
||||
|
||||
@@ -166,7 +166,7 @@ class FeatureComputer {
|
||||
final contextType = node.accept(
|
||||
_ContextTypeVisitor(typeProvider, offset),
|
||||
);
|
||||
if (contextType == null || contextType.isDynamic) {
|
||||
if (contextType == null || contextType is DynamicType) {
|
||||
return null;
|
||||
}
|
||||
return typeSystem.resolveToBound(contextType);
|
||||
|
||||
@@ -129,7 +129,7 @@ class TypeMemberContributor extends DartCompletionContributor {
|
||||
var type = expressionType != null
|
||||
? request.libraryElement.typeSystem.resolveToBound(expressionType)
|
||||
: null;
|
||||
if (type == null || type.isDynamic) {
|
||||
if (type == null || type is DynamicType) {
|
||||
// If the expression does not provide a good type, then attempt to get a
|
||||
// better type from the element.
|
||||
if (expression is Identifier) {
|
||||
@@ -141,7 +141,7 @@ class TypeMemberContributor extends DartCompletionContributor {
|
||||
} else if (elem is LocalVariableElement) {
|
||||
type = elem.type;
|
||||
}
|
||||
if ((type == null || type.isDynamic) &&
|
||||
if ((type == null || type is DynamicType) &&
|
||||
expression is SimpleIdentifier) {
|
||||
// If the element does not provide a good type, then attempt to get a
|
||||
// better type from a local declaration.
|
||||
|
||||
@@ -211,7 +211,7 @@ String getRequestLineIndent(DartCompletionRequest request) {
|
||||
}
|
||||
|
||||
String getTypeString(DartType type, {required bool withNullability}) {
|
||||
if (type.isDynamic) {
|
||||
if (type is DynamicType) {
|
||||
return '';
|
||||
} else {
|
||||
return '${type.getDisplayString(withNullability: withNullability)} ';
|
||||
@@ -245,7 +245,7 @@ String? nameForType(SimpleIdentifier identifier, TypeAnnotation? declaredType) {
|
||||
}
|
||||
|
||||
// If the type is unresolved, use the declared type.
|
||||
if (type.isDynamic) {
|
||||
if (type is DynamicType) {
|
||||
if (declaredType is NamedType) {
|
||||
return declaredType.qualifiedName;
|
||||
}
|
||||
|
||||
+2
-2
@@ -79,7 +79,7 @@ class AddDiagnosticPropertyReference extends CorrectionProducer {
|
||||
constructorId = 'TransformProperty';
|
||||
} else {
|
||||
constructorId = 'DiagnosticsProperty';
|
||||
if (!type.isDynamic) {
|
||||
if (type is! DynamicType) {
|
||||
typeArgs = [type];
|
||||
}
|
||||
}
|
||||
@@ -94,7 +94,7 @@ class AddDiagnosticPropertyReference extends CorrectionProducer {
|
||||
builder.write('<');
|
||||
builder.writeTypes(typeArgs);
|
||||
builder.write('>');
|
||||
} else if (type.isDynamic) {
|
||||
} else if (type is DynamicType) {
|
||||
TypeAnnotation? declType;
|
||||
final decl = node.thisOrAncestorOfType<VariableDeclarationList>();
|
||||
if (decl != null) {
|
||||
|
||||
@@ -67,9 +67,9 @@ class AddReturnType extends CorrectionProducer {
|
||||
|
||||
final insertBeforeEntity_final = insertBeforeEntity;
|
||||
await builder.addDartFileEdit(file, (builder) {
|
||||
if (returnType.isDynamic || builder.canWriteType(returnType)) {
|
||||
if (returnType is DynamicType || builder.canWriteType(returnType)) {
|
||||
builder.addInsertion(insertBeforeEntity_final.offset, (builder) {
|
||||
if (returnType.isDynamic) {
|
||||
if (returnType is DynamicType) {
|
||||
builder.write('dynamic');
|
||||
} else {
|
||||
builder.writeType(returnType);
|
||||
|
||||
@@ -58,8 +58,8 @@ class ConvertToMapLiteral extends CorrectionProducer {
|
||||
creation.thisOrAncestorOfType<VariableDeclarationList>();
|
||||
if (variableDeclarationList?.type == null) {
|
||||
staticTypeArguments = type.typeArguments;
|
||||
if (staticTypeArguments.first.isDynamic &&
|
||||
staticTypeArguments.last.isDynamic) {
|
||||
if (staticTypeArguments.first is DynamicType &&
|
||||
staticTypeArguments.last is DynamicType) {
|
||||
staticTypeArguments = null;
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -5,6 +5,7 @@
|
||||
import 'package:analysis_server/src/services/correction/assist.dart';
|
||||
import 'package:analysis_server/src/services/correction/dart/abstract_producer.dart';
|
||||
import 'package:analyzer/dart/ast/ast.dart';
|
||||
import 'package:analyzer/dart/element/type.dart';
|
||||
import 'package:analyzer_plugin/utilities/assist/assist.dart';
|
||||
import 'package:analyzer_plugin/utilities/change_builder/change_builder_core.dart';
|
||||
import 'package:analyzer_plugin/utilities/range_factory.dart';
|
||||
@@ -30,7 +31,7 @@ class ConvertToNormalParameter extends CorrectionProducer {
|
||||
|
||||
await builder.addDartFileEdit(file, (builder) {
|
||||
// replace parameter
|
||||
if (type.isDynamic) {
|
||||
if (type is DynamicType) {
|
||||
builder.addSimpleReplacement(range.node(parameter), name);
|
||||
} else {
|
||||
builder.addReplacement(range.node(parameter), (builder) {
|
||||
|
||||
+2
-1
@@ -5,6 +5,7 @@
|
||||
import 'package:analysis_server/src/services/correction/dart/abstract_producer.dart';
|
||||
import 'package:analysis_server/src/services/correction/fix.dart';
|
||||
import 'package:analyzer/dart/ast/ast.dart';
|
||||
import 'package:analyzer/dart/element/type.dart';
|
||||
import 'package:analyzer_plugin/utilities/change_builder/change_builder_core.dart';
|
||||
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
|
||||
import 'package:analyzer_plugin/utilities/range_factory.dart';
|
||||
@@ -27,7 +28,7 @@ class ReplaceReturnTypeIterable extends CorrectionProducer {
|
||||
return;
|
||||
}
|
||||
var type = typeAnnotation.type;
|
||||
if (type == null || type.isDynamic || type.isDartCoreIterable) {
|
||||
if (type == null || type is DynamicType || type.isDartCoreIterable) {
|
||||
return;
|
||||
}
|
||||
_typeArgument = utils.getNodeText(typeAnnotation);
|
||||
|
||||
+2
-1
@@ -5,6 +5,7 @@
|
||||
import 'package:analysis_server/src/services/correction/dart/abstract_producer.dart';
|
||||
import 'package:analysis_server/src/services/correction/fix.dart';
|
||||
import 'package:analyzer/dart/ast/ast.dart';
|
||||
import 'package:analyzer/dart/element/type.dart';
|
||||
import 'package:analyzer_plugin/utilities/change_builder/change_builder_core.dart';
|
||||
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
|
||||
import 'package:analyzer_plugin/utilities/range_factory.dart';
|
||||
@@ -27,7 +28,7 @@ class ReplaceReturnTypeStream extends CorrectionProducer {
|
||||
return;
|
||||
}
|
||||
var type = typeAnnotation.type;
|
||||
if (type == null || type.isDynamic || type.isDartAsyncStream) {
|
||||
if (type == null || type is DynamicType || type.isDartAsyncStream) {
|
||||
return;
|
||||
}
|
||||
_typeArgument = utils.getNodeText(typeAnnotation);
|
||||
|
||||
@@ -6,6 +6,7 @@ import 'package:analysis_server/src/services/correction/assist.dart';
|
||||
import 'package:analysis_server/src/services/correction/dart/abstract_producer.dart';
|
||||
import 'package:analysis_server/src/services/correction/fix.dart';
|
||||
import 'package:analyzer/dart/ast/ast.dart';
|
||||
import 'package:analyzer/dart/element/type.dart';
|
||||
import 'package:analyzer/src/dart/ast/extensions.dart';
|
||||
import 'package:analyzer_plugin/utilities/assist/assist.dart';
|
||||
import 'package:analyzer_plugin/utilities/change_builder/change_builder_core.dart';
|
||||
@@ -124,7 +125,7 @@ class ReplaceWithVar extends CorrectionProducer {
|
||||
/// Return `true` if the type in the [node] can be replaced with `var`.
|
||||
bool _canConvertVariableDeclarationList(VariableDeclarationList node) {
|
||||
final staticType = node.type?.type;
|
||||
if (staticType == null || staticType.isDynamic) {
|
||||
if (staticType == null || staticType is DynamicType) {
|
||||
return false;
|
||||
}
|
||||
for (final child in node.variables) {
|
||||
@@ -147,7 +148,7 @@ class ReplaceWithVar extends CorrectionProducer {
|
||||
} else if (parent is ForEachPartsWithDeclaration) {
|
||||
var loopVariableType = parent.loopVariable.type;
|
||||
var staticType = loopVariableType?.type;
|
||||
if (staticType == null || staticType.isDynamic) {
|
||||
if (staticType == null || staticType is DynamicType) {
|
||||
return false;
|
||||
}
|
||||
final iterableType = parent.iterable.typeOrThrow;
|
||||
|
||||
+2
-1
@@ -6,6 +6,7 @@ import 'package:_fe_analyzer_shared/src/scanner/token.dart';
|
||||
import 'package:analysis_server/src/services/correction/assist.dart';
|
||||
import 'package:analysis_server/src/services/correction/dart/abstract_producer.dart';
|
||||
import 'package:analyzer/dart/ast/ast.dart';
|
||||
import 'package:analyzer/dart/element/type.dart';
|
||||
import 'package:analyzer_plugin/utilities/assist/assist.dart';
|
||||
import 'package:analyzer_plugin/utilities/change_builder/change_builder_core.dart';
|
||||
import 'package:analyzer_plugin/utilities/range_factory.dart';
|
||||
@@ -53,7 +54,7 @@ class SplitVariableDeclaration extends CorrectionProducer {
|
||||
await builder.addDartFileEdit(file, (builder) {
|
||||
if (variableList.type == null) {
|
||||
final type = variable.declaredElement!.type;
|
||||
if (!type.isDynamic && keyword != null) {
|
||||
if (type is! DynamicType && keyword != null) {
|
||||
if (!builder.canWriteType(type)) {
|
||||
return;
|
||||
}
|
||||
|
||||
+1
-1
@@ -544,7 +544,7 @@ class _MatcherBuilder {
|
||||
if (type != null) {
|
||||
if (type is InterfaceType) {
|
||||
return type.element.name;
|
||||
} else if (type.isDynamic) {
|
||||
} else if (type is DynamicType) {
|
||||
// The name is likely to be undefined.
|
||||
return target.name;
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ List<String> getVariableNameSuggestionsForExpression(DartType? expectedType,
|
||||
}
|
||||
}
|
||||
// use type
|
||||
if (expectedType != null && !expectedType.isDynamic) {
|
||||
if (expectedType != null && expectedType is! DynamicType) {
|
||||
if (expectedType.isDartCoreInt) {
|
||||
_addSingleCharacterName(excluded, res, 0x69);
|
||||
} else if (expectedType.isDartCoreDouble) {
|
||||
|
||||
@@ -792,7 +792,7 @@ class ExtractMethodRefactoringImpl extends RefactoringImpl
|
||||
} else {
|
||||
returnType = 'void';
|
||||
}
|
||||
} else if (returnTypeObj.isDynamic) {
|
||||
} else if (returnTypeObj is DynamicType) {
|
||||
variableType = '';
|
||||
if (_hasAwait) {
|
||||
returnType = _getTypeCode(typeProvider.futureDynamicType);
|
||||
|
||||
@@ -104,10 +104,11 @@ class ImpliedTypeCollector extends RecursiveAstVisitor<void> {
|
||||
void handleVariableDeclaration(VariableDeclaration node, DartType? dartType) {
|
||||
// If some untyped variable declaration
|
||||
if (node.equals != null && dartType == null ||
|
||||
(dartType != null && (dartType.isDynamic || dartType is VoidType))) {
|
||||
(dartType != null &&
|
||||
(dartType is DynamicType || dartType is VoidType))) {
|
||||
// And if we can determine the type on the RHS of the variable declaration
|
||||
var rhsType = node.initializer?.staticType;
|
||||
if (rhsType != null && !rhsType.isDynamic) {
|
||||
if (rhsType != null && rhsType is! DynamicType) {
|
||||
// Record the name with the type.
|
||||
data.recordImpliedType(
|
||||
node.name.lexeme,
|
||||
|
||||
@@ -1661,9 +1661,9 @@ class RelevanceDataCollector extends RecursiveAstVisitor<void> {
|
||||
var overrideType = overrideParameter?.type;
|
||||
var overriddenType = overriddenParameter?.type;
|
||||
if (overrideType == null ||
|
||||
overrideType.isDynamic ||
|
||||
overrideType is DynamicType ||
|
||||
overriddenType == null ||
|
||||
overriddenType.isDynamic) {
|
||||
overriddenType is DynamicType) {
|
||||
return;
|
||||
}
|
||||
_recordTypeRelationships(
|
||||
@@ -1764,7 +1764,7 @@ class RelevanceDataCollector extends RecursiveAstVisitor<void> {
|
||||
/// in the expression match the type of the associated parameter.
|
||||
void _recordTypeMatch(Expression argument) {
|
||||
var parameterType = argument.staticParameterElement?.type;
|
||||
if (parameterType == null || parameterType.isDynamic) {
|
||||
if (parameterType == null || parameterType is DynamicType) {
|
||||
return;
|
||||
}
|
||||
if (parameterType is FunctionType) {
|
||||
|
||||
@@ -11,6 +11,7 @@ import 'package:analyzer/dart/ast/syntactic_entity.dart';
|
||||
import 'package:analyzer/dart/ast/token.dart';
|
||||
import 'package:analyzer/dart/ast/visitor.dart';
|
||||
import 'package:analyzer/dart/element/element.dart' as element;
|
||||
import 'package:analyzer/dart/element/type.dart';
|
||||
import 'package:analyzer/source/line_info.dart';
|
||||
|
||||
class ExpectedCompletion {
|
||||
@@ -773,7 +774,7 @@ class ExpectedCompletionsVisitor extends RecursiveAstVisitor<void> {
|
||||
|
||||
// If the type of the SimpleIdentifier is dynamic, don't include.
|
||||
var staticType = node.staticType;
|
||||
if (staticType != null && staticType.isDynamic) {
|
||||
if (staticType != null && staticType is DynamicType) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
## 5.12.0-dev
|
||||
* Deprecated `DartType.isDynamic`, use `is DynamicType` instead.
|
||||
|
||||
## 5.11.1
|
||||
* Restore previously published `finalKeyword`, `interfaceKeyword` and
|
||||
`sealedKeyword` of `MixinElement`. We added them preliminary while
|
||||
|
||||
@@ -124,6 +124,7 @@ abstract class DartType {
|
||||
bool get isDartCoreType;
|
||||
|
||||
/// Return `true` if this type represents the type 'dynamic'.
|
||||
@Deprecated('Use `is DynamicType` instead')
|
||||
bool get isDynamic;
|
||||
|
||||
/// Return `true` if this type represents the type 'void'.
|
||||
|
||||
@@ -381,7 +381,7 @@ class ElementDisplayStringBuilder {
|
||||
}
|
||||
|
||||
if (skipAllDynamicArguments) {
|
||||
if (typeArguments.every((t) => t.isDynamic)) {
|
||||
if (typeArguments.every((t) => t is DynamicType)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ class DynamicTypeImpl extends TypeImpl implements DynamicType {
|
||||
@override
|
||||
int get hashCode => 1;
|
||||
|
||||
@Deprecated('Use `is DynamicType` instead')
|
||||
@override
|
||||
bool get isDynamic => true;
|
||||
|
||||
@@ -362,7 +363,7 @@ class FunctionTypeImpl extends TypeImpl implements FunctionType {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!bound2.isDynamic) {
|
||||
if (bound2 is! DynamicType) {
|
||||
pFresh.bound = bound2;
|
||||
}
|
||||
}
|
||||
@@ -1247,6 +1248,7 @@ abstract class TypeImpl implements DartType {
|
||||
@override
|
||||
bool get isDartCoreType => false;
|
||||
|
||||
@Deprecated('Use `is DynamicType` instead')
|
||||
@override
|
||||
bool get isDynamic => false;
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ class UnknownInferredType extends TypeImpl {
|
||||
@override
|
||||
int get hashCode => 1;
|
||||
|
||||
@Deprecated('Use `is UnknownInferredType` instead')
|
||||
@override
|
||||
bool get isDynamic => true;
|
||||
|
||||
|
||||
@@ -914,7 +914,7 @@ class TypeSystemImpl implements TypeSystem {
|
||||
|
||||
// Now handle NNBD default behavior, where we disable non-dynamic downcasts.
|
||||
if (isNonNullableByDefault) {
|
||||
return fromType.isDynamic;
|
||||
return fromType is DynamicType;
|
||||
}
|
||||
|
||||
// Don't allow implicit downcasts between function types
|
||||
@@ -1243,7 +1243,10 @@ class TypeSystemImpl implements TypeSystem {
|
||||
|
||||
@override
|
||||
bool isNonNullable(DartType type) {
|
||||
if (type.isDynamic || type is VoidType || type.isDartCoreNull) {
|
||||
if (type is DynamicType ||
|
||||
type is UnknownInferredType ||
|
||||
type is VoidType ||
|
||||
type.isDartCoreNull) {
|
||||
return false;
|
||||
} else if (type is TypeParameterTypeImpl && type.promotedBound != null) {
|
||||
return isNonNullable(type.promotedBound!);
|
||||
@@ -1284,7 +1287,10 @@ class TypeSystemImpl implements TypeSystem {
|
||||
|
||||
@override
|
||||
bool isNullable(DartType type) {
|
||||
if (type.isDynamic || type is VoidType || type.isDartCoreNull) {
|
||||
if (type is DynamicType ||
|
||||
type is UnknownInferredType ||
|
||||
type is VoidType ||
|
||||
type.isDartCoreNull) {
|
||||
return true;
|
||||
} else if (type is TypeParameterTypeImpl && type.promotedBound != null) {
|
||||
return isNullable(type.promotedBound!);
|
||||
@@ -1326,7 +1332,10 @@ class TypeSystemImpl implements TypeSystem {
|
||||
|
||||
@override
|
||||
bool isStrictlyNonNullable(DartType type) {
|
||||
if (type.isDynamic || type is VoidType || type.isDartCoreNull) {
|
||||
if (type is DynamicType ||
|
||||
type is UnknownInferredType ||
|
||||
type is VoidType ||
|
||||
type.isDartCoreNull) {
|
||||
return false;
|
||||
} else if (type.nullabilitySuffix != NullabilitySuffix.none) {
|
||||
return false;
|
||||
@@ -1682,7 +1691,7 @@ class TypeSystemImpl implements TypeSystem {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!bound1.isDynamic) {
|
||||
if (bound1 is! DynamicType) {
|
||||
freshTypeParameters[i].bound = bound1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import 'package:analyzer/error/listener.dart';
|
||||
import 'package:analyzer/src/dart/ast/ast.dart';
|
||||
import 'package:analyzer/src/dart/ast/extensions.dart';
|
||||
import 'package:analyzer/src/dart/element/type.dart';
|
||||
import 'package:analyzer/src/dart/element/type_schema.dart';
|
||||
import 'package:analyzer/src/dart/element/type_system.dart';
|
||||
import 'package:analyzer/src/dart/resolver/invocation_inference_helper.dart';
|
||||
import 'package:analyzer/src/dart/resolver/resolution_result.dart';
|
||||
@@ -176,7 +177,9 @@ class BinaryExpressionResolver {
|
||||
var leftType = left.typeOrThrow;
|
||||
|
||||
var rightContextType = contextType;
|
||||
if (rightContextType == null || rightContextType.isDynamic) {
|
||||
if (rightContextType == null ||
|
||||
rightContextType is DynamicType ||
|
||||
rightContextType is UnknownInferredType) {
|
||||
rightContextType = leftType;
|
||||
}
|
||||
|
||||
|
||||
@@ -427,7 +427,7 @@ class TypeSystemOperations
|
||||
}
|
||||
|
||||
@override
|
||||
bool isDynamic(DartType type) => type.isDynamic;
|
||||
bool isDynamic(DartType type) => type is DynamicType;
|
||||
|
||||
@override
|
||||
bool isNever(DartType type) {
|
||||
|
||||
@@ -8,6 +8,7 @@ import 'package:analyzer/dart/element/type.dart';
|
||||
import 'package:analyzer/src/dart/ast/ast.dart';
|
||||
import 'package:analyzer/src/dart/element/element.dart';
|
||||
import 'package:analyzer/src/dart/element/type.dart';
|
||||
import 'package:analyzer/src/dart/element/type_schema.dart';
|
||||
import 'package:analyzer/src/dart/element/type_system.dart';
|
||||
import 'package:analyzer/src/dart/resolver/invocation_inference_helper.dart';
|
||||
import 'package:analyzer/src/generated/migration.dart';
|
||||
@@ -53,7 +54,7 @@ class FunctionExpressionResolver {
|
||||
if (instantiatedType is FunctionType) {
|
||||
_inferFormalParameters(node.parameters, instantiatedType);
|
||||
var returnType = instantiatedType.returnType;
|
||||
if (!returnType.isDynamic) {
|
||||
if (!(returnType is DynamicType || returnType is UnknownInferredType)) {
|
||||
imposedType = returnType;
|
||||
}
|
||||
}
|
||||
@@ -91,7 +92,7 @@ class FunctionExpressionResolver {
|
||||
void inferType(ParameterElementImpl p, DartType inferredType) {
|
||||
// Check that there is no declared type, and that we have not already
|
||||
// inferred a type in some fashion.
|
||||
if (p.hasImplicitType && p.type.isDynamic) {
|
||||
if (p.hasImplicitType && p.type is DynamicType) {
|
||||
// If no type is declared for a parameter and there is a
|
||||
// corresponding parameter in the context type schema with type
|
||||
// schema `K`, the parameter is given an inferred type `T` where `T`
|
||||
@@ -111,7 +112,7 @@ class FunctionExpressionResolver {
|
||||
} else {
|
||||
inferredType = _typeSystem.nonNullifyLegacy(inferredType);
|
||||
}
|
||||
if (!inferredType.isDynamic) {
|
||||
if (inferredType is! DynamicType) {
|
||||
p.type = inferredType;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ class FunctionReferenceResolver {
|
||||
prefixType = prefixElement.variable.type;
|
||||
}
|
||||
|
||||
if (prefixType != null && prefixType.isDynamic) {
|
||||
if (prefixType is DynamicType) {
|
||||
_errorReporter.reportErrorForNode(
|
||||
CompileTimeErrorCode.GENERIC_METHOD_TYPE_INSTANTIATION_ON_DYNAMIC,
|
||||
function,
|
||||
@@ -520,7 +520,7 @@ class FunctionReferenceResolver {
|
||||
return;
|
||||
} else {
|
||||
var targetType = target.staticType;
|
||||
if (targetType != null && targetType.isDynamic) {
|
||||
if (targetType is DynamicType) {
|
||||
_errorReporter.reportErrorForNode(
|
||||
CompileTimeErrorCode.GENERIC_METHOD_TYPE_INSTANTIATION_ON_DYNAMIC,
|
||||
node,
|
||||
|
||||
@@ -127,7 +127,7 @@ class LegacyTypeAsserter extends GeneralizingAstVisitor<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
if (type.isDynamic || type is VoidType) {
|
||||
if (type is DynamicType || type is VoidType) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -128,7 +128,7 @@ class RecordLiteralResolver {
|
||||
field = _resolver.popRewrite()!;
|
||||
|
||||
// Implicit cast from `dynamic`.
|
||||
if (contextType != null && field.typeOrThrow.isDynamic) {
|
||||
if (contextType != null && field.typeOrThrow is DynamicType) {
|
||||
field.staticType = contextType;
|
||||
if (field is NamedExpressionImpl) {
|
||||
field.expression.staticType = contextType;
|
||||
|
||||
@@ -101,7 +101,7 @@ class TypedLiteralResolver {
|
||||
if (typeArguments != null) {
|
||||
if (typeArguments.length == 1) {
|
||||
DartType elementType = typeArguments[0].typeOrThrow;
|
||||
if (!elementType.isDynamic) {
|
||||
if (elementType is! DynamicType) {
|
||||
listType = _typeProvider.listType(elementType);
|
||||
}
|
||||
}
|
||||
@@ -220,7 +220,7 @@ class TypedLiteralResolver {
|
||||
return iterableType.typeArguments[0];
|
||||
}
|
||||
|
||||
if (expressionType.isDynamic) {
|
||||
if (expressionType is DynamicType) {
|
||||
return _typeProvider.dynamicType;
|
||||
}
|
||||
|
||||
@@ -411,7 +411,7 @@ class TypedLiteralResolver {
|
||||
);
|
||||
}
|
||||
|
||||
if (expressionType.isDynamic) {
|
||||
if (expressionType is DynamicType) {
|
||||
return _InferredCollectionElementTypeInformation(
|
||||
elementType: expressionType,
|
||||
keyType: expressionType,
|
||||
@@ -679,7 +679,7 @@ class TypedLiteralResolver {
|
||||
}
|
||||
DartType literalType =
|
||||
_inferSetOrMapLiteralType(inferrer, literalResolution, node);
|
||||
if (literalType.isDynamic) {
|
||||
if (literalType is DynamicType) {
|
||||
// The literal is ambiguous, and further analysis won't resolve the
|
||||
// ambiguity. Leave it as neither a set nor a map.
|
||||
} else if (literalType is InterfaceType &&
|
||||
@@ -821,12 +821,9 @@ class _InferredCollectionElementTypeInformation {
|
||||
bool get canBeSet => elementType != null;
|
||||
|
||||
bool get isDynamic =>
|
||||
elementType != null &&
|
||||
elementType!.isDynamic &&
|
||||
keyType != null &&
|
||||
keyType!.isDynamic &&
|
||||
valueType != null &&
|
||||
valueType!.isDynamic;
|
||||
elementType is DynamicType &&
|
||||
keyType is DynamicType &&
|
||||
valueType is DynamicType;
|
||||
|
||||
bool get mustBeMap => canBeMap && elementType == null;
|
||||
|
||||
|
||||
@@ -629,7 +629,7 @@ class BestPracticesVerifier extends RecursiveAstVisitor<void> {
|
||||
// Only report non-aliased, non-user-defined `Null?` and `dynamic?`. Do
|
||||
// not report synthetic `dynamic` in place of an unresolved type.
|
||||
if ((type is InterfaceType && type.element == _nullType.element ||
|
||||
(type.isDynamic && node.name2.lexeme == 'dynamic')) &&
|
||||
(type is DynamicType && node.name2.lexeme == 'dynamic')) &&
|
||||
type.alias == null) {
|
||||
_errorReporter.reportErrorForToken(
|
||||
WarningCode.UNNECESSARY_QUESTION_MARK,
|
||||
@@ -753,7 +753,7 @@ class BestPracticesVerifier extends RecursiveAstVisitor<void> {
|
||||
}
|
||||
|
||||
// `is dynamic` or `is! dynamic`
|
||||
if (rightType.isDynamic) {
|
||||
if (rightType is DynamicType) {
|
||||
var rightTypeStr = rightNode.ifTypeOrNull<NamedType>()?.qualifiedName;
|
||||
if (rightTypeStr == Keyword.DYNAMIC.lexeme) {
|
||||
report();
|
||||
@@ -1601,12 +1601,12 @@ class BestPracticesVerifier extends RecursiveAstVisitor<void> {
|
||||
var rightType = node.type.typeOrThrow;
|
||||
|
||||
// `dynamicValue as SomeType` is a valid use case.
|
||||
if (leftType.isDynamic) {
|
||||
if (leftType is DynamicType) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// `x as Unresolved` is already reported as an error.
|
||||
if (rightType.isDynamic) {
|
||||
if (rightType is DynamicType) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -138,7 +138,7 @@ class LiteralElementVerifier {
|
||||
/// assigned to the [elementType] of the enclosing collection.
|
||||
void _verifySpreadForListOrSet(bool isNullAware, Expression expression) {
|
||||
var expressionType = expression.typeOrThrow;
|
||||
if (expressionType.isDynamic) {
|
||||
if (expressionType is DynamicType) {
|
||||
if (typeSystem.strictCasts) {
|
||||
return errorReporter.reportErrorForNode(
|
||||
CompileTimeErrorCode.NOT_ITERABLE_SPREAD,
|
||||
@@ -232,7 +232,7 @@ class LiteralElementVerifier {
|
||||
/// its key and values are assignable to [mapKeyType] and [mapValueType].
|
||||
void _verifySpreadForMap(bool isNullAware, Expression expression) {
|
||||
var expressionType = expression.typeOrThrow;
|
||||
if (expressionType.isDynamic) {
|
||||
if (expressionType is DynamicType) {
|
||||
if (typeSystem.strictCasts) {
|
||||
return errorReporter.reportErrorForNode(
|
||||
CompileTimeErrorCode.NOT_MAP_SPREAD,
|
||||
|
||||
@@ -448,10 +448,10 @@ class ReturnTypeVerifier {
|
||||
}
|
||||
|
||||
static bool _isVoidDynamic(DartType type) {
|
||||
return type is VoidType || type.isDynamic;
|
||||
return type is VoidType || type is DynamicType;
|
||||
}
|
||||
|
||||
static bool _isVoidDynamicOrNull(DartType type) {
|
||||
return type is VoidType || type.isDynamic || type.isDartCoreNull;
|
||||
return type is VoidType || type is DynamicType || type.isDartCoreNull;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -232,7 +232,7 @@ class TypeArgumentsVerifier {
|
||||
declaredType is FunctionType &&
|
||||
declaredType.typeFormals.isNotEmpty) {
|
||||
List<DartType> typeArgs = node.typeArgumentTypes!;
|
||||
if (typeArgs.any((t) => t.isDynamic)) {
|
||||
if (typeArgs.any((t) => t is DynamicType)) {
|
||||
// Issue an error depending on what we're trying to call.
|
||||
Expression function = node.function;
|
||||
if (function is Identifier) {
|
||||
@@ -268,7 +268,8 @@ class TypeArgumentsVerifier {
|
||||
}
|
||||
DartType type = node.typeOrThrow;
|
||||
// It's an error if either the key or value was inferred as dynamic.
|
||||
if (type is InterfaceType && type.typeArguments.any((t) => t.isDynamic)) {
|
||||
if (type is InterfaceType &&
|
||||
type.typeArguments.any((t) => t is DynamicType)) {
|
||||
// TODO(brianwilkerson) Add StrongModeCode.IMPLICIT_DYNAMIC_SET_LITERAL
|
||||
ErrorCode errorCode = node is ListLiteral
|
||||
? LanguageCode.IMPLICIT_DYNAMIC_LIST_LITERAL
|
||||
@@ -608,7 +609,7 @@ class TypeArgumentsVerifier {
|
||||
|
||||
// Check if this type has type arguments and at least one is dynamic.
|
||||
// If so, we may need to issue a strict-raw-types error.
|
||||
if (typeArguments.any((t) => t.isDynamic)) {
|
||||
if (typeArguments.any((t) => t is DynamicType)) {
|
||||
if (element != null && element.hasOptionalTypeArgs) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ class ElementResolver {
|
||||
if (type == null) {
|
||||
return;
|
||||
}
|
||||
if (type.isDynamic) {
|
||||
if (type is DynamicType) {
|
||||
// Nothing to do.
|
||||
} else if (type is InterfaceType) {
|
||||
// look up ConstructorElement
|
||||
|
||||
@@ -825,7 +825,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
|
||||
if (!_options.implicitDynamic && node.returnType == null) {
|
||||
DartType parameterType = node.declaredElement!.type;
|
||||
if (parameterType is FunctionType &&
|
||||
parameterType.returnType.isDynamic) {
|
||||
parameterType.returnType is DynamicType) {
|
||||
errorReporter.reportErrorForToken(
|
||||
LanguageCode.IMPLICIT_DYNAMIC_RETURN,
|
||||
node.name,
|
||||
@@ -2478,7 +2478,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
|
||||
// Use an explicit string instead of [loopType] to remove the "<E>".
|
||||
String loopNamedType = awaitKeyword != null ? 'Stream' : 'Iterable';
|
||||
|
||||
if (iterableType.isDynamic && typeSystem.strictCasts) {
|
||||
if (iterableType is DynamicType && typeSystem.strictCasts) {
|
||||
errorReporter.reportErrorForNode(
|
||||
CompileTimeErrorCode.FOR_IN_OF_INVALID_TYPE,
|
||||
node.iterable,
|
||||
@@ -3003,7 +3003,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
|
||||
if (_options.implicitDynamic) {
|
||||
return;
|
||||
}
|
||||
if (variable.hasImplicitType && variable.type.isDynamic) {
|
||||
if (variable.hasImplicitType && variable.type is DynamicType) {
|
||||
ErrorCode errorCode;
|
||||
if (variable is FieldElement) {
|
||||
errorCode = LanguageCode.IMPLICIT_DYNAMIC_FIELD;
|
||||
@@ -3026,7 +3026,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
|
||||
if (element is PropertyAccessorElement && element.isSetter) {
|
||||
return;
|
||||
}
|
||||
if (element.hasImplicitReturnType && element.returnType.isDynamic) {
|
||||
if (element.hasImplicitReturnType && element.returnType is DynamicType) {
|
||||
errorReporter.reportErrorForToken(LanguageCode.IMPLICIT_DYNAMIC_RETURN,
|
||||
functionName, [element.displayName]);
|
||||
}
|
||||
@@ -3041,7 +3041,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
|
||||
DartType type = node.typeOrThrow;
|
||||
if (type is ParameterizedType &&
|
||||
type.typeArguments.isNotEmpty &&
|
||||
type.typeArguments.any((t) => t.isDynamic)) {
|
||||
type.typeArguments.any((t) => t is DynamicType)) {
|
||||
errorReporter
|
||||
.reportErrorForNode(LanguageCode.IMPLICIT_DYNAMIC_TYPE, node, [type]);
|
||||
}
|
||||
|
||||
@@ -629,8 +629,9 @@ class ResolverVisitor extends ThrowingAstVisitor<void>
|
||||
errorCode = CompileTimeErrorCode.BODY_MIGHT_COMPLETE_NORMALLY;
|
||||
} else {
|
||||
var returnTypeBase = typeSystem.futureOrBase(returnType);
|
||||
if (returnTypeBase is VoidType ||
|
||||
returnTypeBase.isDynamic ||
|
||||
if (returnTypeBase is DynamicType ||
|
||||
returnTypeBase is UnknownInferredType ||
|
||||
returnTypeBase is VoidType ||
|
||||
returnTypeBase.isDartCoreNull) {
|
||||
return;
|
||||
} else {
|
||||
@@ -2214,7 +2215,7 @@ class ResolverVisitor extends ThrowingAstVisitor<void>
|
||||
node.parameters.accept(this);
|
||||
node.initializers.accept(this);
|
||||
node.redirectedConstructor?.accept(this);
|
||||
node.body.resolve(this, returnType.isDynamic ? null : returnType);
|
||||
node.body.resolve(this, returnType is DynamicType ? null : returnType);
|
||||
elementResolver.visitConstructorDeclaration(node);
|
||||
} finally {
|
||||
_enclosingFunction = outerFunction;
|
||||
@@ -2957,7 +2958,7 @@ class ResolverVisitor extends ThrowingAstVisitor<void>
|
||||
node.returnType?.accept(this);
|
||||
node.typeParameters?.accept(this);
|
||||
node.parameters?.accept(this);
|
||||
node.body.resolve(this, returnType.isDynamic ? null : returnType);
|
||||
node.body.resolve(this, returnType is DynamicType ? null : returnType);
|
||||
elementResolver.visitMethodDeclaration(node);
|
||||
} finally {
|
||||
_enclosingFunction = outerFunction;
|
||||
@@ -3653,8 +3654,9 @@ class ResolverVisitor extends ThrowingAstVisitor<void>
|
||||
final targetFutureType = instanceOfFuture.typeArguments.first;
|
||||
final expectedReturnType = typeProvider.futureOrType(targetFutureType);
|
||||
final returnTypeBase = typeSystem.futureOrBase(expectedReturnType);
|
||||
if (returnTypeBase is VoidType ||
|
||||
returnTypeBase.isDynamic ||
|
||||
if (returnTypeBase is DynamicType ||
|
||||
returnTypeBase is UnknownInferredType ||
|
||||
returnTypeBase is VoidType ||
|
||||
returnTypeBase.isDartCoreNull) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -594,7 +594,7 @@ class CodeChecker extends RecursiveAstVisitor {
|
||||
}
|
||||
}
|
||||
if (yieldStar) {
|
||||
if (type.isDynamic) {
|
||||
if (type is DynamicType) {
|
||||
// Ensure it's at least a Stream / Iterable.
|
||||
return expectedElement.instantiate(
|
||||
typeArguments: [_typeProvider.dynamicType],
|
||||
@@ -606,7 +606,7 @@ class CodeChecker extends RecursiveAstVisitor {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
if (type.isDynamic) {
|
||||
if (type is DynamicType) {
|
||||
return type;
|
||||
} else if (type is InterfaceType && type.element == expectedElement) {
|
||||
return type.typeArguments[0];
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
name: analyzer
|
||||
version: 5.11.1
|
||||
version: 5.12.0-dev
|
||||
description: >-
|
||||
This package provides a library that performs static analysis of Dart code.
|
||||
repository: https://github.com/dart-lang/sdk/tree/main/pkg/analyzer
|
||||
|
||||
@@ -70,7 +70,7 @@ class ResolutionVerifier extends RecursiveAstVisitor<void> {
|
||||
return;
|
||||
}
|
||||
var operandType = node.leftOperand.staticType;
|
||||
if (operandType == null || operandType.isDynamic) {
|
||||
if (operandType == null || operandType is DynamicType) {
|
||||
return;
|
||||
}
|
||||
_checkResolved(node, node.staticElement, (node) => node is MethodElement);
|
||||
@@ -124,7 +124,7 @@ class ResolutionVerifier extends RecursiveAstVisitor<void> {
|
||||
void visitIndexExpression(IndexExpression node) {
|
||||
node.visitChildren(this);
|
||||
var targetType = node.realTarget.staticType;
|
||||
if (targetType == null || targetType.isDynamic) {
|
||||
if (targetType == null || targetType is DynamicType) {
|
||||
return;
|
||||
}
|
||||
var parent = node.parent;
|
||||
@@ -162,7 +162,7 @@ class ResolutionVerifier extends RecursiveAstVisitor<void> {
|
||||
return;
|
||||
}
|
||||
var operandType = node.operand.staticType;
|
||||
if (operandType == null || operandType.isDynamic) {
|
||||
if (operandType == null || operandType is DynamicType) {
|
||||
return;
|
||||
}
|
||||
_checkResolved(node, node.staticElement, (node) => node is MethodElement);
|
||||
@@ -173,7 +173,7 @@ class ResolutionVerifier extends RecursiveAstVisitor<void> {
|
||||
SimpleIdentifier prefix = node.prefix;
|
||||
prefix.accept(this);
|
||||
var prefixType = prefix.staticType;
|
||||
if (prefixType == null || prefixType.isDynamic) {
|
||||
if (prefixType == null || prefixType is DynamicType) {
|
||||
return;
|
||||
}
|
||||
_checkResolved(node, node.staticElement, null);
|
||||
@@ -186,7 +186,7 @@ class ResolutionVerifier extends RecursiveAstVisitor<void> {
|
||||
return;
|
||||
}
|
||||
var operandType = node.operand.staticType;
|
||||
if (operandType == null || operandType.isDynamic) {
|
||||
if (operandType == null || operandType is DynamicType) {
|
||||
return;
|
||||
}
|
||||
_checkResolved(node, node.staticElement, (node) => node is MethodElement);
|
||||
@@ -197,7 +197,7 @@ class ResolutionVerifier extends RecursiveAstVisitor<void> {
|
||||
Expression target = node.realTarget;
|
||||
target.accept(this);
|
||||
var targetType = target.staticType;
|
||||
if (targetType == null || targetType.isDynamic) {
|
||||
if (targetType == null || targetType is DynamicType) {
|
||||
return;
|
||||
}
|
||||
var parent = node.parent;
|
||||
@@ -218,9 +218,7 @@ class ResolutionVerifier extends RecursiveAstVisitor<void> {
|
||||
}
|
||||
|
||||
var staticType = node.staticType;
|
||||
if (staticType != null &&
|
||||
staticType.isDynamic &&
|
||||
node.staticElement == null) {
|
||||
if (staticType is DynamicType && node.staticElement == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -233,7 +231,7 @@ class ResolutionVerifier extends RecursiveAstVisitor<void> {
|
||||
if (identical(invocation.methodName, node)) {
|
||||
var target = invocation.realTarget;
|
||||
var targetType = target?.staticType;
|
||||
if (targetType == null || targetType.isDynamic) {
|
||||
if (targetType == null || targetType is DynamicType) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ class DartEditBuilderImpl extends EditBuilderImpl implements DartEditBuilder {
|
||||
|
||||
@override
|
||||
bool canWriteType(DartType? type, {ExecutableElement? methodBeingCopied}) =>
|
||||
type != null && !type.isDynamic
|
||||
type != null && type is! DynamicType
|
||||
? _canWriteType(type, methodBeingCopied: methodBeingCopied)
|
||||
: false;
|
||||
|
||||
@@ -273,7 +273,7 @@ class DartEditBuilderImpl extends EditBuilderImpl implements DartEditBuilder {
|
||||
write(Keyword.STATIC.lexeme);
|
||||
write(' ');
|
||||
}
|
||||
if (returnType != null && !returnType.isDynamic) {
|
||||
if (returnType != null && returnType is! DynamicType) {
|
||||
if (writeType(returnType, groupName: returnTypeGroupName)) {
|
||||
write(' ');
|
||||
}
|
||||
@@ -730,7 +730,7 @@ class DartEditBuilderImpl extends EditBuilderImpl implements DartEditBuilder {
|
||||
write(name);
|
||||
}
|
||||
write('(');
|
||||
if (parameterType != null && !parameterType.isDynamic) {
|
||||
if (parameterType != null && parameterType is! DynamicType) {
|
||||
if (writeType(parameterType, groupName: parameterTypeGroupName)) {
|
||||
write(' ');
|
||||
}
|
||||
@@ -753,7 +753,7 @@ class DartEditBuilderImpl extends EditBuilderImpl implements DartEditBuilder {
|
||||
ExecutableElement? methodBeingCopied,
|
||||
bool required = false}) {
|
||||
var wroteType = false;
|
||||
if (type != null && !type.isDynamic) {
|
||||
if (type != null && type is! DynamicType) {
|
||||
if (groupName != null) {
|
||||
addLinkedEdit(groupName, (LinkedEditBuilder builder) {
|
||||
wroteType = _writeType(type, methodBeingCopied: methodBeingCopied);
|
||||
@@ -879,7 +879,7 @@ class DartEditBuilderImpl extends EditBuilderImpl implements DartEditBuilder {
|
||||
if (type == null) {
|
||||
return false;
|
||||
}
|
||||
if (type.isDynamic) {
|
||||
if (type is DynamicType) {
|
||||
if (required) {
|
||||
return true;
|
||||
}
|
||||
@@ -1092,7 +1092,7 @@ class DartEditBuilderImpl extends EditBuilderImpl implements DartEditBuilder {
|
||||
}
|
||||
}
|
||||
// use type
|
||||
if (expectedType != null && !expectedType.isDynamic) {
|
||||
if (expectedType != null && expectedType is! DynamicType) {
|
||||
if (expectedType.isDartCoreInt) {
|
||||
_addSingleCharacterName(excluded, res, $i);
|
||||
} else if (expectedType.isDartCoreDouble) {
|
||||
@@ -1223,7 +1223,7 @@ class DartEditBuilderImpl extends EditBuilderImpl implements DartEditBuilder {
|
||||
if (type == null) {
|
||||
return false;
|
||||
}
|
||||
if (type.isDynamic) {
|
||||
if (type is DynamicType) {
|
||||
if (required) {
|
||||
write('dynamic');
|
||||
return true;
|
||||
@@ -1360,7 +1360,7 @@ class DartEditBuilderImpl extends EditBuilderImpl implements DartEditBuilder {
|
||||
var hasArguments = false;
|
||||
var allArgumentsVisible = true;
|
||||
for (var argument in typeArguments) {
|
||||
hasArguments = hasArguments || !argument.isDynamic;
|
||||
hasArguments = hasArguments || argument is! DynamicType;
|
||||
allArgumentsVisible = allArgumentsVisible &&
|
||||
_getVisibleType(argument, methodBeingCopied: methodBeingCopied) !=
|
||||
null;
|
||||
@@ -1628,7 +1628,7 @@ class DartFileEditBuilderImpl extends FileEditBuilderImpl
|
||||
// Check whether the type needs to be replaced.
|
||||
//
|
||||
var type = typeAnnotation?.type;
|
||||
if (type == null || type.isDynamic || type.isDartAsyncFuture) {
|
||||
if (type == null || type is DynamicType || type.isDartAsyncFuture) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ class TypeMemberContributor implements CompletionContributor {
|
||||
|
||||
// Determine the target expression's type
|
||||
var type = expression.staticType;
|
||||
if (type == null || type.isDynamic) {
|
||||
if (type == null || type is DynamicType) {
|
||||
// If the expression does not provide a good type
|
||||
// then attempt to get a better type from the element
|
||||
if (expression is Identifier) {
|
||||
@@ -87,7 +87,7 @@ class TypeMemberContributor implements CompletionContributor {
|
||||
} else if (elem is LocalVariableElement) {
|
||||
type = elem.type;
|
||||
}
|
||||
if ((type == null || type.isDynamic) &&
|
||||
if ((type == null || type is DynamicType) &&
|
||||
expression is SimpleIdentifier) {
|
||||
// If the element does not provide a good type
|
||||
// then attempt to get a better type from a local declaration
|
||||
@@ -111,7 +111,7 @@ class TypeMemberContributor implements CompletionContributor {
|
||||
containingMethodName = id.lexeme;
|
||||
}
|
||||
}
|
||||
if (type == null || type.isDynamic) {
|
||||
if (type == null || type is DynamicType) {
|
||||
// Suggest members from object if target is "dynamic"
|
||||
type = request.result.typeProvider.objectType;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ class AlreadyMigratedCodeDecorator {
|
||||
/// TODO(paulberry): do we still need element or can we use target now?
|
||||
DecoratedType decorate(
|
||||
DartType type, Element element, NullabilityNodeTarget target) {
|
||||
if (type is VoidType || type.isDynamic) {
|
||||
if (type is VoidType || type is DynamicType) {
|
||||
var node = NullabilityNode.forAlreadyMigrated(target);
|
||||
_graph.makeNullableUnion(
|
||||
node, AlwaysNullableTypeOrigin.forElement(element, type is VoidType));
|
||||
|
||||
@@ -450,7 +450,7 @@ class DecoratedType implements DecoratedTypeInfo, SubstitutedType {
|
||||
} else {
|
||||
return inner._performSubstitution(this, undecoratedResult!);
|
||||
}
|
||||
} else if (type is VoidType || type!.isDynamic) {
|
||||
} else if (type is VoidType || type is DynamicType) {
|
||||
return this;
|
||||
}
|
||||
throw '$type.substitute($type | $substitution)'; // TODO(paulberry)
|
||||
|
||||
@@ -2275,7 +2275,7 @@ class EdgeBuilder extends GeneralizingAstVisitor<DecoratedType>
|
||||
? NullabilityNode.forLUB(left.node, right.node)
|
||||
: _nullabilityNodeForGLB(astNode, left.node, right.node);
|
||||
|
||||
if (type!.isDynamic || type is VoidType) {
|
||||
if (type is DynamicType || type is VoidType) {
|
||||
return DecoratedType(type, node);
|
||||
} else if (leftType!.isBottom) {
|
||||
return right.withNode(node);
|
||||
@@ -3439,7 +3439,7 @@ class EdgeBuilder extends GeneralizingAstVisitor<DecoratedType>
|
||||
|
||||
EdgeOrigin _makeEdgeOrigin(DecoratedType sourceType, Expression expression,
|
||||
{bool isSetupAssignment = false}) {
|
||||
if (sourceType.type!.isDynamic) {
|
||||
if (sourceType.type is DynamicType) {
|
||||
return DynamicAssignmentOrigin(source, expression,
|
||||
isSetupAssignment: isSetupAssignment);
|
||||
} else {
|
||||
@@ -3913,7 +3913,7 @@ mixin _AssignmentChecker {
|
||||
hard: false);
|
||||
return;
|
||||
}
|
||||
} else if (destinationType.isDynamic ||
|
||||
} else if (destinationType is DynamicType ||
|
||||
destinationType is VoidType ||
|
||||
destinationType.isDartCoreObject) {
|
||||
// No further edges need to be created, since all types are trivially
|
||||
@@ -3965,7 +3965,7 @@ mixin _AssignmentChecker {
|
||||
hard: false,
|
||||
checkable: false);
|
||||
}
|
||||
} else if (destinationType.isDynamic || sourceType.isDynamic) {
|
||||
} else if (destinationType is DynamicType || sourceType is DynamicType) {
|
||||
// ok; nothing further to do.
|
||||
} else if (destinationType is InterfaceType && sourceType is FunctionType) {
|
||||
// Either this is an upcast to Function or Object, or it is erroneous
|
||||
@@ -3986,7 +3986,7 @@ mixin _AssignmentChecker {
|
||||
_connect(source.node, destination.node, origin, FixReasonTarget.root,
|
||||
hard: hard);
|
||||
|
||||
if (sourceType.isDynamic ||
|
||||
if (sourceType is DynamicType ||
|
||||
sourceType.isDartCoreObject ||
|
||||
sourceType is VoidType) {
|
||||
if (destinationType is InterfaceType) {
|
||||
|
||||
@@ -120,7 +120,7 @@ class FixAggregator extends UnifyingAstVisitor<void> {
|
||||
String typeFormalToCode(TypeParameterElement formal) {
|
||||
var bound = formal.bound;
|
||||
if (bound == null ||
|
||||
bound.isDynamic ||
|
||||
bound is DynamicType ||
|
||||
(bound.isDartCoreObject &&
|
||||
bound.nullabilitySuffix != NullabilitySuffix.none)) {
|
||||
return formal.name;
|
||||
|
||||
@@ -472,7 +472,7 @@ class MigrationResolutionHooksImpl
|
||||
.decoratedTypeParameterBound(element, allowNullUnparentedBounds: true);
|
||||
if (decoratedBound == null) return element.boundInternal;
|
||||
var bound = _fixBuilder._variables!.toFinalType(decoratedBound);
|
||||
if (bound.isDynamic) {
|
||||
if (bound is DynamicType) {
|
||||
return null;
|
||||
} else if (bound.isDartCoreObject &&
|
||||
bound.nullabilitySuffix == NullabilitySuffix.question) {
|
||||
@@ -807,7 +807,7 @@ class MigrationResolutionHooksImpl
|
||||
hintComment: hint),
|
||||
hint: hint);
|
||||
}
|
||||
if (type.isDynamic) return type;
|
||||
if (type is DynamicType) return type;
|
||||
var ancestor = _findNullabilityContextAncestor(node);
|
||||
context ??= _contextTypes[ancestor] ?? DynamicTypeImpl.instance;
|
||||
if (!_isSubtypeOrCoercible(type, context)) {
|
||||
@@ -1082,7 +1082,7 @@ abstract class _AssignmentLikeExpressionHandler {
|
||||
.isWeakNullAware = true;
|
||||
}
|
||||
} else {
|
||||
if (!readType!.isDynamic &&
|
||||
if (readType is! DynamicType &&
|
||||
fixBuilder._typeSystem.isPotentiallyNullable(readType!)) {
|
||||
(fixBuilder._getChange(node) as NodeChangeForAssignmentLike)
|
||||
.hasNullableSource = true;
|
||||
@@ -1460,7 +1460,7 @@ class _FixBuilderPreVisitor extends GeneralizingAstVisitor<void>
|
||||
}
|
||||
|
||||
bool _typeIsNaturallyNullable(DartType type) =>
|
||||
type.isDynamic || type is VoidType || type.isDartCoreNull;
|
||||
type is DynamicType || type is VoidType || type.isDartCoreNull;
|
||||
}
|
||||
|
||||
/// Specialization of [_AssignmentLikeExpressionHandler] for
|
||||
|
||||
@@ -531,7 +531,7 @@ class NodeBuilder extends GeneralizingAstVisitor<DecoratedType>
|
||||
DecoratedType visitTypeAnnotation(TypeAnnotation node) {
|
||||
var type = node.type!;
|
||||
var target = safeTarget.withCodeRef(node);
|
||||
if (type is VoidType || type.isDynamic) {
|
||||
if (type is VoidType || type is DynamicType) {
|
||||
var nullabilityNode = NullabilityNode.forTypeAnnotation(target);
|
||||
var decoratedType = DecoratedType(type, nullabilityNode);
|
||||
_variables.recordDecoratedTypeAnnotation(source, node, decoratedType);
|
||||
@@ -777,7 +777,7 @@ class NodeBuilder extends GeneralizingAstVisitor<DecoratedType>
|
||||
decoratedReturnType = DecoratedType.forImplicitType(
|
||||
_typeProvider, functionType.returnType, _graph, target);
|
||||
instrumentation?.implicitReturnType(source, node, decoratedReturnType);
|
||||
if (isExternal && functionType.returnType.isDynamic) {
|
||||
if (isExternal && functionType.returnType is DynamicType) {
|
||||
_graph.makeNullableUnion(
|
||||
decoratedReturnType.node, ExternalDynamicOrigin(source, node));
|
||||
}
|
||||
|
||||
@@ -297,7 +297,7 @@ class Variables {
|
||||
/// types should be nullable and which types should not.
|
||||
DartType toFinalType(DecoratedType decoratedType) {
|
||||
var type = decoratedType.type!;
|
||||
if (type is VoidType || type.isDynamic) return type;
|
||||
if (type is VoidType || type is DynamicType) return type;
|
||||
if (type is NeverType) {
|
||||
if (decoratedType.node.isNullable) {
|
||||
return (_typeProvider.nullType as TypeImpl)
|
||||
|
||||
@@ -1084,7 +1084,7 @@ typedef F();
|
||||
''');
|
||||
var decoratedType = variables
|
||||
.decoratedElementType(findElement.typeAlias('F').aliasedElement!);
|
||||
expect(decoratedType.returnType!.type!.isDynamic, isTrue);
|
||||
expect(decoratedType.returnType!.type is DynamicType, isTrue);
|
||||
expect(decoratedType.returnType!.node.isImmutable, false);
|
||||
expect(decoratedType.typeFormals, isEmpty);
|
||||
}
|
||||
@@ -1347,7 +1347,7 @@ typedef F = Function();
|
||||
.decoratedElementType(findElement.typeAlias('F').aliasedElement!);
|
||||
expect(decoratedType,
|
||||
same(decoratedGenericFunctionTypeAnnotation('Function')));
|
||||
expect(decoratedType.returnType!.type!.isDynamic, isTrue);
|
||||
expect(decoratedType.returnType!.type is DynamicType, isTrue);
|
||||
expect(decoratedType.returnType!.node.isImmutable, false);
|
||||
expect(decoratedType.typeFormals, isEmpty);
|
||||
}
|
||||
@@ -1808,7 +1808,7 @@ void f(x) {}
|
||||
findNode.simpleFormalParameter('x').declaredElement!);
|
||||
expect(decoratedFunctionType('f').positionalParameters![0],
|
||||
same(decoratedType));
|
||||
expect(decoratedType.type!.isDynamic, isTrue);
|
||||
expect(decoratedType.type is DynamicType, isTrue);
|
||||
}
|
||||
|
||||
Future<void> test_topLevelFunction_parameterType_named_no_default() async {
|
||||
@@ -1897,7 +1897,7 @@ void f(int i) {}
|
||||
f() {}
|
||||
''');
|
||||
var decoratedType = decoratedFunctionType('f').returnType!;
|
||||
expect(decoratedType.type!.isDynamic, isTrue);
|
||||
expect(decoratedType.type is DynamicType, isTrue);
|
||||
}
|
||||
|
||||
Future<void> test_topLevelFunction_returnType_simple() async {
|
||||
|
||||
Reference in New Issue
Block a user