Skip to content

Apply Flexible Types to Symbols from files compiled without Explicit Nulls #22473

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 4 commits into from
Apr 11, 2025

Conversation

HarrisL2
Copy link
Contributor

This PR wraps the types of symbols from files compiled without explicit nulls in flexible types.
This allows for interop between multiple files in cases where

class Unsafe_1 {
  def foo(s: String): String = {
    if (s == null) then "nullString"
    else s
  }
}

compiled without explicit nulls can still be used in

def Flexible_2() =
  val s2: String | Null = "foo"
  val unsafe = new Unsafe_1()
  val s: String = unsafe.foo(s2)
  unsafe.foo("")
  unsafe.foo(null)

whereas the argument would have been a strictly non-null String, because of the flexible type, the function call is now permitted.

@olhotak olhotak requested a review from noti0na1 April 11, 2025 15:03
@olhotak olhotak marked this pull request as ready for review April 11, 2025 15:04
@olhotak olhotak self-requested a review April 11, 2025 15:04
@noti0na1 noti0na1 self-assigned this Apr 11, 2025
Copy link
Contributor

@olhotak olhotak left a comment

Choose a reason for hiding this comment

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

This LGTM, but @noti0na1 can you also have a look?

Copy link
Member

@noti0na1 noti0na1 left a comment

Choose a reason for hiding this comment

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

LGTM

@noti0na1 noti0na1 merged commit f4847cc into scala:main Apr 11, 2025
29 checks passed
noti0na1 added a commit that referenced this pull request Apr 13, 2025
@WojciechMazur WojciechMazur added this to the 3.7.1 milestone May 1, 2025
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.

4 participants