Skip to content

Overriding Java method with varargs under -Yexplicit-nulls compiler error #13486

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
pweisenburger opened this issue Sep 7, 2021 · 1 comment · Fixed by #13647
Closed

Overriding Java method with varargs under -Yexplicit-nulls compiler error #13486

pweisenburger opened this issue Sep 7, 2021 · 1 comment · Fixed by #13647

Comments

@pweisenburger
Copy link
Contributor

Hi, given the following code that overrides a Java method under -Yexplicit-nulls:

class MyPrintStream extends java.io.PrintStream(??? : java.io.OutputStream):
  override def printf(format: String | Null, args: Array[? <: Object | Null])
  : java.io.PrintStream | Null = ???

The compiler produces the following error message:

Name clash between defined and inherited member:
def printf(x$0: String | Null, x$1: Array[? <: Object | Null])
  : java.io.PrintStream | Null in class PrintStream and
override def printf(format: String | Null, args: Array[? <: Object | Null])
  : java.io.PrintStream | Null in class MyPrintStream
have the same type after erasure.

It should not be an error that both methods have the same type since one is supposed to override the other.

As @smarter noted on Gitter, this might be a confusion between varargs and Array arguments.

Tested with Scala 3.0.2 and 3.1.1-RC1-bin-20210907-a47a81a-NIGHTLY

@olhotak
Copy link
Contributor

olhotak commented Sep 7, 2021

This may be related to #13040 .

@noti0na1 noti0na1 linked a pull request Oct 1, 2021 that will close this issue
@Kordyjan Kordyjan added this to the 3.1.1 milestone Aug 2, 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.

5 participants