Skip to content

Inline accessors should be final #15323

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

Closed
nicolasstucki opened this issue May 30, 2022 · 1 comment · Fixed by #15324
Closed

Inline accessors should be final #15323

nicolasstucki opened this issue May 30, 2022 · 1 comment · Fixed by #15324
Assignees
Milestone

Comments

@nicolasstucki
Copy link
Contributor

Compiler version

3.1.2

Minimized code

In this example, the inline accessors of B.x generated by f2 override the ones generated by f1 for A.x

class A:
  private var x = 0
  inline def f1(): Int =
    x += 1;
    x

class B extends A:
  private var x = 0
  inline def f2(): Int =
    x += 1
    x

@main def test: Unit =
  val b = new B
  println(b.f1())
  println(b.f2())

Output

1
2

Expectation

Inline accessors should be final to not allow them to be overridden intentionally or accidentally.

@nicolasstucki nicolasstucki added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label area:inline and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels May 30, 2022
@nicolasstucki nicolasstucki self-assigned this May 30, 2022
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue May 30, 2022
@nicolasstucki
Copy link
Contributor Author

Bug found by @manojo

bishabosha pushed a commit to dotty-staging/dotty that referenced this issue Oct 18, 2022
@Kordyjan Kordyjan added this to the 3.2.0 milestone Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants