Relax flow typing checks on Flexible Types#24278
Conversation
e676a80 to
0b71e50
Compare
|
I don't agree reporting warnings for I would also not make flexible type a "notnull" type. It can have null value by definition... |
|
It may be that flow typing should use a different version of |
|
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 = null
result = bint.multiply(bint)
result.longValuegives an error for accessing longValue. Having the change allows the access, but gives a warning if we use .nn.
If so, we could make it so that we don't give warnings if the .nn is on a FlexibleType. |
b1afe8a to
6817e7f
Compare
6817e7f to
3f2b3e5
Compare
These changes allow flow-typing to view flexible types as non-nullable at relevant places.
Without this PR, the access of trim on result will give an error. This pattern is used in community build projects like sconfig.
After this change, calling .nn on a flexible type directly will still not give a warning, as intended.
However, calling .nn on a variable that is previously flow typed to be a flexible type will now give a warning as a side effect of this change. We believe that the benefits of this change outweigh the drawback.