diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/reflect/scala/reflect/api/Trees.scala | 6 | ||||
-rw-r--r-- | src/reflect/scala/reflect/internal/Trees.scala | 7 |
2 files changed, 9 insertions, 4 deletions
diff --git a/src/reflect/scala/reflect/api/Trees.scala b/src/reflect/scala/reflect/api/Trees.scala index 94226ae866..05458cb311 100644 --- a/src/reflect/scala/reflect/api/Trees.scala +++ b/src/reflect/scala/reflect/api/Trees.scala @@ -2951,8 +2951,10 @@ trait Trees { self: Universe => if (exprOwner != currentOwner && stat.isTerm) atOwner(exprOwner)(transform(stat)) else transform(stat)) filter (EmptyTree != _) /** Transforms `Modifiers`. */ - def transformModifiers(mods: Modifiers): Modifiers = - mods.mapAnnotations(transformTrees) + def transformModifiers(mods: Modifiers): Modifiers = { + if (mods.annotations.isEmpty) mods + else mods mapAnnotations transformTrees + } /** Transforms a tree with a given owner symbol. */ def atOwner[A](owner: Symbol)(trans: => A): A = { diff --git a/src/reflect/scala/reflect/internal/Trees.scala b/src/reflect/scala/reflect/internal/Trees.scala index 9e737528d2..870c1ec5ed 100644 --- a/src/reflect/scala/reflect/internal/Trees.scala +++ b/src/reflect/scala/reflect/internal/Trees.scala @@ -926,8 +926,11 @@ trait Trees extends api.Trees { self: SymbolTable => def withPosition(flag: Long, position: Position) = copy() setPositions positions + (flag -> position) - override def mapAnnotations(f: List[Tree] => List[Tree]): Modifiers = - Modifiers(flags, privateWithin, f(annotations)) setPositions positions + override def mapAnnotations(f: List[Tree] => List[Tree]): Modifiers = { + val newAnns = f(annotations) + if (annotations == newAnns) this + else Modifiers(flags, privateWithin, newAnns) setPositions positions + } override def toString = "Modifiers(%s, %s, %s)".format(flagString, annotations mkString ", ", positions) } |