Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sealed and non-sealed modifiers and permitted types not accessible through ITypeBinding #3252

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

subyssurendran666
Copy link
Contributor

@subyssurendran666 subyssurendran666 commented Nov 5, 2024

Added the unit tests and added the modifiers to the resolve bindings for sealed and non-sealed modifiers

What it does

The 'sealed' and 'non-sealed' modifiers are visible and accessible through the AST, but not when trying to get the same information with the associated type binding. Therefore added the modifiers in the TypeBiding for the sealed and non-sealed modifiers.

How to test

This PR closes #3178

Author checklist

@subyssurendran666 subyssurendran666 force-pushed the sealed-modifiers-and-permitted-types-not-accessible-through-ITypeBinding-3178 branch from e45f07a to 178a88c Compare November 5, 2024 13:39
if (referenceBinding.isAnonymousType()) {
return accessFlags & ~Modifier.FINAL;
} else if (referenceBinding.isSealed()) {
return Modifier.SEALED;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is wrong. With this, we are discarding every other bit in accessFlags.

} else if (referenceBinding.isSealed()) {
return Modifier.SEALED;
} else if (referenceBinding.isNonSealed()) {
return Modifier.NON_SEALED;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

@@ -133,4 +127,64 @@ void main() {
assertEquals("Not a Block", block.getNodeType(), ASTNode.BLOCK);
assertEquals("Block startPosition is not correct", block.getStartPosition(), 21);
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would help if you can select just the newly added code block and format, to keep it in line with our formatting preferences.

astParser.setBindingsRecovery(true);

String source ="""
sealed class A permits B, C {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want to add some more modifiers and test for their presence in the output. For e.g.
public sealed abstract class A permits B, C {}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[dom binding] JEP 409 - sealed modifiers and permitted types not accessible through ITypeBinding
2 participants