@@ -47,6 +47,14 @@ object desugar {
4747 */
4848 val UntupledParam : Property .Key [Unit ] = Property .StickyKey ()
4949
50+ /** An attachment key to indicate that a ValDef originated from a pattern.
51+ */
52+ val PatternVar : Property .Key [Unit ] = Property .StickyKey ()
53+
54+ /** An attachment key for Trees originating in for-comprehension, such as tupling of assignments.
55+ */
56+ val ForArtifact : Property .Key [Unit ] = Property .StickyKey ()
57+
5058 /** An attachment key to indicate that a ValDef is an evidence parameter
5159 * for a context bound.
5260 */
@@ -1507,7 +1515,7 @@ object desugar {
15071515 val matchExpr =
15081516 if (tupleOptimizable) rhs
15091517 else
1510- val caseDef = CaseDef (pat, EmptyTree , makeTuple(ids))
1518+ val caseDef = CaseDef (pat, EmptyTree , makeTuple(ids).withAttachment( ForArtifact , ()) )
15111519 Match (makeSelector(rhs, MatchCheck .IrrefutablePatDef ), caseDef :: Nil )
15121520 vars match {
15131521 case Nil if ! mods.is(Lazy ) =>
@@ -1537,6 +1545,7 @@ object desugar {
15371545 ValDef (named.name.asTermName, tpt, selector(n))
15381546 .withMods(mods)
15391547 .withSpan(named.span)
1548+ .withAttachment(PatternVar , ())
15401549 )
15411550 flatTree(firstDef :: restDefs)
15421551 }
@@ -1922,6 +1931,7 @@ object desugar {
19221931 val vdef = ValDef (named.name.asTermName, tpt, rhs)
19231932 .withMods(mods)
19241933 .withSpan(original.span.withPoint(named.span.start))
1934+ .withAttachment(PatternVar , ())
19251935 val mayNeedSetter = valDef(vdef)
19261936 mayNeedSetter
19271937 }
@@ -2167,7 +2177,7 @@ object desugar {
21672177 case _ => Modifiers ()
21682178 makePatDef(valeq, mods, defpat, rhs)
21692179 }
2170- val rhs1 = makeFor(nme.map, nme.flatMap, GenFrom (defpat0, gen.expr, gen.checkMode) :: Nil , Block (pdefs, makeTuple(id0 :: ids)))
2180+ val rhs1 = makeFor(nme.map, nme.flatMap, GenFrom (defpat0, gen.expr, gen.checkMode) :: Nil , Block (pdefs, makeTuple(id0 :: ids).withAttachment( ForArtifact , ()) ))
21712181 val allpats = gen.pat :: pats
21722182 val vfrom1 = GenFrom (makeTuple(allpats), rhs1, GenCheckMode .Ignore )
21732183 makeFor(mapName, flatMapName, vfrom1 :: rest1, body)
0 commit comments