mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 00:19:48 +00:00
Use FooImpl in BarImpl getters/setters, property related.
I think we might get away with this now, because we don't let users create elements manually. Presubmit in google3 looks green. https://fusion2.corp.google.com/presubmit/tap/483535261/OCL:483535261:BASE:483575659:1666678949553:5d26313d/targets Change-Id: Id9618e2d8a15ab98c5919750461c508e87f76c7b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/265405 Reviewed-by: Samuel Rawlins <srawlins@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
parent
5f063cb155
commit
9f35115b90
|
@ -177,10 +177,7 @@ class DefinitionHandler extends MessageHandler<TextDocumentPositionParams,
|
||||||
// For synthetic getters created for fields, we need to access the associated
|
// For synthetic getters created for fields, we need to access the associated
|
||||||
// variable to get the codeOffset/codeLength.
|
// variable to get the codeOffset/codeLength.
|
||||||
if (codeElement.isSynthetic && codeElement is PropertyAccessorElementImpl) {
|
if (codeElement.isSynthetic && codeElement is PropertyAccessorElementImpl) {
|
||||||
final variable = codeElement.variable;
|
codeElement = codeElement.variable;
|
||||||
if (variable is ElementImpl) {
|
|
||||||
codeElement = variable as ElementImpl;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read the main codeOffset from the element. This may include doc comments
|
// Read the main codeOffset from the element. This may include doc comments
|
||||||
|
|
|
@ -74,7 +74,7 @@ abstract class AbstractClassElementImpl extends _ExistingElementImpl
|
||||||
List<PropertyAccessorElement> _accessors = _Sentinel.propertyAccessorElement;
|
List<PropertyAccessorElement> _accessors = _Sentinel.propertyAccessorElement;
|
||||||
|
|
||||||
/// A list containing all of the fields contained in this class.
|
/// A list containing all of the fields contained in this class.
|
||||||
List<FieldElement> _fields = _Sentinel.fieldElement;
|
List<FieldElementImpl> _fields = _Sentinel.fieldElement;
|
||||||
|
|
||||||
/// A list containing all of the methods contained in this class.
|
/// A list containing all of the methods contained in this class.
|
||||||
List<MethodElement> _methods = _Sentinel.methodElement;
|
List<MethodElement> _methods = _Sentinel.methodElement;
|
||||||
|
@ -122,10 +122,13 @@ abstract class AbstractClassElementImpl extends _ExistingElementImpl
|
||||||
@override
|
@override
|
||||||
CompilationUnitElementImpl get enclosingElement3 => enclosingElement;
|
CompilationUnitElementImpl get enclosingElement3 => enclosingElement;
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<FieldElementImpl> get fields;
|
||||||
|
|
||||||
/// Set the fields contained in this class to the given [fields].
|
/// Set the fields contained in this class to the given [fields].
|
||||||
set fields(List<FieldElement> fields) {
|
set fields(List<FieldElementImpl> fields) {
|
||||||
for (FieldElement field in fields) {
|
for (var field in fields) {
|
||||||
(field as FieldElementImpl).enclosingElement = this;
|
field.enclosingElement = this;
|
||||||
}
|
}
|
||||||
_fields = fields;
|
_fields = fields;
|
||||||
}
|
}
|
||||||
|
@ -609,7 +612,7 @@ class ClassElementImpl extends ClassOrMixinElementImpl implements ClassElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
set fields(List<FieldElement> fields) {
|
set fields(List<FieldElementImpl> fields) {
|
||||||
assert(!isMixinApplication);
|
assert(!isMixinApplication);
|
||||||
super.fields = fields;
|
super.fields = fields;
|
||||||
}
|
}
|
||||||
|
@ -968,7 +971,7 @@ abstract class ClassOrMixinElementImpl extends AbstractClassElementImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<FieldElement> get fields {
|
List<FieldElementImpl> get fields {
|
||||||
if (!identical(_fields, _Sentinel.fieldElement)) {
|
if (!identical(_fields, _Sentinel.fieldElement)) {
|
||||||
return _fields;
|
return _fields;
|
||||||
}
|
}
|
||||||
|
@ -1099,7 +1102,7 @@ class CompilationUnitElementImpl extends UriReferencedElementImpl
|
||||||
List<TypeAliasElement> _typeAliases = const [];
|
List<TypeAliasElement> _typeAliases = const [];
|
||||||
|
|
||||||
/// A list containing all of the variables contained in this compilation unit.
|
/// A list containing all of the variables contained in this compilation unit.
|
||||||
List<TopLevelVariableElement> _variables = const [];
|
List<TopLevelVariableElementImpl> _variables = const [];
|
||||||
|
|
||||||
ElementLinkedData? linkedData;
|
ElementLinkedData? linkedData;
|
||||||
|
|
||||||
|
@ -1255,15 +1258,15 @@ class CompilationUnitElementImpl extends UriReferencedElementImpl
|
||||||
AnalysisSession get session => enclosingElement.session;
|
AnalysisSession get session => enclosingElement.session;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<TopLevelVariableElement> get topLevelVariables {
|
List<TopLevelVariableElementImpl> get topLevelVariables {
|
||||||
return _variables;
|
return _variables;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the top-level variables contained in this compilation unit to the
|
/// Set the top-level variables contained in this compilation unit to the
|
||||||
/// given[variables].
|
/// given[variables].
|
||||||
set topLevelVariables(List<TopLevelVariableElement> variables) {
|
set topLevelVariables(List<TopLevelVariableElementImpl> variables) {
|
||||||
for (TopLevelVariableElement field in variables) {
|
for (var variable in variables) {
|
||||||
(field as TopLevelVariableElementImpl).enclosingElement = this;
|
variable.enclosingElement = this;
|
||||||
}
|
}
|
||||||
_variables = variables;
|
_variables = variables;
|
||||||
}
|
}
|
||||||
|
@ -2947,7 +2950,7 @@ class EnumElementImpl extends AbstractClassElementImpl implements EnumElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<FieldElement> get fields {
|
List<FieldElementImpl> get fields {
|
||||||
return _fields;
|
return _fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3242,7 +3245,7 @@ class ExtensionElementImpl extends _ExistingElementImpl
|
||||||
List<PropertyAccessorElement> _accessors = const [];
|
List<PropertyAccessorElement> _accessors = const [];
|
||||||
|
|
||||||
/// A list containing all of the fields contained in this extension.
|
/// A list containing all of the fields contained in this extension.
|
||||||
List<FieldElement> _fields = const [];
|
List<FieldElementImpl> _fields = const [];
|
||||||
|
|
||||||
/// A list containing all of the methods contained in this extension.
|
/// A list containing all of the methods contained in this extension.
|
||||||
List<MethodElement> _methods = const [];
|
List<MethodElement> _methods = const [];
|
||||||
|
@ -3303,13 +3306,13 @@ class ExtensionElementImpl extends _ExistingElementImpl
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<FieldElement> get fields {
|
List<FieldElementImpl> get fields {
|
||||||
return _fields;
|
return _fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
set fields(List<FieldElement> fields) {
|
set fields(List<FieldElementImpl> fields) {
|
||||||
for (FieldElement field in fields) {
|
for (var field in fields) {
|
||||||
(field as FieldElementImpl).enclosingElement = this;
|
field.enclosingElement = this;
|
||||||
}
|
}
|
||||||
_fields = fields;
|
_fields = fields;
|
||||||
}
|
}
|
||||||
|
@ -5506,7 +5509,7 @@ class PropertyAccessorElementImpl extends ExecutableElementImpl
|
||||||
implements PropertyAccessorElement {
|
implements PropertyAccessorElement {
|
||||||
/// The variable associated with this accessor.
|
/// The variable associated with this accessor.
|
||||||
@override
|
@override
|
||||||
late PropertyInducingElement variable;
|
late PropertyInducingElementImpl variable;
|
||||||
|
|
||||||
/// If this method is a synthetic element which is based on another method
|
/// If this method is a synthetic element which is based on another method
|
||||||
/// with some modifications (such as making some parameters covariant),
|
/// with some modifications (such as making some parameters covariant),
|
||||||
|
@ -5632,7 +5635,7 @@ class PropertyAccessorElementImpl_ImplicitGetter
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Element get enclosingElement => variable.enclosingElement!;
|
Element get enclosingElement => variable.enclosingElement;
|
||||||
|
|
||||||
@Deprecated('Use enclosingElement instead')
|
@Deprecated('Use enclosingElement instead')
|
||||||
@override
|
@override
|
||||||
|
@ -5697,7 +5700,7 @@ class PropertyAccessorElementImpl_ImplicitSetter
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Element get enclosingElement => variable.enclosingElement!;
|
Element get enclosingElement => variable.enclosingElement;
|
||||||
|
|
||||||
@Deprecated('Use enclosingElement instead')
|
@Deprecated('Use enclosingElement instead')
|
||||||
@override
|
@override
|
||||||
|
@ -5760,13 +5763,13 @@ abstract class PropertyInducingElementImpl
|
||||||
extends NonParameterVariableElementImpl implements PropertyInducingElement {
|
extends NonParameterVariableElementImpl implements PropertyInducingElement {
|
||||||
/// The getter associated with this element.
|
/// The getter associated with this element.
|
||||||
@override
|
@override
|
||||||
PropertyAccessorElement? getter;
|
PropertyAccessorElementImpl? getter;
|
||||||
|
|
||||||
/// The setter associated with this element, or `null` if the element is
|
/// The setter associated with this element, or `null` if the element is
|
||||||
/// effectively `final` and therefore does not have a setter associated with
|
/// effectively `final` and therefore does not have a setter associated with
|
||||||
/// it.
|
/// it.
|
||||||
@override
|
@override
|
||||||
PropertyAccessorElement? setter;
|
PropertyAccessorElementImpl? setter;
|
||||||
|
|
||||||
/// This field is set during linking, and performs type inference for
|
/// This field is set during linking, and performs type inference for
|
||||||
/// this property. After linking this field is always `null`.
|
/// this property. After linking this field is always `null`.
|
||||||
|
@ -6554,7 +6557,7 @@ class _Sentinel {
|
||||||
List.unmodifiable([]);
|
List.unmodifiable([]);
|
||||||
static final List<ConstructorElement> constructorElement =
|
static final List<ConstructorElement> constructorElement =
|
||||||
List.unmodifiable([]);
|
List.unmodifiable([]);
|
||||||
static final List<FieldElement> fieldElement = List.unmodifiable([]);
|
static final List<FieldElementImpl> fieldElement = List.unmodifiable([]);
|
||||||
static final List<LibraryExportElement> libraryExportElement =
|
static final List<LibraryExportElement> libraryExportElement =
|
||||||
List.unmodifiable([]);
|
List.unmodifiable([]);
|
||||||
static final List<LibraryImportElement> libraryImportElement =
|
static final List<LibraryImportElement> libraryImportElement =
|
||||||
|
|
|
@ -779,7 +779,7 @@ class InheritanceManager3 {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (executable is PropertyAccessorElement) {
|
if (executable is PropertyAccessorElementImpl) {
|
||||||
assert(executable.isSetter);
|
assert(executable.isSetter);
|
||||||
var result = PropertyAccessorElementImpl(executable.name, -1);
|
var result = PropertyAccessorElementImpl(executable.name, -1);
|
||||||
result.enclosingElement = class_;
|
result.enclosingElement = class_;
|
||||||
|
|
|
@ -630,7 +630,7 @@ class LibraryReader {
|
||||||
Reference reference,
|
Reference reference,
|
||||||
) {
|
) {
|
||||||
var accessors = <PropertyAccessorElementImpl>[];
|
var accessors = <PropertyAccessorElementImpl>[];
|
||||||
var fields = <FieldElement>[];
|
var fields = <FieldElementImpl>[];
|
||||||
_readFields(unitElement, element, reference, accessors, fields);
|
_readFields(unitElement, element, reference, accessors, fields);
|
||||||
_readPropertyAccessors(
|
_readPropertyAccessors(
|
||||||
unitElement, element, reference, accessors, fields, '@field');
|
unitElement, element, reference, accessors, fields, '@field');
|
||||||
|
@ -783,7 +783,7 @@ class LibraryReader {
|
||||||
element.typeParameters = _readTypeParameters();
|
element.typeParameters = _readTypeParameters();
|
||||||
|
|
||||||
var accessors = <PropertyAccessorElement>[];
|
var accessors = <PropertyAccessorElement>[];
|
||||||
var fields = <FieldElement>[];
|
var fields = <FieldElementImpl>[];
|
||||||
|
|
||||||
_readFields(unitElement, element, reference, accessors, fields);
|
_readFields(unitElement, element, reference, accessors, fields);
|
||||||
_readPropertyAccessors(
|
_readPropertyAccessors(
|
||||||
|
@ -869,7 +869,7 @@ class LibraryReader {
|
||||||
element.typeParameters = _readTypeParameters();
|
element.typeParameters = _readTypeParameters();
|
||||||
|
|
||||||
var accessors = <PropertyAccessorElement>[];
|
var accessors = <PropertyAccessorElement>[];
|
||||||
var fields = <FieldElement>[];
|
var fields = <FieldElementImpl>[];
|
||||||
_readPropertyAccessors(
|
_readPropertyAccessors(
|
||||||
unitElement, element, reference, accessors, fields, '@field');
|
unitElement, element, reference, accessors, fields, '@field');
|
||||||
_readFields(unitElement, element, reference, accessors, fields);
|
_readFields(unitElement, element, reference, accessors, fields);
|
||||||
|
@ -1127,7 +1127,7 @@ class LibraryReader {
|
||||||
|
|
||||||
element.typeParameters = _readTypeParameters();
|
element.typeParameters = _readTypeParameters();
|
||||||
|
|
||||||
var fields = <FieldElement>[];
|
var fields = <FieldElementImpl>[];
|
||||||
var accessors = <PropertyAccessorElement>[];
|
var accessors = <PropertyAccessorElement>[];
|
||||||
_readFields(unitElement, element, reference, accessors, fields);
|
_readFields(unitElement, element, reference, accessors, fields);
|
||||||
_readPropertyAccessors(
|
_readPropertyAccessors(
|
||||||
|
|
|
@ -242,8 +242,7 @@ class BundleWriter {
|
||||||
|
|
||||||
_writeList(
|
_writeList(
|
||||||
element.fields.where((e) {
|
element.fields.where((e) {
|
||||||
return !e.isSynthetic ||
|
return !e.isSynthetic || e.isSyntheticEnumField;
|
||||||
e is FieldElementImpl && e.isSyntheticEnumField;
|
|
||||||
}).toList(),
|
}).toList(),
|
||||||
_writeFieldElement,
|
_writeFieldElement,
|
||||||
);
|
);
|
||||||
|
|
|
@ -434,7 +434,7 @@ class ElementBuilder extends ThrowingAstVisitor<void> {
|
||||||
_visitPropertyFirst<FieldDeclaration>(node.members);
|
_visitPropertyFirst<FieldDeclaration>(node.members);
|
||||||
});
|
});
|
||||||
element.accessors = holder.propertyAccessors;
|
element.accessors = holder.propertyAccessors;
|
||||||
element.fields = holder.properties.whereType<FieldElement>().toList();
|
element.fields = holder.properties.whereType<FieldElementImpl>().toList();
|
||||||
element.methods = holder.methods;
|
element.methods = holder.methods;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1140,7 +1140,7 @@ class ElementBuilder extends ThrowingAstVisitor<void> {
|
||||||
|
|
||||||
element.accessors = holder.propertyAccessors;
|
element.accessors = holder.propertyAccessors;
|
||||||
element.constructors = holder.constructors;
|
element.constructors = holder.constructors;
|
||||||
element.fields = holder.properties.whereType<FieldElement>().toList();
|
element.fields = holder.properties.whereType<FieldElementImpl>().toList();
|
||||||
element.methods = holder.methods;
|
element.methods = holder.methods;
|
||||||
|
|
||||||
_resolveConstructorFieldFormals(element);
|
_resolveConstructorFieldFormals(element);
|
||||||
|
@ -1179,7 +1179,7 @@ class ElementBuilder extends ThrowingAstVisitor<void> {
|
||||||
|
|
||||||
element.accessors = holder.propertyAccessors;
|
element.accessors = holder.propertyAccessors;
|
||||||
element.constructors = holder.constructors;
|
element.constructors = holder.constructors;
|
||||||
element.fields = holder.properties.whereType<FieldElement>().toList();
|
element.fields = holder.properties.whereType<FieldElementImpl>().toList();
|
||||||
element.methods = holder.methods;
|
element.methods = holder.methods;
|
||||||
|
|
||||||
_resolveConstructorFieldFormals(element);
|
_resolveConstructorFieldFormals(element);
|
||||||
|
|
|
@ -273,6 +273,7 @@ class LibraryBuilder {
|
||||||
// Transplant built elements as if the augmentation was applied.
|
// Transplant built elements as if the augmentation was applied.
|
||||||
final augmentedUnitElement = element.definingCompilationUnit;
|
final augmentedUnitElement = element.definingCompilationUnit;
|
||||||
for (final augmentation in unitElement.classes) {
|
for (final augmentation in unitElement.classes) {
|
||||||
|
augmentation as ClassElementImpl;
|
||||||
// TODO(scheglov) if augmentation
|
// TODO(scheglov) if augmentation
|
||||||
final augmented = element.getClass(augmentation.name);
|
final augmented = element.getClass(augmentation.name);
|
||||||
if (augmented is ClassElementImpl) {
|
if (augmented is ClassElementImpl) {
|
||||||
|
|
|
@ -327,7 +327,7 @@ class InstanceMemberInferrer {
|
||||||
currentInterfaceElement = classElement;
|
currentInterfaceElement = classElement;
|
||||||
for (var field in classElement.fields) {
|
for (var field in classElement.fields) {
|
||||||
_inferAccessorOrField(
|
_inferAccessorOrField(
|
||||||
field: field as FieldElementImpl,
|
field: field,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
for (var accessor in classElement.accessors) {
|
for (var accessor in classElement.accessors) {
|
||||||
|
|
|
@ -138,7 +138,7 @@ class _MockSdkElementsBuilder {
|
||||||
_deprecatedElement = deprecatedElement = _class(name: 'Deprecated');
|
_deprecatedElement = deprecatedElement = _class(name: 'Deprecated');
|
||||||
deprecatedElement.supertype = objectType;
|
deprecatedElement.supertype = objectType;
|
||||||
|
|
||||||
deprecatedElement.fields = <FieldElement>[
|
deprecatedElement.fields = [
|
||||||
_field('message', stringType, isFinal: true),
|
_field('message', stringType, isFinal: true),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -167,11 +167,11 @@ class _MockSdkElementsBuilder {
|
||||||
);
|
);
|
||||||
doubleElement.supertype = numType;
|
doubleElement.supertype = numType;
|
||||||
|
|
||||||
FieldElement staticConstDoubleField(String name) {
|
FieldElementImpl staticConstDoubleField(String name) {
|
||||||
return _field(name, doubleType, isStatic: true, isConst: true);
|
return _field(name, doubleType, isStatic: true, isConst: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
doubleElement.fields = <FieldElement>[
|
doubleElement.fields = <FieldElementImpl>[
|
||||||
staticConstDoubleField('nan'),
|
staticConstDoubleField('nan'),
|
||||||
staticConstDoubleField('infinity'),
|
staticConstDoubleField('infinity'),
|
||||||
staticConstDoubleField('negativeInfinity'),
|
staticConstDoubleField('negativeInfinity'),
|
||||||
|
@ -969,7 +969,7 @@ class _MockSdkElementsBuilder {
|
||||||
overrideVariable.getter!,
|
overrideVariable.getter!,
|
||||||
proxyVariable.getter!,
|
proxyVariable.getter!,
|
||||||
];
|
];
|
||||||
coreUnit.topLevelVariables = <TopLevelVariableElement>[
|
coreUnit.topLevelVariables = <TopLevelVariableElementImpl>[
|
||||||
deprecatedVariable,
|
deprecatedVariable,
|
||||||
overrideVariable,
|
overrideVariable,
|
||||||
proxyVariable,
|
proxyVariable,
|
||||||
|
@ -1014,7 +1014,7 @@ class _MockSdkElementsBuilder {
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
|
|
||||||
FieldElement _field(
|
FieldElementImpl _field(
|
||||||
String name,
|
String name,
|
||||||
DartType type, {
|
DartType type, {
|
||||||
bool isConst = false,
|
bool isConst = false,
|
||||||
|
@ -1133,11 +1133,14 @@ class _MockSdkElementsBuilder {
|
||||||
classElement.accessors = accessors;
|
classElement.accessors = accessors;
|
||||||
classElement.fields = accessors
|
classElement.fields = accessors
|
||||||
.map((accessor) => accessor.variable)
|
.map((accessor) => accessor.variable)
|
||||||
.cast<FieldElement>()
|
.cast<FieldElementImpl>()
|
||||||
.toList();
|
.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
TopLevelVariableElement _topLevelVariableConst(String name, DartType type) {
|
TopLevelVariableElementImpl _topLevelVariableConst(
|
||||||
|
String name,
|
||||||
|
DartType type,
|
||||||
|
) {
|
||||||
final variable = ConstTopLevelVariableElementImpl(name, -1)
|
final variable = ConstTopLevelVariableElementImpl(name, -1)
|
||||||
..isConst = true
|
..isConst = true
|
||||||
..type = type;
|
..type = type;
|
||||||
|
|
|
@ -40,7 +40,7 @@ class ClassElementImplTest extends AbstractTypeSystemTest {
|
||||||
String fieldName = "f";
|
String fieldName = "f";
|
||||||
FieldElementImpl field =
|
FieldElementImpl field =
|
||||||
ElementFactory.fieldElement(fieldName, false, false, false, intNone);
|
ElementFactory.fieldElement(fieldName, false, false, false, intNone);
|
||||||
classA.fields = <FieldElement>[field];
|
classA.fields = [field];
|
||||||
expect(classA.getField(fieldName), same(field));
|
expect(classA.getField(fieldName), same(field));
|
||||||
expect(field.isEnumConstant, false);
|
expect(field.isEnumConstant, false);
|
||||||
// no such field
|
// no such field
|
||||||
|
@ -65,7 +65,7 @@ class ClassElementImplTest extends AbstractTypeSystemTest {
|
||||||
|
|
||||||
void test_hasNonFinalField_false_const() {
|
void test_hasNonFinalField_false_const() {
|
||||||
var classA = class_(name: 'A');
|
var classA = class_(name: 'A');
|
||||||
classA.fields = <FieldElement>[
|
classA.fields = [
|
||||||
ElementFactory.fieldElement(
|
ElementFactory.fieldElement(
|
||||||
"f", false, false, true, interfaceTypeStar(classA))
|
"f", false, false, true, interfaceTypeStar(classA))
|
||||||
];
|
];
|
||||||
|
@ -74,7 +74,7 @@ class ClassElementImplTest extends AbstractTypeSystemTest {
|
||||||
|
|
||||||
void test_hasNonFinalField_false_final() {
|
void test_hasNonFinalField_false_final() {
|
||||||
var classA = class_(name: 'A');
|
var classA = class_(name: 'A');
|
||||||
classA.fields = <FieldElement>[
|
classA.fields = [
|
||||||
ElementFactory.fieldElement(
|
ElementFactory.fieldElement(
|
||||||
"f", false, true, false, interfaceTypeStar(classA))
|
"f", false, true, false, interfaceTypeStar(classA))
|
||||||
];
|
];
|
||||||
|
@ -93,7 +93,7 @@ class ClassElementImplTest extends AbstractTypeSystemTest {
|
||||||
|
|
||||||
void test_hasNonFinalField_true_immediate() {
|
void test_hasNonFinalField_true_immediate() {
|
||||||
var classA = class_(name: 'A');
|
var classA = class_(name: 'A');
|
||||||
classA.fields = <FieldElement>[
|
classA.fields = [
|
||||||
ElementFactory.fieldElement(
|
ElementFactory.fieldElement(
|
||||||
"f", false, false, false, interfaceTypeStar(classA))
|
"f", false, false, false, interfaceTypeStar(classA))
|
||||||
];
|
];
|
||||||
|
@ -105,7 +105,7 @@ class ClassElementImplTest extends AbstractTypeSystemTest {
|
||||||
var classA = class_(name: 'A');
|
var classA = class_(name: 'A');
|
||||||
ClassElementImpl classB =
|
ClassElementImpl classB =
|
||||||
ElementFactory.classElement("B", interfaceTypeStar(classA));
|
ElementFactory.classElement("B", interfaceTypeStar(classA));
|
||||||
classA.fields = <FieldElement>[
|
classA.fields = [
|
||||||
ElementFactory.fieldElement(
|
ElementFactory.fieldElement(
|
||||||
"f", false, false, false, interfaceTypeStar(classA))
|
"f", false, false, false, interfaceTypeStar(classA))
|
||||||
];
|
];
|
||||||
|
@ -421,7 +421,7 @@ class ElementImplTest extends AbstractTypeSystemTest {
|
||||||
LibraryElementImpl library = ElementFactory.library(analysisContext, "lib");
|
LibraryElementImpl library = ElementFactory.library(analysisContext, "lib");
|
||||||
ClassElementImpl classElement = ElementFactory.classElement2("C");
|
ClassElementImpl classElement = ElementFactory.classElement2("C");
|
||||||
(library.definingCompilationUnit).classes = <ClassElement>[classElement];
|
(library.definingCompilationUnit).classes = <ClassElement>[classElement];
|
||||||
FieldElement field = ElementFactory.fieldElement(
|
var field = ElementFactory.fieldElement(
|
||||||
"next",
|
"next",
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
|
@ -431,7 +431,7 @@ class ElementImplTest extends AbstractTypeSystemTest {
|
||||||
nullabilitySuffix: NullabilitySuffix.star,
|
nullabilitySuffix: NullabilitySuffix.star,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
classElement.fields = <FieldElement>[field];
|
classElement.fields = [field];
|
||||||
expect(field == field, isTrue);
|
expect(field == field, isTrue);
|
||||||
// ignore: unrelated_type_equality_checks
|
// ignore: unrelated_type_equality_checks
|
||||||
expect(field == field.getter, isFalse);
|
expect(field == field.getter, isFalse);
|
||||||
|
|
|
@ -11236,16 +11236,14 @@ library
|
||||||
synthetic static get y @-1
|
synthetic static get y @-1
|
||||||
returnType: Object
|
returnType: Object
|
||||||
''');
|
''');
|
||||||
var x = library.definingCompilationUnit.topLevelVariables[0]
|
var x = library.definingCompilationUnit.topLevelVariables[0];
|
||||||
as TopLevelVariableElementImpl;
|
|
||||||
var xExpr = x.constantInitializer as InstanceCreationExpression;
|
var xExpr = x.constantInitializer as InstanceCreationExpression;
|
||||||
var xType = xExpr.constructorName.staticElement!.returnType;
|
var xType = xExpr.constructorName.staticElement!.returnType;
|
||||||
_assertTypeStr(
|
_assertTypeStr(
|
||||||
xType,
|
xType,
|
||||||
'C<int>',
|
'C<int>',
|
||||||
);
|
);
|
||||||
var y = library.definingCompilationUnit.topLevelVariables[0]
|
var y = library.definingCompilationUnit.topLevelVariables[0];
|
||||||
as TopLevelVariableElementImpl;
|
|
||||||
var yExpr = y.constantInitializer as InstanceCreationExpression;
|
var yExpr = y.constantInitializer as InstanceCreationExpression;
|
||||||
var yType = yExpr.constructorName.staticElement!.returnType;
|
var yType = yExpr.constructorName.staticElement!.returnType;
|
||||||
_assertTypeStr(yType, 'C<int>');
|
_assertTypeStr(yType, 'C<int>');
|
||||||
|
|
Loading…
Reference in a new issue