Skip to content

Default arguments of final method are not final #17519

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

Open
nicolasstucki opened this issue May 16, 2023 · 2 comments
Open

Default arguments of final method are not final #17519

nicolasstucki opened this issue May 16, 2023 · 2 comments

Comments

@nicolasstucki
Copy link
Contributor

Compiler version

3.0.0 to 3.3.0-RC4

Minimized example

class A:
  final def foo(x: Int = 1): Any = ???

Output

Compiled with -Xprint:typer shows

[[syntax trees at end of                     typer]] 
package <empty> {
  class A() extends Object() {
    final def foo(x: Int): Any = ???
    def foo$default$1: Int @uncheckedVariance = 1
  }
}

Expectation

Default argument methods of final methods should be final.

class A() extends Object() {
  final def foo(x: Int): Any = ???
  final def foo$default$1: Int @uncheckedVariance = 1
}
@sjrd
Copy link
Member

sjrd commented May 16, 2023

That is unfortunate. I don't think we can fix this in 3.x. If we fix it, when libraries upgrade, they will have plenty of MiMa errors for all their default accessor methods, and there will be nothing they can do about them except adding zillions of filters.

@dwijnand
Copy link
Member

We could teach MiMa to account for fixing this.

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

No branches or pull requests

4 participants