-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add warnings for inferred flexible types in public methods and fields #23880
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
if ctx.phase.isTyper && ctx.explicitNulls && !ctx.isJava | ||
&& sym.exists && sym.isPublic && sym.owner.isClass | ||
&& !sym.isOneOf(Synthetic | InlineProxy | Param) then | ||
val resTp = sym.info.finalResultType |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the case of a method, should we also warn if the parameter types are flexible? Or can that never happen for some reason?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's possible to infer parameter types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise this LGTM, but let's wait for the CI.
Report warning if a public method/field exposes FlexibleType in its result type under explicit nulls and encourage explicit annotation.
According to the discussion in #23682