implicit_reopen
loophole
#59124
Labels
area-devexp
For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.
devexp-linter
Issues with the analyzer's support for the linter package
linter-false-negative
P2
A bug or feature request we're likely to work on
type-bug
Incorrect behavior (everything from a crash to more subtle misbehavior)
Summary
It is possible for a class to inherit an instance member implementation from an
interface
class in another library without getting any lint messages fromimplicit_reopen
. This should not happen.Example
This behavior is exhibited with the following program (consisting of two user-written libraries 'lib.dart' and 'main.dart'):
The program is accepted with no diagnostic messages when processed by
dart analyze main.dart
(e34daa8), with the followinganalysis_options.yaml
:Analysis
The feature specification rules are as follows: An
implicit_reopen
lint, if enabled, should be emitted when a classC
is not annotated with@reopen
, and it satisfies any of the following:interface
orfinal
and is not itself markedinterface
orfinal
, orsealed
class which itself transitively extends a class markedinterface
orfinal
.In the example, the superclass of
B
isA with M
.If you prefer to consider the situation in terms of implicitly induced class modifiers, the mixin application
A with M
is implicitlyinterface
, because theinterface
property is propagated from the superclass to the mixin application (it would also be propagated from the mixin, except that a mixin can't beinterface
). So we need the lint because the superclassA with M
isinterface
, but the classB
itself is not.If we insist that implicitly induced class modifiers do not exist then we will need to say that
B
extendsA
, notA with M
, and we would then again require a@reopen
annotation or aninterface
(or stronger) annotation onB
, becauseA
isinterface
andB
is not.In any case, there should be a diagnostic message from
implicit_reopen
in the case where a class (likeC
above) can inherit an instance member implementation from aninterface
(or stronger) class in a different library (likeA
above), and no@reopen
annotation is encountered at the point where theinterface
property is dropped and the member is still inherited.Expected behavior
A lint message is emitted at the declaration of the class
B
. Currently, no such message is emitted.The text was updated successfully, but these errors were encountered: