@@ -160,10 +160,6 @@ bool _rejectUnnamedAndShadowingConstructors(CommentReferable? referable) {
160
160
bool _requireCallable (CommentReferable ? referable) =>
161
161
referable is ModelElement && referable.isCallable;
162
162
163
- /// Returns false unless the passed [referable] represents a constructor.
164
- bool _requireConstructor (CommentReferable ? referable) =>
165
- referable is Constructor ;
166
-
167
163
MatchingLinkResult _getMatchingLinkElement (
168
164
String referenceText, Warnable element) {
169
165
var commentReference = ModelCommentReference .synthetic (referenceText);
@@ -174,38 +170,21 @@ MatchingLinkResult _getMatchingLinkElement(
174
170
// An "allow tree" filter to be used by [CommentReferable.referenceBy].
175
171
bool Function (CommentReferable ? ) allowTree;
176
172
177
- // Constructor references are pretty ambiguous by nature since they can be
178
- // declared with the same name as the class they are constructing, and even
179
- // if they don't use field-formal parameters, sometimes have parameters
180
- // named the same as members.
181
- // Maybe clean this up with inspiration from constructor tear-off syntax?
182
- if (commentReference.allowUnnamedConstructor) {
183
- allowTree = (_) => true ;
184
- // Neither reject, nor require, a unnamed constructor in the event the
185
- // comment reference structure implies one. (We can not require it in case
186
- // a library name is the same as a member class name and the class is the
187
- // intended lookup). For example, '[FooClass.FooClass]' structurally
188
- // "looks like" an unnamed constructor, so we should allow it here.
189
- filter = commentReference.hasCallableHint ? _requireCallable : (_) => true ;
190
- } else if (commentReference.hasConstructorHint &&
191
- commentReference.hasCallableHint) {
192
- allowTree = (_) => true ;
193
- // This takes precedence over the callable hint if both are present --
194
- // pick a constructor if and only constructor if we see `new`.
195
- filter = _requireConstructor;
196
- } else if (commentReference.hasCallableHint) {
173
+ if (commentReference.hasCallableHint) {
197
174
allowTree = (_) => true ;
198
175
// Trailing parens indicate we are looking for a callable.
199
176
filter = _requireCallable;
200
177
} else {
201
- if (! commentReference.allowUnnamedConstructorParameter) {
202
- allowTree = _rejectUnnamedAndShadowingConstructors;
203
- } else {
204
- allowTree = (_) => true ;
205
- }
206
- // Without hints, reject unnamed constructors and their parameters to force
207
- // resolution to the class.
208
- filter = _rejectUnnamedAndShadowingConstructors;
178
+ allowTree = (_) => true ;
179
+ // Neither reject, nor require, an unnamed constructor in the event the
180
+ // comment reference structure implies one. (We cannot require it in case a
181
+ // library name is the same as a member class name and the class is the
182
+ // intended lookup).
183
+ filter = commentReference.hasCallableHint
184
+ ? _requireCallable
185
+ // Without hints, reject unnamed constructors and their parameters to
186
+ // force resolution to the class.
187
+ : filter = _rejectUnnamedAndShadowingConstructors;
209
188
}
210
189
var lookupResult = element.referenceBy (commentReference.referenceBy,
211
190
allowTree: allowTree, filter: filter);
0 commit comments