Warn-unused uses type alias in nesting check#6190
Conversation
0c2c7ec to
c16f1ce
Compare
There was a problem hiding this comment.
Is this the best one can do?
There was a problem hiding this comment.
tp.typeSymbolDirect.isAliasType?
There was a problem hiding this comment.
That pulls in too much, it turns out. I tried various isNonClassType etc, so mostly I don't actually understand the API.
There was a problem hiding this comment.
That pulls in too much
Can you give an example?
There was a problem hiding this comment.
In constructors you see:
[log typer] ALIAS C.super.type/class scala.reflect.internal.Types$UniqueSuperType/class C/type AnyRef primary constructor C
[log typer] C.super.type referenced from primary constructor C
with the false negative for object X { private class C }. So the AnyRef is the Direct.isAliasType, defined as an alias of Object.
I guess it's sufficient to also check isLocal || isPrivate.
A reference from the body of a class is not a usage of the class, but a reference to a local type alias of it is a usage of the type alias.
c16f1ce to
f223a7e
Compare
The call has the form, `qual.withFilter(check$refutable => body)`
where the body is `{ case mypat => true }` which must always
spuriously warn about any pattern variables.
Notice ConstantType and record it under -Ywarn-unused.
Although vars have setters, it's more uniform to report that the private var is not updated. (It's not possible that the setter is overriding a synthetic setter for a var, so there can be no ambiguity.)
Incremental compilation while erroring can result in unpositioned trees. Parser preserves the escape hatch attachment under patdef transform. Both casedef and valdef can test immediately if escape hatch was requested. Add attachment for valdefs resulting from patvardefs. When checking for redundant unused setters, try to compare using accessed, otherwise compare names.
|
this seems to have been forgotten about. can you suggest a reviewer? |
|
@SethTisue I believe the community that wants the fix will step up to review it! I believe in the community! |
hrhino
left a comment
There was a problem hiding this comment.
Just because you asked.
It might be cool to add the ticket references in somewhere for future retrospective capabilities.
There was a problem hiding this comment.
I assume this is UNIX for copy? It seems strange that cpAtBoundAttachment only adds the attachment if from has it but cpPatVarDefAttachments unconditionally adds PatVarDefAttachment.
There was a problem hiding this comment.
One propagates whether the syntax was x @ _, the other adds that this is a patvar. There is doc over in TypeDiag.
I would justify cp by persistence of mk for make and similar, which are not due to a subculture. I do resist long names, and these are long.
I think I will shave my beard now and maybe go get a hair cut.
Don't add attachments when not warning. Avoid warning when already in error.
SethTisue
left a comment
There was a problem hiding this comment.
this all looks plausible to me, but maybe one more pair of eyes on the attachments stuff.
| import scala.util.control.Exception.ultimately | ||
| import symtab.Flags._ | ||
| import PartialFunction._ | ||
| import PartialFunction.{condOpt => whenever} |
There was a problem hiding this comment.
Seth's nit: I know, condOpt isn't the greatest name, but it's the name we have, I don't think we should indulge ourselves in arbitrary local renamings like this
There was a problem hiding this comment.
I know what you mean. Paulp once said those methods where the most underlooked of his contributions, and I think it's partly the names. Maybe we can fix that.
|
I need another session to exercise the last commit. While debugging the underlying issue, I realized I know nothing. |
|
And we're back under 2,100 issues in scala/bug! |
|
🙀 |
|
I'll create a few new issues to address @SethTisue 's nits. Is there a "nit" label? |
|
very glad to see this crossing the finish line! 🎉 thanks Som, greatly appreciate your ongoing commitment to this unused warnings work, it's a real boon for code quality community-wide |
|
I won't rest until all the code is used. |
|
no child (in any abstract syntax tree) left behind |
|
"I speak for the trees." - The Lorax. |
|
Looks like this regressed for a local val captured in a CBN closure: nok: ok: |
|
thanks @som-snytt ... (Actually this might have been a bug in my compiler plugin...) |
* split the Conseil configurations * use typed objects in PlatformDiscovery and separate from the confguration file parsing * use imports to get config readers into scope * create custom readers for platforms * wrap lightbend config for the host pool in a configuration class * fix residuals compilation errors from the merge * upgrade pureconfig version, improving the available api * upgrade scala version to latest, which fix scala/scala#6190
A reference from the body of a class is not a usage
of the class, but a reference to a local type alias of it
is a usage of the type alias.
Also don't warn about filter for refutable pattern.
Also
classOf[C]is a usage ofC.Simplify message for a
varthat isn't mutated.Fixes scala/bug#10623
Fixes scala/bug#10394
Fixes scala/bug#9058
Fixes scala/bug#10282
Fixes scala/bug#10448