Skip to content

Fix type NamedArg of annotations when pt is nullable #11974

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

Merged
merged 1 commit into from
Apr 5, 2021

Conversation

noti0na1
Copy link
Member

@noti0na1 noti0na1 commented Apr 3, 2021

Thie PR fixs typing NamedArg of annotations when pt is nullable.

scalac -Yexplicit-nulls Jtest.java
public class Jtest {
  @SuppressWarnings("unused")
  public void f() {}
}

Without the fix:

-- [E007] Type Mismatch Error: Jtest.java:2:19 ---------------------------------
2 |  @SuppressWarnings("unused")
  |                   ^
  |                   Found:    ("SuppressWarnings" : String)
  |                   Required: scala.Array[String | scala.Null] | scala.Null

Since the argument type of the annotation is nullable under explicit nulls, we need to strip the Null type first in order to try the Array transformation.

@noti0na1 noti0na1 requested a review from odersky April 3, 2021 07:14
@noti0na1 noti0na1 enabled auto-merge April 3, 2021 08:27
@noti0na1 noti0na1 merged commit 16776c8 into scala:master Apr 5, 2021
@noti0na1 noti0na1 deleted the fix-namedArg-nullable branch April 5, 2021 10:15
@Kordyjan Kordyjan added this to the 3.0.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.

3 participants