aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/ast/Trees.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/dotty/tools/dotc/ast/Trees.scala')
-rw-r--r--src/dotty/tools/dotc/ast/Trees.scala9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/ast/Trees.scala b/src/dotty/tools/dotc/ast/Trees.scala
index 2392e52be..628e7f9d3 100644
--- a/src/dotty/tools/dotc/ast/Trees.scala
+++ b/src/dotty/tools/dotc/ast/Trees.scala
@@ -156,7 +156,12 @@ object Trees {
private[this] var myTpe: T = _
- private def setMyTpe(tpe: T) = myTpe = tpe
+ /** Destructively set the type of the tree. This should be called only when it is known that
+ * it is safe under sharing to do so. One user-case is in the withType method below
+ * which implements copy-on-write. Another user-case is in method interpolateAndAdapt in Typer,
+ * where we overwrite with a simplified version of the type itself.
+ */
+ private[dotc] def overwriteType(tpe: T) = myTpe = tpe
/** The type of the tree. In case of an untyped tree,
* an UnAssignedTypeException is thrown. (Overridden by empty trees)
@@ -191,7 +196,7 @@ object Trees {
(if (myTpe == null ||
(myTpe.asInstanceOf[AnyRef] eq tpe.asInstanceOf[AnyRef])) this
else clone).asInstanceOf[Tree[Type]]
- tree setMyTpe tpe
+ tree overwriteType tpe
tree.asInstanceOf[ThisTree[Type]]
}