linter
linter copied to clipboard
comment_references broken when using super parameters
When migrating the below code to use_super_parameters, the references to ctor paramaters in doc comments are now flagged with the comment_references hint.
class PartBuilder extends _Builder {
/// Wrap [generators] as a [Builder] that generates `part of` files.
///
/// [generatedExtension] indicates what files will be created for each
/// `.dart` input. The [generatedExtension] should *not* be `.g.dart`. If you
/// wish to produce `.g.dart` files please use [SharedPartBuilder].
///
/// If any generator in [generators] will create additional outputs through
/// the [BuildStep] they should be indicated in [additionalOutputExtensions].
///
/// [formatOutput] is called to format the generated code. Defaults to
/// [DartFormatter.format].
///
/// [header] is used to specify the content at the top of each generated file.
/// If `null`, the content of [defaultFileHeader] is used.
/// If [header] is an empty `String` no header is added.
///
/// [allowSyntaxErrors] indicates whether to allow syntax errors in input
/// libraries.
///
/// If available, the `build_extensions` option will be extracted from
/// [options] to allow output files to be generated into a different directory
PartBuilder(
super.generators,
String generatedExtension, {
super.formatOutput,
super.additionalOutputExtensions,
super.header,
super.allowSyntaxErrors,
super.options,
}) : super(
generatedExtension: generatedExtension,
);
}
@jcollins-g @srawlins – any idea if things still work w/ DartDoc here?
I'm not sure.
FYI: I just confirmed that dartdoc "does the right thing" here. So it's just lint weirdness, it seems!
Also, here's a test case that should pass, but doesn't at current HEAD
class G {
G({required int paramA, required int paramB});
}
/// [paramA] is better than [paramB].
///
/// At least to have a regression test for
/// https://github.com/dart-lang/linter/issues/3563.
class H extends G {
H({required super.paramA, required super.paramB});
}
Sounds like it might be an analyzer issue, where the comment reference is not being linked to its corresponding static element.
Potentially blocking #3911
Updated repro:
class G {
G({required int p1, required int p2});
}
class H extends G {
/// [p1] is better than [p2].
H({required super.p1, required super.p2});
}
Fixed by https://github.com/dart-lang/sdk/commit/80ad96837c207bb1d74c8c54e7387b9e6b7093df
Woohoo!