Mark Conditional.execute overrides as @protected - #720
Open
Shubham-Padkonde wants to merge 1 commit into
Open
Shubham-Padkonde wants to merge 1 commit into
Shubham-Padkonde wants to merge 1 commit into
Conversation
Conditional.execute is declared @Protected on the base class, but Dart does not propagate the annotation to overrides: each override has to carry it. All four Conditional subclasses -- Case, ConditionalAssign, ConditionalGroup and If -- declared only @OverRide, so a call made through the subclass type was not flagged, even though the same call through a Conditional-typed reference was. Add @Protected to the four overrides so the restriction holds no matter which static type the caller uses. Fixes intel#596 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description & Motivation
Conditional.executeis already annotated@protectedon the base class, but Dart does not propagate that annotation to overrides — each override has to carry it itself. All fourConditionalsubclasses declared only@override, so the restriction quietly disappeared whenever the caller's static type was the subclass rather thanConditional.Concretely, on
mainthis code produces no analyzer complaint:With this change, both calls are flagged:
Same file analyzed either way: 4 issues without the change, 6 with it — the two new ones being exactly the calls above.
This covers all four subclasses of
Conditional(Case,ConditionalAssign,ConditionalGroup,If); I checked for others withgrep -rn "extends Conditional\b" lib/srcand there are no more.Related Issue(s)
Fixes #596
Testing
The change is annotation-only, so the analyzer is the real check here.
dart analyzeover the whole package is clean:That matters because the legitimate internal callers in
CombinationalandSequentialalready carry// ignore: invalid_use_of_protected_membercomments — tightening the overrides did not turn any of them into a new warning, and did not require adding any new ignores.dart format --output=none --set-exit-if-changedreports no changes.Tests still behave as before —
conditionals_test.dart,fsm_test.dart,comb_math_test.dartandcomb_mod_test.dartgive+31 -25, where all 25 failures areProcessException ... Command: iverilog -g2012 ...because Icarus Verilog is not installed on my machine, which CONTRIBUTING notes is required for the complete suite. CI has it.Backwards-compatibility
Not a breaking change for the simulator or generated output — annotations have no runtime effect.
It is a new analyzer warning for any downstream code that was calling
executeon a concreteConditionalsubclass from outside, which is precisely the misuse #596 asks to surface. Such code was already getting the warning when it went through aConditional-typed reference, so this makes the existing rule consistent rather than introducing a new one.Documentation
No documentation changes needed — the base class doc comment on
executealready describes it as being called byAlwaysexecution, and this just makes the annotations match that.Disclosure: this change was written by Claude Code (Claude Opus 5) working as my agent, at my direction. The analyzer output quoted above comes from real runs in my local environment; I am accountable for the content of this PR and happy to iterate on review feedback.
🤖 Generated with Claude Code