Skip to content

Commit b032208

Browse files
committed
Be less strict about visibility for warnings on synthetic elements
Fixes compat with timezone 0.8.0 We try to place error messages for synthetic elements at either its setter or at its getter. Before now, that setter/getter had to be both public and synthetic; now, we'll just print a warning if that check fails. Note that we still error out if we can't find any setter or getter. Related to dart-lang#2034
1 parent aca373a commit b032208

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

lib/src/model/getter_setter_combo.dart

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,20 @@ mixin GetterSetterCombo on ModelElement {
9090
// explicit setters/getters will be handled by those objects, but
9191
// if a warning comes up for an enclosing synthetic field we have to
9292
// put it somewhere. So pick an accessor.
93+
/// TODO: testcase based on timezone 0.8.0 (env.dart:timeZoneDatabase)
9394
if (element!.isSynthetic) {
9495
if (hasExplicitGetter) return getter!.characterLocation;
9596
if (hasExplicitSetter) return setter!.characterLocation;
97+
if (hasGetter) {
98+
if (!getter!.isSynthetic) warn(PackageWarning.noCanonicalFound, message: 'Getter for synthetic is not synthetic: $element');
99+
if (!getter!.isPublic) warn(PackageWarning.noCanonicalFound, message: 'Getter for synthetic is not public: $element');
100+
return getter!.characterLocation;
101+
}
102+
if (hasSetter) {
103+
if (!setter!.isSynthetic) warn(PackageWarning.noCanonicalFound, message: 'Setter for synthetic is not synthetic: $element');
104+
if (!setter!.isPublic) warn(PackageWarning.noCanonicalFound, message: 'Setter for synthetic is not public: $element');
105+
return setter!.characterLocation;
106+
}
96107
assert(false, 'Field and accessors can not all be synthetic: $element');
97108
}
98109
return super.characterLocation;
@@ -168,7 +179,7 @@ mixin GetterSetterCombo on ModelElement {
168179
@override
169180
bool get hasDocumentationComment =>
170181
_getterSetterDocumentationComment.isNotEmpty ||
171-
element!.documentationComment != null;
182+
element!.documentationComment != null;
172183

173184
/// Derive a documentation comment for the combo by copying documentation
174185
/// from the [getter] and/or [setter].

0 commit comments

Comments
 (0)