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

Commit 4e52082

Browse files
scheglovcommit-bot@chromium.org
authored andcommitted
Deprecated DartType.isObject
R=brianwilkerson@google.com Change-Id: If588b23668764b07c99e327281bfeb11c8e31367 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/147423 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
1 parent 1120d64 commit 4e52082

File tree

13 files changed

+24
-17
lines changed

13 files changed

+24
-17
lines changed

pkg/analyzer/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.39.9-dev
2+
* Deprecated `DartType.isObject`, use `DartType.isDartCoreObject` for
3+
consistency with other similar getters.
4+
15
## 0.39.8
26
* Deprecated `VariableElement.constantValue`, it does not guarantee that
37
the value has been computed. Use `computeConstantValue()` instead.

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ abstract class DartType {
104104
bool get isDynamic;
105105

106106
/// Return `true` if this type represents the type 'Object'.
107+
@Deprecated('Use isDartCoreObject')
107108
bool get isObject;
108109

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

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ class ConstantEvaluationEngine {
356356
// manually insert a reference to the implicit superconstructor.
357357
InterfaceType superclass =
358358
(constant.returnType as InterfaceType).superclass;
359-
if (superclass != null && !superclass.isObject) {
359+
if (superclass != null && !superclass.isDartCoreObject) {
360360
ConstructorElement unnamedConstructor =
361361
superclass.element.unnamedConstructor?.declaration;
362362
if (unnamedConstructor != null) {
@@ -736,7 +736,7 @@ class ConstantEvaluationEngine {
736736
}
737737
// Evaluate explicit or implicit call to super().
738738
InterfaceType superclass = definingClass.superclass;
739-
if (superclass != null && !superclass.isObject) {
739+
if (superclass != null && !superclass.isDartCoreObject) {
740740
ConstructorElement superConstructor =
741741
superclass.lookUpConstructor(superName, constructor.library);
742742
if (superConstructor != null) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,7 @@ class ClassElementImpl extends AbstractClassElementImpl
777777
if (hasReferenceToSuper) {
778778
return false;
779779
}
780-
if (!supertype.isObject) {
780+
if (!supertype.isDartCoreObject) {
781781
return false;
782782
}
783783
for (ConstructorElement constructor in constructors) {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ bool _isLegacyTop(DartType t, {@required bool orTrueTop}) {
3939
return _isLegacyTop((t as InterfaceType).typeArguments[0],
4040
orTrueTop: orTrueTop);
4141
}
42-
if (t.isObject && t.nullabilitySuffix == NullabilitySuffix.none) {
42+
if (t.isDartCoreObject && t.nullabilitySuffix == NullabilitySuffix.none) {
4343
return true;
4444
}
4545
return orTrueTop ? _isTop(t) : false;
@@ -50,7 +50,7 @@ bool _isTop(DartType t) {
5050
return _isTop((t as InterfaceType).typeArguments[0]);
5151
}
5252
return t.isDynamic ||
53-
(t.isObject && t.nullabilitySuffix != NullabilitySuffix.none) ||
53+
(t.isDartCoreObject && t.nullabilitySuffix != NullabilitySuffix.none) ||
5454
t.isVoid ||
5555
identical(t, UnknownInferredType.instance);
5656
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,12 +445,12 @@ class SubtypeHelper {
445445
// Note: we should never reach `_isInterfaceSubtypeOf` with `i2 == Object`,
446446
// because top types are eliminated before `isSubtypeOf` calls this.
447447
// TODO(scheglov) Replace with assert().
448-
if (identical(subType, superType) || superType.isObject) {
448+
if (identical(subType, superType) || superType.isDartCoreObject) {
449449
return true;
450450
}
451451

452452
// Object cannot subtype anything but itself (handled above).
453-
if (subType.isObject) {
453+
if (subType.isDartCoreObject) {
454454
return false;
455455
}
456456

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ class FunctionTypeImpl extends TypeImpl implements FunctionType {
416416
} else if (identical(t, other) ||
417417
other.isDynamic ||
418418
other.isDartCoreFunction ||
419-
other.isObject) {
419+
other.isDartCoreObject) {
420420
return true;
421421
} else if (other is! FunctionType) {
422422
return false;
@@ -830,6 +830,7 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType {
830830
return element.name == "Symbol" && element.library.isDartCore;
831831
}
832832

833+
@Deprecated('Use isDartCoreObject')
833834
@override
834835
bool get isObject => element.supertype == null && !element.isMixin;
835836

@@ -1837,6 +1838,7 @@ abstract class TypeImpl implements DartType {
18371838
@override
18381839
bool get isDynamic => false;
18391840

1841+
@Deprecated('Use isDartCoreObject')
18401842
@override
18411843
bool get isObject => false;
18421844

pkg/analyzer/lib/src/error/best_practices_verifier.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ class BestPracticesVerifier extends RecursiveAstVisitor<void> {
658658
return true;
659659
}
660660
// `is Object` or `is! Object`
661-
if (rhsType.isObject) {
661+
if (rhsType.isDartCoreObject) {
662662
var nullability = rhsType.nullabilitySuffix;
663663
if (nullability == NullabilitySuffix.star ||
664664
nullability == NullabilitySuffix.question) {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1928,7 +1928,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void> {
19281928
if (supertype == null) {
19291929
return;
19301930
}
1931-
if (supertype.isObject) {
1931+
if (supertype.isDartCoreObject) {
19321932
return;
19331933
}
19341934
ConstructorElement unnamedConstructor =
@@ -3249,7 +3249,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void> {
32493249
TypeName mixinName, ClassElement mixinElement) {
32503250
InterfaceType mixinSupertype = mixinElement.supertype;
32513251
if (mixinSupertype != null) {
3252-
if (!mixinSupertype.isObject ||
3252+
if (!mixinSupertype.isDartCoreObject ||
32533253
!mixinElement.isMixinApplication && mixinElement.mixins.isNotEmpty) {
32543254
_errorReporter.reportErrorForNode(
32553255
CompileTimeErrorCode.MIXIN_INHERITS_FROM_NOT_OBJECT,

pkg/analyzer/test/src/dart/resolution/mixin_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ mixin M {}
144144
expect(element.isEnum, isFalse);
145145
expect(element.isMixin, isTrue);
146146
expect(element.isMixinApplication, isFalse);
147-
expect(interfaceTypeStar(element).isObject, isFalse);
147+
expect(interfaceTypeStar(element).isDartCoreObject, isFalse);
148148
expect(element.isDartCoreObject, isFalse);
149149

150150
assertElementTypes(element.superclassConstraints, [objectType]);

0 commit comments

Comments
 (0)