@@ -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 */
@@ -1505,7 +1513,7 @@ object desugar {
15051513 val matchExpr =
15061514 if (tupleOptimizable) rhs
15071515 else
1508- val caseDef = CaseDef (pat, EmptyTree , makeTuple(ids))
1516+ val caseDef = CaseDef (pat, EmptyTree , makeTuple(ids).withAttachment( ForArtifact , ()) )
15091517 Match (makeSelector(rhs, MatchCheck .IrrefutablePatDef ), caseDef :: Nil )
15101518 vars match {
15111519 case Nil if ! mods.is(Lazy ) =>
@@ -1535,6 +1543,7 @@ object desugar {
15351543 ValDef (named.name.asTermName, tpt, selector(n))
15361544 .withMods(mods)
15371545 .withSpan(named.span)
1546+ .withAttachment(PatternVar , ())
15381547 )
15391548 flatTree(firstDef :: restDefs)
15401549 }
@@ -1920,6 +1929,7 @@ object desugar {
19201929 val vdef = ValDef (named.name.asTermName, tpt, rhs)
19211930 .withMods(mods)
19221931 .withSpan(original.span.withPoint(named.span.start))
1932+ .withAttachment(PatternVar , ())
19231933 val mayNeedSetter = valDef(vdef)
19241934 mayNeedSetter
19251935 }
@@ -2165,7 +2175,7 @@ object desugar {
21652175 case _ => Modifiers ()
21662176 makePatDef(valeq, mods, defpat, rhs)
21672177 }
2168- val rhs1 = makeFor(nme.map, nme.flatMap, GenFrom (defpat0, gen.expr, gen.checkMode) :: Nil , Block (pdefs, makeTuple(id0 :: ids)))
2178+ val rhs1 = makeFor(nme.map, nme.flatMap, GenFrom (defpat0, gen.expr, gen.checkMode) :: Nil , Block (pdefs, makeTuple(id0 :: ids).withAttachment( ForArtifact , ()) ))
21692179 val allpats = gen.pat :: pats
21702180 val vfrom1 = GenFrom (makeTuple(allpats), rhs1, GenCheckMode .Ignore )
21712181 makeFor(mapName, flatMapName, vfrom1 :: rest1, body)
0 commit comments