You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are thousands of such methods/fields. This would be an important feature to have.
In our prototype, we generated a list of standard library methods that should not return nullable values, using an annotated JDK taken from the Checker Framework.
bishabosha
changed the title
Give the correct type to methods in the Scala std library that can return null
Augment Nullability of known standard library methods
Nov 18, 2020
bishabosha
changed the title
Augment Nullability of known standard library methods
Augment Nullability of known standard library signatures
Nov 18, 2020
This would be a killer feature for adopting -Yexplicit-nulls.
I think that making it possible to narrow types in a separate library would be a good solution here. That would make it possible to fix the same issue when using other dependencies than just the Java standard library.
I would also make it possible for the community to provide the type information.
Python has https://github.com/python/typeshed and TypeScript has https://github.com/DefinitelyTyped/DefinitelyTyped wich are widely used.
This solution could be applied for other kinds of narrowing as well. For example, some methods that are returning Object today could probably be made to return a union type.
One such example is
Regex.Match#group
. I'm unsure if there are others, but would be great if the could get the correct type.The text was updated successfully, but these errors were encountered: