Skip to content

Conversation

SuperCl4sh
Copy link
Contributor

An extension to #23461 that adds a quick fix to add a .nn. For example, if the code were

val t: String | Null = ???
val s: String = t

the quick fix would transform the code to

val t: String | Null = ???
val s: String = t.nn

The code is WIP (I've put some ugly workarounds to get it to work). Right now, it adds brackets whenever the root node is an Apply. This is needed for infix functions (both those with ApplyKind InfixTuple and those that are written as such in the source code, such as + which is desugared to an ApplyKind Regular I think), but there may be other edge cases where brackets are needed. I've discussed these edges cases a bit with @olhotak and @HarrisL2, but it's possible that we've missed some (or I've forgotten to add them).

@SuperCl4sh SuperCl4sh marked this pull request as draft July 24, 2025 18:45
@SuperCl4sh SuperCl4sh marked this pull request as ready for review July 25, 2025 18:23
@HarrisL2
Copy link
Contributor

cc @noti0na1

…es for in-line match and if, improve formatting, and add more test

Signed-off-by: Seyon Sivatharan <[email protected]>
@SuperCl4sh SuperCl4sh requested a review from noti0na1 August 7, 2025 21:22
@SuperCl4sh
Copy link
Contributor Author

All the issues should be resolved now.

@noti0na1
Copy link
Member

I was on vocation in last few weeks. I will review it soon.

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 d860725 into scala:main Aug 13, 2025
45 checks passed
@tgodzik
Copy link
Contributor

tgodzik commented Sep 1, 2025

Tried backposting the PR, but got:

[info] compiling 92 Scala sources and 25 Java sources to /Users/tgodzik/Documents/scala3/out/bootstrap/scala3-library-bootstrapped/scala-3.3.8-RC1-bin-SNAPSHOT-nonbootstrapped/classes ...
[error] -- Error: /Users/tgodzik/Documents/scala3/library/src/scala/IArray.scala:259:85 
[error] 259 |    def ++[U >: T: ClassTag](suffix: IArray[U]): IArray[U] = genericArrayOps(arr) ++ suffix.toSeq
[error]     |                                                                                     ^
[error]     |?{ toSeq: <?> } is not a value type, cannot be used in union ?{ toSeq: <?> } | Null
[error] -- Error: /Users/tgodzik/Documents/scala3/library/src/scala/IArray.scala:272:77 
[error] 272 |    def diff[U >: T](that: IArray[U]): IArray[T] = genericArrayOps(arr).diff(that.toSeq)
[error]     |                                                                             ^
[error]     |?{ toSeq: <?> } is not a value type, cannot be used in union ?{ toSeq: <?> } | Null
[error] -- Error: /Users/tgodzik/Documents/scala3/library/src/scala/IArray.scala:298:77 
[error] 298 |    def search[U >: T](elem: U)(using Ordering[U]): Searching.SearchResult = arr.toSeq.search(elem)
[error]     |                                                                             ^
[error]     |?{ toSeq: <?> } is not a value type, cannot be used in union ?{ toSeq: <?> } | Null
[error] -- Error: /Users/tgodzik/Documents/scala3/library/src/scala/IArray.scala:299:97 
[error] 299 |    def search[U >: T](elem: U, from: Int, to: Int)(using Ordering[U]): Searching.SearchResult = arr.toSeq.search(elem, from, to)

Most likely due to some other changes that were not backported. With experimental stuff like this we should be fine.

@SuperCl4sh
Copy link
Contributor Author

That's quite weird. We had that issue before pushing 6c2147d, but it shouldn't be an issue anymore because we only OrNull a type when we know it's a value type (https://github.com/scala/scala3/pull/23598/files#diff-e054695755ff26925ae51361df0f7cd4940bc1fd7ceb658023d0dc38c18178c3R305-R306).
Can you send the git log (via a text file or pastebin) so I can take a closer look at the commits? (or you can push your code and send the link, whichever is easier for you)

@tgodzik
Copy link
Contributor

tgodzik commented Sep 1, 2025

ach, that might be it. I didn't realize it was a temporary issue. Ideally we would squash in those situations. I will try and backport it again next week.

WojciechMazur added a commit that referenced this pull request Sep 20, 2025
Backports #23598 to the 3.7.4.

PR submitted by the release tooling.
[skip ci]
@WojciechMazur WojciechMazur added this to the 3.7.4 milestone Sep 23, 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.

5 participants