Repository navigation
Fix crash on the automated visibility keyword - #472
Open
adityaanikam wants to merge 1 commit into
Open
adityaanikam wants to merge 1 commit into
adityaanikam wants to merge 1 commit into
Conversation
FLuzzi-csw
reviewed
Sep 30, 2026
The grammar accepts an automated visibility section, but VisibilityNodeImpl.getVisibility had no case for it and threw an AssertionError, which aborted the scan of any file that contained one. Add an AUTOMATED VisibilityType instead of treating it as PUBLIC, because ConsecutiveVisibilitySectionCheck compares visibilities by identity and a public section followed by an automated one was reported as consecutive. Visibility.isPublic also returns true for automated members so name resolution and the unused-code checks treat them as before, VisibilitySectionOrderCheck ranks automated with public, and a generic constructor constraint accepts an automated default constructor.
adityaanikam
force-pushed
the
fix-automated-visibility-crash
branch
from
October 1, 2026 18:20
ea84e4b to
f8406ab
Compare
cirras
self-requested a review
October 2, 2026 00:54
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.
Fixes #471
The grammar accepts an
automatedvisibility section and builds aVisibilityNodefor it, butVisibilityNodeImpl.getVisibilityhad no case for that token type and threwAssertionError: Visibility node has unexpected token type: AUTOMATED. That aborted the scan of any file with an automated section.This adds an
AUTOMATEDvalue toVisibilityType, as suggested in review. Treating it asPUBLICwas wrong becauseConsecutiveVisibilitySectionCheckcompares visibilities by identity, so apublicsection followed by anautomatedone was reported as consecutive.What follows from the new value:
Visibility::isAutomatedis new, andVisibility::isPublicalso returnstruefor automated members, in the same wayisPublishedincludes implicit published andisProtectedincludes strict protected. Without that,NameResolverwould treat automated methods as inaccessible and the unused-code checks would stop treating them as API.VisibilitySectionOrderCheckkeeps its order in a map keyed by everyVisibilityType, so it needed an entry. I gaveautomatedthe same rank aspublic, so the two can appear in either order without an issue, andpublishedstill has to come last. I can rank it differently if you prefer.constructorconstraint is satisfied by a default constructor declared in anautomatedsection, as it is forpublic.CHANGELOG.mdlists the new API members and theisPublicchange.Testing:
VisibilityNodeImplTestcovers the visibility of every keyword plusisPublicandisAutomated.ConsecutiveVisibilitySectionCheckTesthas the public then automated case from the review, which fails on the previous mapping with a false issue, and consecutive automated sections.VisibilitySectionOrderCheckTestandConstructorConstraintTesthaveautomatedcases. All of these pass, and I ranmvn installfordelphi-frontendanddelphi-checks, including the format and license checks.