Skip to content

Commit 9280712

Browse files
committed
Change ConstructorElement.returnType to InterfaceType.
[email protected] Change-Id: I3f2605b26cc953d707dc5c37b690ec0438a99b3c Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153621 Reviewed-by: Brian Wilkerson <[email protected]>
1 parent 8b9f920 commit 9280712

File tree

5 files changed

+12
-13
lines changed

5 files changed

+12
-13
lines changed

pkg/analyzer/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Added 'dart/sdk/build_sdk_summary.dart' with `buildSdkSummary`.
33
* Added `DynamicType`, `NeverType`, and `VoidType` interfaces.
44
* Added `TypeVisitor` and `DartType.accept(TypeVisitor)`.
5+
* Changed `ConstructorElement.returnType` to `InterfaceType`.
56

67
## 0.39.12
78
* Deprecated `canUseSummaries` in `DartSdkManager` constructor.

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

+3
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,9 @@ abstract class ConstructorElement
487487
/// if this constructor does not redirect to another constructor or if the
488488
/// library containing this constructor has not yet been resolved.
489489
ConstructorElement get redirectedConstructor;
490+
491+
@override
492+
InterfaceType get returnType;
490493
}
491494

492495
/// The base class for all of the elements in the element model. Generally

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

+2-3
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,7 @@ class ConstantEvaluationEngine {
355355
if (defaultSuperInvocationNeeded) {
356356
// No explicit superconstructor invocation found, so we need to
357357
// manually insert a reference to the implicit superconstructor.
358-
InterfaceType superclass =
359-
(constant.returnType as InterfaceType).superclass;
358+
InterfaceType superclass = (constant.returnType).superclass;
360359
if (superclass != null && !superclass.isDartCoreObject) {
361360
ConstructorElement unnamedConstructor =
362361
superclass.element.unnamedConstructor?.declaration;
@@ -476,7 +475,7 @@ class ConstantEvaluationEngine {
476475
);
477476

478477
constructor = followConstantRedirectionChain(constructor);
479-
InterfaceType definingClass = constructor.returnType as InterfaceType;
478+
InterfaceType definingClass = constructor.returnType;
480479
if (constructor.isFactory) {
481480
// We couldn't find a non-factory constructor.
482481
// See if it's because we reached an external const factory constructor

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

+3-10
Original file line numberDiff line numberDiff line change
@@ -2143,7 +2143,7 @@ class ConstructorElementImpl extends ExecutableElementImpl
21432143
}
21442144

21452145
@override
2146-
DartType get returnType =>
2146+
InterfaceType get returnType =>
21472147
ElementTypeProvider.current.getExecutableReturnType(this);
21482148

21492149
@override
@@ -2152,15 +2152,8 @@ class ConstructorElementImpl extends ExecutableElementImpl
21522152
}
21532153

21542154
@override
2155-
DartType get returnTypeInternal {
2156-
if (_returnType != null) return _returnType;
2157-
2158-
InterfaceTypeImpl classThisType = enclosingElement.thisType;
2159-
return _returnType = InterfaceTypeImpl(
2160-
element: classThisType.element,
2161-
typeArguments: classThisType.typeArguments,
2162-
nullabilitySuffix: classThisType.nullabilitySuffix,
2163-
);
2155+
InterfaceType get returnTypeInternal {
2156+
return _returnType ??= enclosingElement.thisType;
21642157
}
21652158

21662159
@override

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

+3
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ class ConstructorMember extends ExecutableMember implements ConstructorElement {
8383
return ConstructorMember(declaration, substitution, false);
8484
}
8585

86+
@override
87+
InterfaceType get returnType => type.returnType as InterfaceType;
88+
8689
@override
8790
T accept<T>(ElementVisitor<T> visitor) =>
8891
visitor.visitConstructorElement(this);

0 commit comments

Comments
 (0)