Skip to content

Commit 210933c

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 f2bb6e9 commit 210933c

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

lib/src/model/getter_setter_combo.dart

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,18 @@ mixin GetterSetterCombo on ModelElement {
101101
// explicit setters/getters will be handled by those objects, but
102102
// if a warning comes up for an enclosing synthetic field we have to
103103
// put it somewhere. So pick an accessor.
104+
/// TODO: testcase based on timezone 0.8.0 (env.dart:timeZoneDatabase)
104105
if (element.isSynthetic) {
105-
if (hasExplicitGetter) return getter!.characterLocation;
106-
if (hasExplicitSetter) return setter!.characterLocation;
106+
if (hasGetter) {
107+
if (!getter!.isSynthetic) warn(PackageWarning.noCanonicalFound, message: 'Getter for synthetic is not synthetic: $element');
108+
if (!getter!.isPublic) warn(PackageWarning.noCanonicalFound, message: 'Getter for synthetic is not public: $element');
109+
return getter!.characterLocation;
110+
}
111+
if (hasSetter) {
112+
if (!setter!.isSynthetic) warn(PackageWarning.noCanonicalFound, message: 'Setter for synthetic is not synthetic: $element');
113+
if (!setter!.isPublic) warn(PackageWarning.noCanonicalFound, message: 'Setter for synthetic is not public: $element');
114+
return setter!.characterLocation;
115+
}
107116
assert(false, 'Field and accessors can not all be synthetic: $element');
108117
}
109118
return super.characterLocation;
@@ -175,7 +184,7 @@ mixin GetterSetterCombo on ModelElement {
175184
@override
176185
bool get hasDocumentationComment =>
177186
_getterSetterDocumentationComment.isNotEmpty ||
178-
element.documentationComment != null;
187+
element.documentationComment != null;
179188

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

0 commit comments

Comments
 (0)