Skip to content

Commit 0e8cf52

Browse files
committed
Rename attachment to NoWarn
Simple rename to `NoWarnAttachment`. It is still used selectively to turn off unused warning for pattern variables.
1 parent 41d81b1 commit 0e8cf52

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

src/compiler/scala/tools/nsc/ast/parser/Parsers.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1969,7 +1969,7 @@ self =>
19691969
atPos(p.pos.start, p.pos.start, body.pos.end) {
19701970
val t = Bind(name, body)
19711971
body match {
1972-
case Ident(nme.WILDCARD) if settings.warnUnusedPatVars => t updateAttachment AtBoundIdentifierAttachment
1972+
case Ident(nme.WILDCARD) if settings.warnUnusedPatVars => t updateAttachment NoWarnAttachment
19731973
case _ => t
19741974
}
19751975
}

src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ trait TypeDiagnostics {
8080
}
8181

8282
// Bind of pattern var was `x @ _`
83-
private def atBounded(t: Tree) = t.hasAttachment[AtBoundIdentifierAttachment.type]
83+
private def atBounded(t: Tree) = t.hasAttachment[NoWarnAttachment.type]
8484

8585
// ValDef was a PatVarDef `val P(x) = ???`
8686
private def wasPatVarDef(t: Tree) = t.hasAttachment[PatVarDefAttachment.type]

src/reflect/scala/reflect/internal/StdAttachments.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,12 @@ trait StdAttachments {
6464
case object BackquotedIdentifierAttachment extends PlainAttachment
6565

6666
/** A pattern binding exempt from unused warning.
67-
*
68-
* Its host `Ident` has been created from a pattern2 binding, `case x @ p`.
69-
* In the absence of named parameters in patterns, allows nuanced warnings for unused variables.
70-
* Hence, `case X(x = _) =>` would not warn; for now, `case X(x @ _) =>` is documentary if x is unused.
71-
*/
72-
case object AtBoundIdentifierAttachment extends PlainAttachment
67+
*
68+
* Its host `Ident` has been created from a pattern2 binding, `case x @ p`.
69+
* In the absence of named parameters in patterns, allows nuanced warnings for unused variables.
70+
* Hence, `case X(x = _) =>` would not warn; for now, `case X(x @ _) =>` is documentary if x is unused.
71+
*/
72+
case object NoWarnAttachment extends PlainAttachment
7373

7474
/** Indicates that a `ValDef` was synthesized from a pattern definition, `val P(x)`.
7575
*/

src/reflect/scala/reflect/internal/TreeGen.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -732,19 +732,19 @@ abstract class TreeGen {
732732
def mkPatDef(pat: Tree, rhs: Tree)(implicit fresh: FreshNameCreator): List[ValDef] =
733733
mkPatDef(Modifiers(0), pat, rhs)
734734

735-
private def propagateAtBoundAttachment(from: Tree, to: ValDef): to.type =
736-
if (isPatVarWarnable && from.hasAttachment[AtBoundIdentifierAttachment.type]) to.updateAttachment(AtBoundIdentifierAttachment)
735+
private def propagateNoWarnAttachment(from: Tree, to: ValDef): to.type =
736+
if (isPatVarWarnable && from.hasAttachment[NoWarnAttachment.type]) to.updateAttachment(NoWarnAttachment)
737737
else to
738738

739739
// Keep marker for `x@_`, add marker for `val C(x) = ???` to distinguish from ordinary `val x = ???`.
740740
private def propagatePatVarDefAttachments(from: Tree, to: ValDef): to.type =
741-
propagateAtBoundAttachment(from, to).updateAttachment(PatVarDefAttachment)
741+
propagateNoWarnAttachment(from, to).updateAttachment(PatVarDefAttachment)
742742

743743
/** Create tree for pattern definition <mods val pat0 = rhs> */
744744
def mkPatDef(mods: Modifiers, pat: Tree, rhs: Tree)(implicit fresh: FreshNameCreator): List[ValDef] = matchVarPattern(pat) match {
745745
case Some((name, tpt)) =>
746746
List(atPos(pat.pos union rhs.pos) {
747-
propagateAtBoundAttachment(pat, ValDef(mods, name.toTermName, tpt, rhs))
747+
propagateNoWarnAttachment(pat, ValDef(mods, name.toTermName, tpt, rhs))
748748
})
749749

750750
case None =>
@@ -815,7 +815,7 @@ abstract class TreeGen {
815815

816816
private def unwarnable(pat: Tree): Tree = {
817817
pat foreach {
818-
case b @ Bind(_, _) => b updateAttachment AtBoundIdentifierAttachment
818+
case b @ Bind(_, _) => b updateAttachment NoWarnAttachment
819819
case _ =>
820820
}
821821
pat
@@ -917,7 +917,7 @@ abstract class TreeGen {
917917
case Ident(name) if treeInfo.isVarPattern(tree) && name != nme.WILDCARD =>
918918
atPos(tree.pos) {
919919
val b = Bind(name, atPos(tree.pos.focus) (Ident(nme.WILDCARD)))
920-
if (forFor && isPatVarWarnable) b updateAttachment AtBoundIdentifierAttachment
920+
if (forFor && isPatVarWarnable) b updateAttachment NoWarnAttachment
921921
else b
922922
}
923923
case Typed(id @ Ident(name), tpt) if treeInfo.isVarPattern(id) && name != nme.WILDCARD =>

src/reflect/scala/reflect/runtime/JavaUniverseForce.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ trait JavaUniverseForce { self: runtime.JavaUniverse =>
4040
this.SAMFunction
4141
this.DelambdafyTarget
4242
this.BackquotedIdentifierAttachment
43-
this.AtBoundIdentifierAttachment
43+
this.NoWarnAttachment
4444
this.PatVarDefAttachment
4545
this.ForAttachment
4646
this.SyntheticUnitAttachment

0 commit comments

Comments
 (0)