diff options
author | Paul Phillips <paulp@improving.org> | 2012-05-01 19:08:41 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-05-01 19:52:09 -0700 |
commit | ae5ff6628bb74c16d871a2ada0664cdd5d2399a5 (patch) | |
tree | 6819665c0030d5305d55c9b2e4141eea8e8f2458 /src | |
parent | 15e05a400be378b012903411179f2a4114f890ef (diff) | |
download | scala-ae5ff6628bb74c16d871a2ada0664cdd5d2399a5.tar.gz scala-ae5ff6628bb74c16d871a2ada0664cdd5d2399a5.tar.bz2 scala-ae5ff6628bb74c16d871a2ada0664cdd5d2399a5.zip |
Fixes #SI-5578.
ResetAttrs shouldn't be side-effecting on the original tree,
since it can lead to NPEs in erroneous trees (or maybe even for valid ones?).
Review by @odersky
(Patch by plocinic, applied without his complicity by extempore)
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/ast/Trees.scala | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/Trees.scala b/src/compiler/scala/tools/nsc/ast/Trees.scala index 2bd1ba3fea..34b37073fd 100644 --- a/src/compiler/scala/tools/nsc/ast/Trees.scala +++ b/src/compiler/scala/tools/nsc/ast/Trees.scala @@ -321,13 +321,14 @@ trait Trees extends reflect.internal.Trees { self: Global => super.transform { tree match { case tpt: TypeTree => - if (tpt.original != null) { + if (tpt.original != null) transform(tpt.original) - } else { - if (tpt.tpe != null && (tpt.wasEmpty || (tpt.tpe exists (tp => locals contains tp.typeSymbol)))) - tpt.tpe = null - tree + else if (tpt.tpe != null && (tpt.wasEmpty || (tpt.tpe exists (tp => locals contains tp.typeSymbol)))) { + val dupl = tpt.duplicate + dupl.tpe = null + dupl } + else tree case TypeApply(fn, args) if args map transform exists (_.isEmpty) => transform(fn) case This(_) if tree.symbol != null && tree.symbol.isPackageClass => @@ -335,10 +336,11 @@ trait Trees extends reflect.internal.Trees { self: Global => case EmptyTree => tree case _ => + val dupl = tree.duplicate if (tree.hasSymbol && (!localOnly || (locals contains tree.symbol)) && !(keepLabels && tree.symbol.isLabel)) - tree.symbol = NoSymbol - tree.tpe = null - tree + dupl.symbol = NoSymbol + dupl.tpe = null + dupl } } } |