Skip to content

Conversation

@HarrisL2
Copy link
Contributor

These changes allow flow-typing to view flexible types as non-nullable at relevant places.

@HarrisL2 HarrisL2 requested a review from a team as a code owner October 27, 2025 17:33
@HarrisL2 HarrisL2 force-pushed the relaxFlexible branch 2 times, most recently from dfce527 to e676a80 Compare October 27, 2025 19:45
@noti0na1
Copy link
Member

I don't agree reporting warnings for .nn on flexible types, since it correctly rules out implicit nulls.

I would also not make flexible type a "notnull" type. It can have null value by definition...

@noti0na1 noti0na1 removed the request for review from a team October 28, 2025 10:43
@olhotak
Copy link
Contributor

olhotak commented Oct 29, 2025

isNotNull is used in a number of places. One of those places is flow typing. @HarrisL2 you had some specific compelling use cases from the community build that would bring a significant benefit to flow typing from this change. Can you put some of those examples (or modified illustrative examples) here in the discussion and/or as compiler tests on this PR?

It may be that flow typing should use a different version of isNotNull than some of the other places where the compiler calls isNotNull. It would be useful for us to discuss the motivating examples for flow typing.

@HarrisL2
Copy link
Contributor Author

I could not find the example where the change for isNotNull is needed. But I did find an example for the change in NullOpsDecorator.scala:50.

//> using options -Yexplicit-nulls import java.math.BigInteger def main() = val bint: BigInteger = new BigInteger( "5") var result: BigInteger | Null = bint.multiply(bint) result.longValue

gives an error for accessing longValue.

Having the change allows the access, but gives a warning if we use .nn.

I don't agree reporting warnings for .nn on flexible types, since it correctly rules out implicit nulls.

I would also not make flexible type a "notnull" type. It can have null value by definition...

If so, we could make it so that we don't give warnings if the .nn is on a FlexibleType.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants