Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1033)

Unified Diff: pkg/analyzer/lib/src/summary/format.dart

Issue 2757143002: The parameter of synthetic setters should inherit 'covariant'. (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/dart/element/element.dart ('k') | pkg/analyzer/lib/src/summary/format.fbs » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/summary/format.dart
diff --git a/pkg/analyzer/lib/src/summary/format.dart b/pkg/analyzer/lib/src/summary/format.dart
index f716dfff5dc668df4c1b9b3fcbfcbe0504b119c7..c38daabb7c79442e90ae6e29fc748b090f3be9b8 100644
--- a/pkg/analyzer/lib/src/summary/format.dart
+++ b/pkg/analyzer/lib/src/summary/format.dart
@@ -3067,9 +3067,9 @@ class LinkedUnitBuilder extends Object with _LinkedUnitMixin implements idl.Link
List<int> get parametersInheritingCovariant => _parametersInheritingCovariant ??= <int>[];
/**
- * List of slot ids (referring to [UnlinkedParam.inheritsCovariantSlot])
- * corresponding to parameters that inherit `@covariant` behavior from a base
- * class.
+ * List of slot ids (referring to [UnlinkedParam.inheritsCovariantSlot] or
+ * [UnlinkedVariable.inheritsCovariantSlot]) corresponding to parameters
+ * that inherit `@covariant` behavior from a base class.
*/
void set parametersInheritingCovariant(List<int> value) {
assert(value == null || value.every((e) => e >= 0));
@@ -7917,6 +7917,190 @@ abstract class _UnlinkedExprMixin implements idl.UnlinkedExpr {
String toString() => convert.JSON.encode(toJson());
}
+class UnlinkedGenericFunctionTypeBuilder extends Object with _UnlinkedGenericFunctionTypeMixin implements idl.UnlinkedGenericFunctionType {
+ int _offset;
+ List<UnlinkedParamBuilder> _parameters;
+ EntityRefBuilder _returnType;
+ List<UnlinkedTypeParamBuilder> _typeParameters;
+
+ @override
+ int get offset => _offset ??= 0;
+
+ /**
+ * The offset of the return type.
+ */
+ void set offset(int value) {
+ assert(value == null || value >= 0);
+ this._offset = value;
+ }
+
+ @override
+ List<UnlinkedParamBuilder> get parameters => _parameters ??= <UnlinkedParamBuilder>[];
+
+ /**
+ * Parameters of the function type, if any.
+ */
+ void set parameters(List<UnlinkedParamBuilder> value) {
+ this._parameters = value;
+ }
+
+ @override
+ EntityRefBuilder get returnType => _returnType;
+
+ /**
+ * Declared return type of the function type. Absent if the return type is
+ * implicit.
+ */
+ void set returnType(EntityRefBuilder value) {
+ this._returnType = value;
+ }
+
+ @override
+ List<UnlinkedTypeParamBuilder> get typeParameters => _typeParameters ??= <UnlinkedTypeParamBuilder>[];
+
+ /**
+ * Type parameters of the function type, if any.
+ */
+ void set typeParameters(List<UnlinkedTypeParamBuilder> value) {
+ this._typeParameters = value;
+ }
+
+ UnlinkedGenericFunctionTypeBuilder({int offset, List<UnlinkedParamBuilder> parameters, EntityRefBuilder returnType, List<UnlinkedTypeParamBuilder> typeParameters})
+ : _offset = offset,
+ _parameters = parameters,
+ _returnType = returnType,
+ _typeParameters = typeParameters;
+
+ /**
+ * Flush [informative] data recursively.
+ */
+ void flushInformative() {
+ _offset = null;
+ _parameters?.forEach((b) => b.flushInformative());
+ _returnType?.flushInformative();
+ _typeParameters?.forEach((b) => b.flushInformative());
+ }
+
+ /**
+ * Accumulate non-[informative] data into [signature].
+ */
+ void collectApiSignature(api_sig.ApiSignature signature) {
+ signature.addBool(this._returnType != null);
+ this._returnType?.collectApiSignature(signature);
+ if (this._typeParameters == null) {
+ signature.addInt(0);
+ } else {
+ signature.addInt(this._typeParameters.length);
+ for (var x in this._typeParameters) {
+ x?.collectApiSignature(signature);
+ }
+ }
+ if (this._parameters == null) {
+ signature.addInt(0);
+ } else {
+ signature.addInt(this._parameters.length);
+ for (var x in this._parameters) {
+ x?.collectApiSignature(signature);
+ }
+ }
+ }
+
+ fb.Offset finish(fb.Builder fbBuilder) {
+ fb.Offset offset_parameters;
+ fb.Offset offset_returnType;
+ fb.Offset offset_typeParameters;
+ if (!(_parameters == null || _parameters.isEmpty)) {
+ offset_parameters = fbBuilder.writeList(_parameters.map((b) => b.finish(fbBuilder)).toList());
+ }
+ if (_returnType != null) {
+ offset_returnType = _returnType.finish(fbBuilder);
+ }
+ if (!(_typeParameters == null || _typeParameters.isEmpty)) {
+ offset_typeParameters = fbBuilder.writeList(_typeParameters.map((b) => b.finish(fbBuilder)).toList());
+ }
+ fbBuilder.startTable();
+ if (_offset != null && _offset != 0) {
+ fbBuilder.addUint32(0, _offset);
+ }
+ if (offset_parameters != null) {
+ fbBuilder.addOffset(3, offset_parameters);
+ }
+ if (offset_returnType != null) {
+ fbBuilder.addOffset(1, offset_returnType);
+ }
+ if (offset_typeParameters != null) {
+ fbBuilder.addOffset(2, offset_typeParameters);
+ }
+ return fbBuilder.endTable();
+ }
+}
+
+class _UnlinkedGenericFunctionTypeReader extends fb.TableReader<_UnlinkedGenericFunctionTypeImpl> {
+ const _UnlinkedGenericFunctionTypeReader();
+
+ @override
+ _UnlinkedGenericFunctionTypeImpl createObject(fb.BufferContext bc, int offset) => new _UnlinkedGenericFunctionTypeImpl(bc, offset);
+}
+
+class _UnlinkedGenericFunctionTypeImpl extends Object with _UnlinkedGenericFunctionTypeMixin implements idl.UnlinkedGenericFunctionType {
+ final fb.BufferContext _bc;
+ final int _bcOffset;
+
+ _UnlinkedGenericFunctionTypeImpl(this._bc, this._bcOffset);
+
+ int _offset;
+ List<idl.UnlinkedParam> _parameters;
+ idl.EntityRef _returnType;
+ List<idl.UnlinkedTypeParam> _typeParameters;
+
+ @override
+ int get offset {
+ _offset ??= const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 0, 0);
+ return _offset;
+ }
+
+ @override
+ List<idl.UnlinkedParam> get parameters {
+ _parameters ??= const fb.ListReader<idl.UnlinkedParam>(const _UnlinkedParamReader()).vTableGet(_bc, _bcOffset, 3, const <idl.UnlinkedParam>[]);
+ return _parameters;
+ }
+
+ @override
+ idl.EntityRef get returnType {
+ _returnType ??= const _EntityRefReader().vTableGet(_bc, _bcOffset, 1, null);
+ return _returnType;
+ }
+
+ @override
+ List<idl.UnlinkedTypeParam> get typeParameters {
+ _typeParameters ??= const fb.ListReader<idl.UnlinkedTypeParam>(const _UnlinkedTypeParamReader()).vTableGet(_bc, _bcOffset, 2, const <idl.UnlinkedTypeParam>[]);
+ return _typeParameters;
+ }
+}
+
+abstract class _UnlinkedGenericFunctionTypeMixin implements idl.UnlinkedGenericFunctionType {
+ @override
+ Map<String, Object> toJson() {
+ Map<String, Object> _result = <String, Object>{};
+ if (offset != 0) _result["offset"] = offset;
+ if (parameters.isNotEmpty) _result["parameters"] = parameters.map((_value) => _value.toJson()).toList();
+ if (returnType != null) _result["returnType"] = returnType.toJson();
+ if (typeParameters.isNotEmpty) _result["typeParameters"] = typeParameters.map((_value) => _value.toJson()).toList();
+ return _result;
+ }
+
+ @override
+ Map<String, Object> toMap() => {
+ "offset": offset,
+ "parameters": parameters,
+ "returnType": returnType,
+ "typeParameters": typeParameters,
+ };
+
+ @override
+ String toString() => convert.JSON.encode(toJson());
+}
+
class UnlinkedImportBuilder extends Object with _UnlinkedImportMixin implements idl.UnlinkedImport {
List<UnlinkedExprBuilder> _annotations;
List<UnlinkedCombinatorBuilder> _combinators;
@@ -10873,6 +11057,7 @@ class UnlinkedVariableBuilder extends Object with _UnlinkedVariableMixin impleme
CodeRangeBuilder _codeRange;
UnlinkedDocumentationCommentBuilder _documentationComment;
int _inferredTypeSlot;
+ int _inheritsCovariantSlot;
UnlinkedExecutableBuilder _initializer;
bool _isConst;
bool _isCovariant;
@@ -10931,6 +11116,22 @@ class UnlinkedVariableBuilder extends Object with _UnlinkedVariableMixin impleme
}
@override
+ int get inheritsCovariantSlot => _inheritsCovariantSlot ??= 0;
+
+ /**
+ * If this is an instance non-final field, a nonzero slot id which is unique
+ * within this compilation unit. If this id is found in
+ * [LinkedUnit.parametersInheritingCovariant], then the parameter of the
+ * synthetic setter inherits `@covariant` behavior from a base class.
+ *
+ * Otherwise, zero.
+ */
+ void set inheritsCovariantSlot(int value) {
+ assert(value == null || value >= 0);
+ this._inheritsCovariantSlot = value;
+ }
+
+ @override
UnlinkedExecutableBuilder get initializer => _initializer;
/**
@@ -11055,11 +11256,12 @@ class UnlinkedVariableBuilder extends Object with _UnlinkedVariableMixin impleme
this._visibleOffset = value;
}
- UnlinkedVariableBuilder({List<UnlinkedExprBuilder> annotations, CodeRangeBuilder codeRange, UnlinkedDocumentationCommentBuilder documentationComment, int inferredTypeSlot, UnlinkedExecutableBuilder initializer, bool isConst, bool isCovariant, bool isFinal, bool isStatic, String name, int nameOffset, int propagatedTypeSlot, EntityRefBuilder type, int visibleLength, int visibleOffset})
+ UnlinkedVariableBuilder({List<UnlinkedExprBuilder> annotations, CodeRangeBuilder codeRange, UnlinkedDocumentationCommentBuilder documentationComment, int inferredTypeSlot, int inheritsCovariantSlot, UnlinkedExecutableBuilder initializer, bool isConst, bool isCovariant, bool isFinal, bool isStatic, String name, int nameOffset, int propagatedTypeSlot, EntityRefBuilder type, int visibleLength, int visibleOffset})
: _annotations = annotations,
_codeRange = codeRange,
_documentationComment = documentationComment,
_inferredTypeSlot = inferredTypeSlot,
+ _inheritsCovariantSlot = inheritsCovariantSlot,
_initializer = initializer,
_isConst = isConst,
_isCovariant = isCovariant,
@@ -11109,6 +11311,7 @@ class UnlinkedVariableBuilder extends Object with _UnlinkedVariableMixin impleme
signature.addBool(this._initializer != null);
this._initializer?.collectApiSignature(signature);
signature.addBool(this._isCovariant == true);
+ signature.addInt(this._inheritsCovariantSlot ?? 0);
}
fb.Offset finish(fb.Builder fbBuilder) {
@@ -11149,6 +11352,9 @@ class UnlinkedVariableBuilder extends Object with _UnlinkedVariableMixin impleme
if (_inferredTypeSlot != null && _inferredTypeSlot != 0) {
fbBuilder.addUint32(9, _inferredTypeSlot);
}
+ if (_inheritsCovariantSlot != null && _inheritsCovariantSlot != 0) {
+ fbBuilder.addUint32(15, _inheritsCovariantSlot);
+ }
if (offset_initializer != null) {
fbBuilder.addOffset(13, offset_initializer);
}
@@ -11203,6 +11409,7 @@ class _UnlinkedVariableImpl extends Object with _UnlinkedVariableMixin implement
idl.CodeRange _codeRange;
idl.UnlinkedDocumentationComment _documentationComment;
int _inferredTypeSlot;
+ int _inheritsCovariantSlot;
idl.UnlinkedExecutable _initializer;
bool _isConst;
bool _isCovariant;
@@ -11240,6 +11447,12 @@ class _UnlinkedVariableImpl extends Object with _UnlinkedVariableMixin implement
}
@override
+ int get inheritsCovariantSlot {
+ _inheritsCovariantSlot ??= const fb.Uint32Reader().vTableGet(_bc, _bcOffset, 15, 0);
+ return _inheritsCovariantSlot;
+ }
+
+ @override
idl.UnlinkedExecutable get initializer {
_initializer ??= const _UnlinkedExecutableReader().vTableGet(_bc, _bcOffset, 13, null);
return _initializer;
@@ -11314,6 +11527,7 @@ abstract class _UnlinkedVariableMixin implements idl.UnlinkedVariable {
if (codeRange != null) _result["codeRange"] = codeRange.toJson();
if (documentationComment != null) _result["documentationComment"] = documentationComment.toJson();
if (inferredTypeSlot != 0) _result["inferredTypeSlot"] = inferredTypeSlot;
+ if (inheritsCovariantSlot != 0) _result["inheritsCovariantSlot"] = inheritsCovariantSlot;
if (initializer != null) _result["initializer"] = initializer.toJson();
if (isConst != false) _result["isConst"] = isConst;
if (isCovariant != false) _result["isCovariant"] = isCovariant;
@@ -11334,6 +11548,7 @@ abstract class _UnlinkedVariableMixin implements idl.UnlinkedVariable {
"codeRange": codeRange,
"documentationComment": documentationComment,
"inferredTypeSlot": inferredTypeSlot,
+ "inheritsCovariantSlot": inheritsCovariantSlot,
"initializer": initializer,
"isConst": isConst,
"isCovariant": isCovariant,
« no previous file with comments | « pkg/analyzer/lib/src/dart/element/element.dart ('k') | pkg/analyzer/lib/src/summary/format.fbs » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698