Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 92729e0

Browse files
scheglovcommit-bot@chromium.org
authored andcommitted
Remove UndefinedTypeImpl.
And corresponding DartType.isUndefined as well. R=brianwilkerson@google.com, paulberry@google.com Change-Id: I85debe627e989b5a5671becf5d9dd16413562236 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/99729 Commit-Queue: Konstantin Shcheglov <scheglov@google.com> Reviewed-by: Paul Berry <paulberry@google.com> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
1 parent cf77b82 commit 92729e0

15 files changed

Lines changed: 29 additions & 161 deletions

File tree

pkg/analysis_server/lib/src/services/completion/dart/utilities.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ String nameForType(SimpleIdentifier identifier, TypeAnnotation declaredType) {
213213
}
214214

215215
// If the type is unresolved, use the declared type.
216-
if (type != null && type.isUndefined) {
216+
if (type != null && type.isDynamic) {
217217
if (declaredType is TypeName) {
218218
Identifier id = declaredType.name;
219219
if (id != null) {

pkg/analyzer/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 0.36.1
2+
* Deprecated `DartType.isUndefined`, and now it always returns `false`.
3+
14
## 0.36.0
25
* Changed the return type of `Expression.precendence` to `Precedence`. Clients
36
that prepared for this change by switching to `Expression.precedence2` should

pkg/analyzer/lib/dart/element/type.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ abstract class DartType {
8080

8181
/// Return `true` if this type represents a typename that couldn't be
8282
/// resolved.
83+
@deprecated
8384
bool get isUndefined;
8485

8586
/// Return `true` if this type represents the type 'void'.

pkg/analyzer/lib/src/dart/constant/evaluation.dart

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -902,9 +902,6 @@ class ConstantEvaluationEngine {
902902
if (obj.isNull) {
903903
return true;
904904
}
905-
if (type.isUndefined) {
906-
return false;
907-
}
908905
var objType = obj.type;
909906
if (objType.isDartCoreInt && type.isDartCoreDouble) {
910907
// Work around dartbug.com/35993 by allowing `int` to be used in a place

pkg/analyzer/lib/src/dart/element/type.dart

Lines changed: 0 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -3264,87 +3264,6 @@ class TypeParameterTypeImpl extends TypeImpl implements TypeParameterType {
32643264
}
32653265
}
32663266

3267-
/**
3268-
* The unique instance of the class `UndefinedTypeImpl` implements the type of
3269-
* type names that couldn't be resolved.
3270-
*
3271-
* This class behaves like DynamicTypeImpl in almost every respect, to reduce
3272-
* cascading errors.
3273-
*/
3274-
class UndefinedTypeImpl extends TypeImpl {
3275-
/**
3276-
* The unique instance of this class.
3277-
*/
3278-
static final UndefinedTypeImpl instance = new UndefinedTypeImpl._();
3279-
3280-
/**
3281-
* Prevent the creation of instances of this class.
3282-
*/
3283-
UndefinedTypeImpl._()
3284-
: super(DynamicElementImpl.instance, Keyword.DYNAMIC.lexeme);
3285-
3286-
@override
3287-
int get hashCode => 1;
3288-
3289-
@override
3290-
bool get isDynamic => true;
3291-
3292-
@override
3293-
bool get isUndefined => true;
3294-
3295-
@override
3296-
NullabilitySuffix get nullabilitySuffix => NullabilitySuffix.star;
3297-
3298-
@override
3299-
bool operator ==(Object object) => identical(object, this);
3300-
3301-
@override
3302-
bool isMoreSpecificThan(DartType type,
3303-
[bool withDynamic = false, Set<Element> visitedElements]) {
3304-
// T is S
3305-
if (identical(this, type)) {
3306-
return true;
3307-
}
3308-
// else
3309-
return withDynamic;
3310-
}
3311-
3312-
@override
3313-
bool isSubtypeOf(DartType type) => true;
3314-
3315-
@override
3316-
bool isSupertypeOf(DartType type) => true;
3317-
3318-
@override
3319-
TypeImpl pruned(List<FunctionTypeAliasElement> prune) => this;
3320-
3321-
@override
3322-
DartType replaceTopAndBottom(TypeProvider typeProvider,
3323-
{bool isCovariant = true}) {
3324-
if (isCovariant) {
3325-
return typeProvider.nullType;
3326-
} else {
3327-
return this;
3328-
}
3329-
}
3330-
3331-
@override
3332-
DartType substitute2(
3333-
List<DartType> argumentTypes, List<DartType> parameterTypes,
3334-
[List<FunctionTypeAliasElement> prune]) {
3335-
int length = parameterTypes.length;
3336-
for (int i = 0; i < length; i++) {
3337-
if (parameterTypes[i] == this) {
3338-
return argumentTypes[i];
3339-
}
3340-
}
3341-
return this;
3342-
}
3343-
3344-
@override
3345-
TypeImpl withNullability(NullabilitySuffix nullabilitySuffix) => this;
3346-
}
3347-
33483267
/**
33493268
* The type `void`.
33503269
*/

pkg/analyzer/lib/src/generated/declaration_resolver.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ class DeclarationResolver extends RecursiveAstVisitor<void> {
735735
/// corresponding type arguments of the [typeArguments].
736736
static void _applyTypeArgumentsToList(LibraryElement enclosingLibraryElement,
737737
DartType type, List<TypeAnnotation> typeArguments) {
738-
if (type != null && type.isUndefined) {
738+
if (type != null && type.isDynamic) {
739739
for (TypeAnnotation argument in typeArguments) {
740740
applyToTypeAnnotation(enclosingLibraryElement, type, argument);
741741
}

pkg/analyzer/lib/src/generated/resolver.dart

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6255,7 +6255,6 @@ class ToDoFinder {
62556255
class TypeNameResolver {
62566256
final TypeSystem typeSystem;
62576257
final DartType dynamicType;
6258-
final DartType undefinedType;
62596258
final bool isNonNullableUnit;
62606259
final AnalysisOptionsImpl analysisOptions;
62616260
final LibraryElement definingLibrary;
@@ -6280,7 +6279,6 @@ class TypeNameResolver {
62806279
this.errorListener,
62816280
{this.shouldUseWithClauseInferredTypes: true})
62826281
: dynamicType = typeProvider.dynamicType,
6283-
undefinedType = typeProvider.undefinedType,
62846282
analysisOptions = definingLibrary.context.analysisOptions;
62856283

62866284
/// Report an error with the given error code and arguments.
@@ -6322,8 +6320,8 @@ class TypeNameResolver {
63226320
return;
63236321
}
63246322
if (nameScope.shouldIgnoreUndefined(typeName)) {
6325-
typeName.staticType = undefinedType;
6326-
node.type = undefinedType;
6323+
typeName.staticType = dynamicType;
6324+
node.type = dynamicType;
63276325
return;
63286326
}
63296327
//
@@ -6343,8 +6341,8 @@ class TypeNameResolver {
63436341
element = nameScope.lookup(prefix, definingLibrary);
63446342
if (element is PrefixElement) {
63456343
if (nameScope.shouldIgnoreUndefined(typeName)) {
6346-
typeName.staticType = undefinedType;
6347-
node.type = undefinedType;
6344+
typeName.staticType = dynamicType;
6345+
node.type = dynamicType;
63486346
return;
63496347
}
63506348
AstNode grandParent = parent.parent;
@@ -6382,8 +6380,8 @@ class TypeNameResolver {
63826380
}
63836381
}
63846382
if (nameScope.shouldIgnoreUndefined(typeName)) {
6385-
typeName.staticType = undefinedType;
6386-
node.type = undefinedType;
6383+
typeName.staticType = dynamicType;
6384+
node.type = dynamicType;
63876385
return;
63886386
}
63896387
}
@@ -6500,8 +6498,8 @@ class TypeNameResolver {
65006498
if (element is MultiplyDefinedElement) {
65016499
_setElement(typeName, element);
65026500
}
6503-
typeName.staticType = undefinedType;
6504-
node.type = undefinedType;
6501+
typeName.staticType = dynamicType;
6502+
node.type = dynamicType;
65056503
return;
65066504
}
65076505

@@ -6674,7 +6672,7 @@ class TypeNameResolver {
66746672
DartType _getType(TypeAnnotation annotation) {
66756673
DartType type = annotation.type;
66766674
if (type == null) {
6677-
return undefinedType;
6675+
return dynamicType;
66786676
}
66796677
return type;
66806678
}
@@ -7231,9 +7229,6 @@ abstract class TypeProvider {
72317229
/// Return the type representing the built-in type 'Type'.
72327230
InterfaceType get typeType;
72337231

7234-
/// Return the type representing typenames that can't be resolved.
7235-
DartType get undefinedType;
7236-
72377232
/// Return 'true' if [id] is the name of a getter on
72387233
/// the Object type.
72397234
bool isObjectGetter(String id);
@@ -7372,9 +7367,6 @@ class TypeProviderImpl extends TypeProviderBase {
73727367
/// The type representing the built-in type 'Type'.
73737368
InterfaceType _typeType;
73747369

7375-
/// The type representing typenames that can't be resolved.
7376-
DartType _undefinedType;
7377-
73787370
/// Initialize a newly created type provider to provide the types defined in
73797371
/// the given [coreLibrary] and [asyncLibrary].
73807372
TypeProviderImpl(LibraryElement coreLibrary, LibraryElement asyncLibrary) {
@@ -7476,9 +7468,6 @@ class TypeProviderImpl extends TypeProviderBase {
74767468
@override
74777469
InterfaceType get typeType => _typeType;
74787470

7479-
@override
7480-
DartType get undefinedType => _undefinedType;
7481-
74827471
InterfaceType _createNever(Namespace namespace) {
74837472
// TODO(brianwilkerson) Remove this method when the class is defined in the
74847473
// SDK.
@@ -7533,7 +7522,6 @@ class TypeProviderImpl extends TypeProviderBase {
75337522
_stringType = _getType(coreNamespace, 'String');
75347523
_symbolType = _getType(coreNamespace, 'Symbol');
75357524
_typeType = _getType(coreNamespace, 'Type');
7536-
_undefinedType = UndefinedTypeImpl.instance;
75377525
_futureDynamicType = _futureType.instantiate(<DartType>[_dynamicType]);
75387526
_futureNullType = _futureType.instantiate(<DartType>[_nullType]);
75397527
_iterableDynamicType = _iterableType.instantiate(<DartType>[_dynamicType]);
@@ -7587,9 +7575,6 @@ class TypeResolverVisitor extends ScopedVisitor {
75877575
/// The type representing the type 'dynamic'.
75887576
DartType _dynamicType;
75897577

7590-
/// The type representing typenames that can't be resolved.
7591-
DartType _undefinedType;
7592-
75937578
/// The flag specifying if currently visited class references 'super'
75947579
/// expression.
75957580
bool _hasReferenceToSuper = false;
@@ -7645,7 +7630,6 @@ class TypeResolverVisitor extends ScopedVisitor {
76457630
: super(definingLibrary, source, typeProvider, errorListener,
76467631
nameScope: nameScope) {
76477632
_dynamicType = typeProvider.dynamicType;
7648-
_undefinedType = typeProvider.undefinedType;
76497633
_typeSystem = TypeSystem.create(definingLibrary.context);
76507634
_typeNameResolver = new TypeNameResolver(_typeSystem, typeProvider,
76517635
isNonNullableUnit, definingLibrary, source, errorListener,

pkg/analyzer/lib/src/generated/testing/test_type_provider.dart

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,6 @@ class TestTypeProvider extends TypeProviderBase {
178178
*/
179179
InterfaceType _typeType;
180180

181-
/**
182-
* The type representing type names that can't be resolved.
183-
*/
184-
DartType _undefinedType;
185-
186181
/**
187182
* The analysis context, if any. Used to create an appropriate 'dart:async'
188183
* library to back `Future<T>`.
@@ -612,14 +607,6 @@ class TestTypeProvider extends TypeProviderBase {
612607
return _typeType;
613608
}
614609

615-
@override
616-
DartType get undefinedType {
617-
if (_undefinedType == null) {
618-
_undefinedType = UndefinedTypeImpl.instance;
619-
}
620-
return _undefinedType;
621-
}
622-
623610
void _initDartAsync() {
624611
Source asyncSource;
625612
if (_driver != null) {

pkg/analyzer/lib/src/summary/link.dart

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5481,9 +5481,6 @@ class TypeProviderForLink extends TypeProviderBase {
54815481
InterfaceType get typeType =>
54825482
_typeType ??= _buildInterfaceType(_linker.coreLibrary, 'Type');
54835483

5484-
@override
5485-
DartType get undefinedType => UndefinedTypeImpl.instance;
5486-
54875484
InterfaceType _buildInterfaceType(
54885485
LibraryElementForLink library, String name) {
54895486
return library.getContainedName(name).buildType((int i) {

pkg/analyzer/lib/src/summary/resynthesize.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1491,7 +1491,7 @@ class _UnitResynthesizer extends UnitResynthesizer with UnitResynthesizerMixin {
14911491
bool isDeclarableType = false;
14921492
int numTypeParameters = linkedReference.numTypeParameters;
14931493
if (linkedReference.kind == ReferenceKind.unresolved) {
1494-
type = UndefinedTypeImpl.instance;
1494+
type = DynamicTypeImpl.instance;
14951495
element = null;
14961496
isDeclarableType = true;
14971497
} else if (name == 'dynamic') {

0 commit comments

Comments
 (0)