Move _hasSetter and typeInferenceError.
R=brianwilkerson@google.com
Change-Id: I8bf476dd6323f01d987c7cf2c3378f6beb37c267
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/159647
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
diff --git a/pkg/analyzer/lib/src/dart/element/element.dart b/pkg/analyzer/lib/src/dart/element/element.dart
index 46b2b3e..0923d43 100644
--- a/pkg/analyzer/lib/src/dart/element/element.dart
+++ b/pkg/analyzer/lib/src/dart/element/element.dart
@@ -6273,35 +6273,6 @@
}
_type = type;
}
-
- /// Return the error reported during type inference for this variable, or
- /// `null` if this variable is not a subject of type inference, or there was
- /// no error.
- TopLevelInferenceError get typeInferenceError {
- if (linkedNode != null) {
- return linkedContext.getTypeInferenceError(linkedNode);
- }
-
- // We don't support type inference errors without linking.
- return null;
- }
-
- /// Return `true` if this variable needs the setter.
- bool get _hasSetter {
- if (isConst) {
- return false;
- }
-
- // TODO(scheglov) is this right?
- if (isLate) {
- if (isFinal) {
- return !hasInitializer;
- }
- return true;
- }
-
- return !isFinal;
- }
}
/// A concrete implementation of a [ParameterElement].
@@ -7126,6 +7097,18 @@
@override
DartType get type => ElementTypeProvider.current.getFieldType(this);
+ /// Return the error reported during type inference for this variable, or
+ /// `null` if this variable is not a subject of type inference, or there was
+ /// no error.
+ TopLevelInferenceError get typeInferenceError {
+ if (linkedNode != null) {
+ return linkedContext.getTypeInferenceError(linkedNode);
+ }
+
+ // We don't support type inference errors without linking.
+ return null;
+ }
+
@override
DartType get typeInternal {
if (linkedNode != null) {
@@ -7146,6 +7129,19 @@
}
return super.typeInternal;
}
+
+ /// Return `true` if this variable needs the setter.
+ bool get _hasSetter {
+ if (isConst) {
+ return false;
+ }
+
+ if (isLate) {
+ return !isFinal || !hasInitializer;
+ }
+
+ return !isFinal;
+ }
}
/// Instances of this class are set for fields and top-level variables
diff --git a/pkg/analyzer/lib/src/summary2/linked_unit_context.dart b/pkg/analyzer/lib/src/summary2/linked_unit_context.dart
index 727b439..1a6410a 100644
--- a/pkg/analyzer/lib/src/summary2/linked_unit_context.dart
+++ b/pkg/analyzer/lib/src/summary2/linked_unit_context.dart
@@ -632,12 +632,8 @@
}
TopLevelInferenceError getTypeInferenceError(AstNode node) {
- if (node is DefaultFormalParameter) {
- return getTypeInferenceError(node.parameter);
- } else if (node is MethodDeclaration) {
+ if (node is MethodDeclaration) {
return LazyMethodDeclaration.getTypeInferenceError(node);
- } else if (node is SimpleFormalParameter) {
- return LazyFormalParameter.getTypeInferenceError(node);
} else if (node is VariableDeclaration) {
return LazyVariableDeclaration.getTypeInferenceError(node);
} else {
diff --git a/pkg/analyzer/lib/src/task/strong/checker.dart b/pkg/analyzer/lib/src/task/strong/checker.dart
index f036ec1..4e67d44 100644
--- a/pkg/analyzer/lib/src/task/strong/checker.dart
+++ b/pkg/analyzer/lib/src/task/strong/checker.dart
@@ -1057,7 +1057,7 @@
void validateHasType(AstNode n, PropertyAccessorElement e) {
if (e.hasImplicitReturnType) {
- var variable = e.declaration.variable as NonParameterVariableElementImpl;
+ var variable = e.declaration.variable as PropertyInducingElementImpl;
TopLevelInferenceError error = variable.typeInferenceError;
if (error != null) {
if (error.kind == TopLevelInferenceErrorKind.dependencyCycle) {
diff --git a/pkg/analyzer/test/src/summary/element_text.dart b/pkg/analyzer/test/src/summary/element_text.dart
index 6d6be56..1158676 100644
--- a/pkg/analyzer/test/src/summary/element_text.dart
+++ b/pkg/analyzer/test/src/summary/element_text.dart
@@ -1029,7 +1029,7 @@
TopLevelInferenceError inferenceError;
if (e is MethodElementImpl) {
inferenceError = e.typeInferenceError;
- } else if (e is NonParameterVariableElementImpl) {
+ } else if (e is PropertyInducingElementImpl) {
inferenceError = e.typeInferenceError;
}