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

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

Issue 2736383005: Store type inference errors into EntityRef. (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 | « no previous file | 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 8771170c01b9c6e262053450d61e09404c185227..f716dfff5dc668df4c1b9b3fcbfcbe0504b119c7 100644
--- a/pkg/analyzer/lib/src/summary/format.dart
+++ b/pkg/analyzer/lib/src/summary/format.dart
@@ -1807,6 +1807,7 @@ class EntityRefBuilder extends Object with _EntityRefMixin implements idl.Entity
int _slot;
List<UnlinkedParamBuilder> _syntheticParams;
EntityRefBuilder _syntheticReturnType;
+ List<TopLevelInferenceErrorBuilder> _topLevelInferenceErrors;
List<EntityRefBuilder> _typeArguments;
List<UnlinkedTypeParamBuilder> _typeParameters;
@@ -1921,6 +1922,20 @@ class EntityRefBuilder extends Object with _EntityRefMixin implements idl.Entity
}
@override
+ List<TopLevelInferenceErrorBuilder> get topLevelInferenceErrors => _topLevelInferenceErrors ??= <TopLevelInferenceErrorBuilder>[];
+
+ /**
+ * If this [EntityRef] is a result of type inference, and so contained within
+ * [LinkedUnit.types], and was computed as a result of top-level type
+ * inference, which failed for this target, contains the list of one or more
+ * errors describing the failure. The [reference] must point at `dynamic` in
+ * this case.
+ */
+ void set topLevelInferenceErrors(List<TopLevelInferenceErrorBuilder> value) {
+ this._topLevelInferenceErrors = value;
+ }
+
+ @override
List<EntityRefBuilder> get typeArguments => _typeArguments ??= <EntityRefBuilder>[];
/**
@@ -1942,13 +1957,14 @@ class EntityRefBuilder extends Object with _EntityRefMixin implements idl.Entity
this._typeParameters = value;
}
- EntityRefBuilder({List<int> implicitFunctionTypeIndices, int paramReference, int reference, int slot, List<UnlinkedParamBuilder> syntheticParams, EntityRefBuilder syntheticReturnType, List<EntityRefBuilder> typeArguments, List<UnlinkedTypeParamBuilder> typeParameters})
+ EntityRefBuilder({List<int> implicitFunctionTypeIndices, int paramReference, int reference, int slot, List<UnlinkedParamBuilder> syntheticParams, EntityRefBuilder syntheticReturnType, List<TopLevelInferenceErrorBuilder> topLevelInferenceErrors, List<EntityRefBuilder> typeArguments, List<UnlinkedTypeParamBuilder> typeParameters})
: _implicitFunctionTypeIndices = implicitFunctionTypeIndices,
_paramReference = paramReference,
_reference = reference,
_slot = slot,
_syntheticParams = syntheticParams,
_syntheticReturnType = syntheticReturnType,
+ _topLevelInferenceErrors = topLevelInferenceErrors,
_typeArguments = typeArguments,
_typeParameters = typeParameters;
@@ -1958,6 +1974,7 @@ class EntityRefBuilder extends Object with _EntityRefMixin implements idl.Entity
void flushInformative() {
_syntheticParams?.forEach((b) => b.flushInformative());
_syntheticReturnType?.flushInformative();
+ _topLevelInferenceErrors?.forEach((b) => b.flushInformative());
_typeArguments?.forEach((b) => b.flushInformative());
_typeParameters?.forEach((b) => b.flushInformative());
}
@@ -2003,12 +2020,21 @@ class EntityRefBuilder extends Object with _EntityRefMixin implements idl.Entity
x?.collectApiSignature(signature);
}
}
+ if (this._topLevelInferenceErrors == null) {
+ signature.addInt(0);
+ } else {
+ signature.addInt(this._topLevelInferenceErrors.length);
+ for (var x in this._topLevelInferenceErrors) {
+ x?.collectApiSignature(signature);
+ }
+ }
}
fb.Offset finish(fb.Builder fbBuilder) {
fb.Offset offset_implicitFunctionTypeIndices;
fb.Offset offset_syntheticParams;
fb.Offset offset_syntheticReturnType;
+ fb.Offset offset_topLevelInferenceErrors;
fb.Offset offset_typeArguments;
fb.Offset offset_typeParameters;
if (!(_implicitFunctionTypeIndices == null || _implicitFunctionTypeIndices.isEmpty)) {
@@ -2020,6 +2046,9 @@ class EntityRefBuilder extends Object with _EntityRefMixin implements idl.Entity
if (_syntheticReturnType != null) {
offset_syntheticReturnType = _syntheticReturnType.finish(fbBuilder);
}
+ if (!(_topLevelInferenceErrors == null || _topLevelInferenceErrors.isEmpty)) {
+ offset_topLevelInferenceErrors = fbBuilder.writeList(_topLevelInferenceErrors.map((b) => b.finish(fbBuilder)).toList());
+ }
if (!(_typeArguments == null || _typeArguments.isEmpty)) {
offset_typeArguments = fbBuilder.writeList(_typeArguments.map((b) => b.finish(fbBuilder)).toList());
}
@@ -2045,6 +2074,9 @@ class EntityRefBuilder extends Object with _EntityRefMixin implements idl.Entity
if (offset_syntheticReturnType != null) {
fbBuilder.addOffset(5, offset_syntheticReturnType);
}
+ if (offset_topLevelInferenceErrors != null) {
+ fbBuilder.addOffset(8, offset_topLevelInferenceErrors);
+ }
if (offset_typeArguments != null) {
fbBuilder.addOffset(1, offset_typeArguments);
}
@@ -2074,6 +2106,7 @@ class _EntityRefImpl extends Object with _EntityRefMixin implements idl.EntityRe
int _slot;
List<idl.UnlinkedParam> _syntheticParams;
idl.EntityRef _syntheticReturnType;
+ List<idl.TopLevelInferenceError> _topLevelInferenceErrors;
List<idl.EntityRef> _typeArguments;
List<idl.UnlinkedTypeParam> _typeParameters;
@@ -2114,6 +2147,12 @@ class _EntityRefImpl extends Object with _EntityRefMixin implements idl.EntityRe
}
@override
+ List<idl.TopLevelInferenceError> get topLevelInferenceErrors {
+ _topLevelInferenceErrors ??= const fb.ListReader<idl.TopLevelInferenceError>(const _TopLevelInferenceErrorReader()).vTableGet(_bc, _bcOffset, 8, const <idl.TopLevelInferenceError>[]);
+ return _topLevelInferenceErrors;
+ }
+
+ @override
List<idl.EntityRef> get typeArguments {
_typeArguments ??= const fb.ListReader<idl.EntityRef>(const _EntityRefReader()).vTableGet(_bc, _bcOffset, 1, const <idl.EntityRef>[]);
return _typeArguments;
@@ -2136,6 +2175,7 @@ abstract class _EntityRefMixin implements idl.EntityRef {
if (slot != 0) _result["slot"] = slot;
if (syntheticParams.isNotEmpty) _result["syntheticParams"] = syntheticParams.map((_value) => _value.toJson()).toList();
if (syntheticReturnType != null) _result["syntheticReturnType"] = syntheticReturnType.toJson();
+ if (topLevelInferenceErrors.isNotEmpty) _result["topLevelInferenceErrors"] = topLevelInferenceErrors.map((_value) => _value.toJson()).toList();
if (typeArguments.isNotEmpty) _result["typeArguments"] = typeArguments.map((_value) => _value.toJson()).toList();
if (typeParameters.isNotEmpty) _result["typeParameters"] = typeParameters.map((_value) => _value.toJson()).toList();
return _result;
@@ -2149,6 +2189,7 @@ abstract class _EntityRefMixin implements idl.EntityRef {
"slot": slot,
"syntheticParams": syntheticParams,
"syntheticReturnType": syntheticReturnType,
+ "topLevelInferenceErrors": topLevelInferenceErrors,
"typeArguments": typeArguments,
"typeParameters": typeParameters,
};
@@ -4185,6 +4226,87 @@ abstract class _PackageIndexMixin implements idl.PackageIndex {
String toString() => convert.JSON.encode(toJson());
}
+class TopLevelInferenceErrorBuilder extends Object with _TopLevelInferenceErrorMixin implements idl.TopLevelInferenceError {
+ String _message;
+
+ @override
+ String get message => _message ??= '';
+
+ /**
+ * The message describing the error.
+ */
+ void set message(String value) {
+ this._message = value;
+ }
+
+ TopLevelInferenceErrorBuilder({String message})
+ : _message = message;
+
+ /**
+ * Flush [informative] data recursively.
+ */
+ void flushInformative() {
+ }
+
+ /**
+ * Accumulate non-[informative] data into [signature].
+ */
+ void collectApiSignature(api_sig.ApiSignature signature) {
+ signature.addString(this._message ?? '');
+ }
+
+ fb.Offset finish(fb.Builder fbBuilder) {
+ fb.Offset offset_message;
+ if (_message != null) {
+ offset_message = fbBuilder.writeString(_message);
+ }
+ fbBuilder.startTable();
+ if (offset_message != null) {
+ fbBuilder.addOffset(0, offset_message);
+ }
+ return fbBuilder.endTable();
+ }
+}
+
+class _TopLevelInferenceErrorReader extends fb.TableReader<_TopLevelInferenceErrorImpl> {
+ const _TopLevelInferenceErrorReader();
+
+ @override
+ _TopLevelInferenceErrorImpl createObject(fb.BufferContext bc, int offset) => new _TopLevelInferenceErrorImpl(bc, offset);
+}
+
+class _TopLevelInferenceErrorImpl extends Object with _TopLevelInferenceErrorMixin implements idl.TopLevelInferenceError {
+ final fb.BufferContext _bc;
+ final int _bcOffset;
+
+ _TopLevelInferenceErrorImpl(this._bc, this._bcOffset);
+
+ String _message;
+
+ @override
+ String get message {
+ _message ??= const fb.StringReader().vTableGet(_bc, _bcOffset, 0, '');
+ return _message;
+ }
+}
+
+abstract class _TopLevelInferenceErrorMixin implements idl.TopLevelInferenceError {
+ @override
+ Map<String, Object> toJson() {
+ Map<String, Object> _result = <String, Object>{};
+ if (message != '') _result["message"] = message;
+ return _result;
+ }
+
+ @override
+ Map<String, Object> toMap() => {
+ "message": message,
+ };
+
+ @override
+ String toString() => convert.JSON.encode(toJson());
+}
+
class UnitIndexBuilder extends Object with _UnitIndexMixin implements idl.UnitIndex {
List<idl.IndexNameKind> _definedNameKinds;
List<int> _definedNameOffsets;
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/summary/format.fbs » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698