diff options
author | Martin Odersky <odersky@gmail.com> | 2013-11-03 12:45:49 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2013-11-03 12:50:01 +0100 |
commit | 6728b51613c6a3ee858ace014fb9c9097d15c35b (patch) | |
tree | 34799964daf5fa15e3917483991a4220e6ad50d3 /src/dotty/tools/dotc/ast/Trees.scala | |
parent | f920a3186427e9df2fbac97197f2f11331ef4ef3 (diff) | |
download | dotty-6728b51613c6a3ee858ace014fb9c9097d15c35b.tar.gz dotty-6728b51613c6a3ee858ace014fb9c9097d15c35b.tar.bz2 dotty-6728b51613c6a3ee858ace014fb9c9097d15c35b.zip |
Adding simplification and fixing a variance problem.
1. Added a "simplified" method which gets called on type varianvle instantiation and interpolation.
2. Fixed a problem in TypeAccumulator which did not take the variance into account for Co/Contra type aliases.
Diffstat (limited to 'src/dotty/tools/dotc/ast/Trees.scala')
-rw-r--r-- | src/dotty/tools/dotc/ast/Trees.scala | 9 |
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]] } |