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

Set ACC_FINAL access flag to final variable accessors #15707

Merged
merged 1 commit into from
Aug 4, 2022

Conversation

WojciechMazur
Copy link
Contributor

@WojciechMazur WojciechMazur commented Jul 19, 2022

Fixes #10835
ACC_FINAL flag was never set for the accessors - they were filtered out by !sym.is(Mutable) condition

Copy link
Contributor

@odersky odersky left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -310,7 +310,7 @@ class BTypesFromSymbols[I <: DottyBackendInterface](val int: I) extends BTypes {
// tests/run/serialize.scala and https://github.com/typelevel/cats-effect/pull/2360).
val privateFlag = !sym.isClass && (sym.is(Private) || (sym.isPrimaryConstructor && sym.owner.isTopLevelModuleClass))

val finalFlag = sym.is(Final) && !toDenot(sym).isClassConstructor && !sym.is(Mutable) && !sym.enclosingClass.is(Trait)
val finalFlag = sym.is(Final) && !toDenot(sym).isClassConstructor && (!sym.is(Mutable) || sym.is(Accessor)) && !sym.enclosingClass.is(Trait)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
val finalFlag = sym.is(Final) && !toDenot(sym).isClassConstructor && (!sym.is(Mutable) || sym.is(Accessor)) && !sym.enclosingClass.is(Trait)
val finalFlag = sym.is(Final) && !toDenot(sym).isClassConstructor && !sym.is(Mutable, butNot = Accessor) && !sym.enclosingClass.is(Trait)

Copy link
Contributor

Choose a reason for hiding this comment

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

This is slightly shorter and more efficient, but not sure it's worth it actually.

@WojciechMazur WojciechMazur force-pushed the fix/i10835-final-vars branch from eab6d19 to 51be2dd Compare August 1, 2022 09:09
@WojciechMazur WojciechMazur merged commit cfd91d4 into scala:main Aug 4, 2022
@WojciechMazur WojciechMazur deleted the fix/i10835-final-vars branch August 4, 2022 10:18
@Kordyjan Kordyjan added this to the 3.2.1 milestone Aug 2, 2023
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.

A final var's accessors aren't final
3 participants