typelevel / sbt-tpolecat

scalac options for the enlightened
Apache License 2.0
394 stars 54 forks source link

Scala 3's -Yexplicit-nulls #188

Open alexandru opened 1 year ago

alexandru commented 1 year ago

Hello,

I noticed that version 0.5.0 doesn't enable -Yexplicit-nulls on Scala 3.

Any reasons for it?

armanbilge commented 1 year ago

Is it ready for use? e.g. @SethTisue on Discord a few months ago:

seconded that -Yexplicit-nulls isn't really that usable yet, but I just want to note that it's being worked on: https://github.com/lampepfl/dotty/pull/18112

https://discord.com/channels/632150470000902164/632150470000902166/1131611679566872698

SethTisue commented 1 year ago

Anyway, in general -Y flags should be considered guilty until proven innocent. -Y is a signal that something is internal and/or not-ready-for-prime-time

alexandru commented 1 year ago

I'd enable it 🤷‍♂️

sbt-tpolecat is a plugin that enables errors in case of unused imports or unused variables, and there's nothing more annoying than that.

The “platform types” in Kotlin are well implemented, as the compiler is also looking at @NonNull and @Nullable annotations from Java's ecosystem. I hope that Scala implements that as well, but meanwhile, while we're waiting, I want explicit nulls for protection against Java APIs, and I don't mind using .nn all over the place.

armanbilge commented 1 year ago

IMHO this issue also seems like a major impediment to using explicit nulls.

This use of Option is idiomatic for handling possibly-null values, so it seems ironic that it isn't available when using explicit nulls.

alexandru commented 1 year ago

That untagged unions aren't used yet in the stdlib is such a pity, as it would improve type safety by a lot.

kubukoz commented 3 weeks ago

Anyway, in general -Y flags should be considered guilty until proven innocent. -Y is a signal that something is internal and/or not-ready-for-prime-time

honestly the compiler/language doesn't do a great job at marketing this, I've worked in scala for 9 years and it's the first time I'm hearing that these aren't prime time 😅