-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Lint function arrow intended context function #23847
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
@@ -168,6 +168,7 @@ private sealed trait WarningSettings: | |||
private val WunstableInlineAccessors = BooleanSetting(WarningSetting, "WunstableInlineAccessors", "Warn an inline methods has references to non-stable binary APIs.") | |||
private val WtoStringInterpolated = BooleanSetting(WarningSetting, "Wtostring-interpolated", "Warn a standard interpolator used toString on a reference type.") | |||
private val WrecurseWithDefault = BooleanSetting(WarningSetting, "Wrecurse-with-default", "Warn when a method calls itself with a default argument.") | |||
private val WdubiousContextual = BooleanSetting(WarningSetting, "Wdubious-contextual", "Warn about T ?=> (t: T) => U.") |
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.
private val WdubiousContextual = BooleanSetting(WarningSetting, "Wdubious-contextual", "Warn about T ?=> (t: T) => U.") | |
private val WunlikelyContextual = BooleanSetting(WarningSetting, "Wunlikely-contextual", "Warn about T ?=> (t: T) => U. when a normal function literal was used instead of context one."), |
just because the word is prone to typos for non english speakers and a bit more explanation aside from signature?
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 rely on -Xlint
or now -Wall
. Though I do like the word "dubious". All warnings are dubious because they begin with -W
or "dubya".
object Zone: | ||
inline def apply[T](inline f: Zone ?=> T): T = f(using new Zone) | ||
|
||
inline def zone[A](inline f: Zone ?=> A) = Zone.apply(z => f(using z)) // warn suspicious contextualizing |
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.
Will this be reported with:
def zone[A](f: Zone ?=> A) = Zone.apply(z => f(using z))
as well? Maybe the warning should only be for the inline cases, where it might cause most issues.
What do you think?
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 think it's the same issue, which is that the function literal is wrapped in a context function. I added it to the test to document the behavior is the same.
4684bed
to
f1d5ced
Compare
Fixes #21187
If a function literal
x => body
has an expected typeX ?=> ?
then maybe they intended to writex ?=> body
.As shown in the test, maybe types will misalign in other ways to emit warnings.