-
Notifications
You must be signed in to change notification settings - Fork 21
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
False positive ambiguity warning #12816
Comments
I'm not sure why it's a false positive. But I've forgotten how the spec of the new ambiguity was worded. I think the intuition is that if The definition is available by virtue of packaging (albeit in the same unit). By my formulation, that inherited and packaged have the same precedence, then it's a false positive. But I would be inclined to tweak that, to say inherited is lower precedence than all defs local to the unit. (Inherited members can come from anywhere, all the more reason to distrust them.) In different units, it should not warn, so that's clearly a false positive. |
As you say, the reported example warns when
My intuition to warn was not "adding an inherited So this does not warn, even though trait P { trait T }
trait U { trait T }
object O extends P {
trait C extends U {
def t: T // no warn (good)
}
} This next one doesn't warn, maybe that's a bug? Anyway this is a corner case, package objects are typically defined in separate files, which should not warn. package object p { def m = 0 }
package p {
trait T { def m = 1 }
class C extends T { def t = m } // no warn (unclear?)
} About the spec, we have something in comments: https://github.com/scala/scala/blob/v2.13.11/spec/02-identifiers-names-and-scopes.md?plain=1#L20-L27 Below both trait P { trait T }
trait U { trait T }
object O extends P {
trait C extends U {
def t: T // no warn (good)
}
} Here is again the original example of this report. I'm not sure if trait U { def m: Int = 0 }
package object p extends U
package p {
trait T { def m = 1 }
class C extends T { def t = m }
} Finally, I guess here trait U { trait T }
object O {
trait T
trait C extends U {
def t: T
}
} Confusing to me is that "local" in the spec for precedence (does it have a definition?) is not the same as "local" in section 4 (https://github.com/scala/scala/blob/v2.13.11/spec/04-basic-declarations-and-definitions.md?plain=1#L26-L30) 🤷♂️ |
I remember one of my edits removed the "local" before it was restored. My question, which you answered nicely, is perhaps about what "local" means. The other part of the intuition is that you can see it. What you can see is more intentional than what is concealed (by virtue of a separate file). I bet ten or 15 years ago, you did not expect this would be the conversation in 2023. |
With 2.13.11 and
-Xsource:3
, this emits a false ambiguity warning:The text was updated successfully, but these errors were encountered: