diff options
author | Martin Odersky <odersky@gmail.com> | 2015-09-08 10:34:48 +0200 |
---|---|---|
committer | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2015-09-14 13:36:14 +0200 |
commit | 1ff1cf5393778b7dc21f765f5c8f372c05877862 (patch) | |
tree | 6e04edfe90f146b07897822755ca9619a19116c1 /src/dotty/tools/dotc/core | |
parent | 869bdb0503628e8665292073087b08b91399a6c9 (diff) | |
download | dotty-1ff1cf5393778b7dc21f765f5c8f372c05877862.tar.gz dotty-1ff1cf5393778b7dc21f765f5c8f372c05877862.tar.bz2 dotty-1ff1cf5393778b7dc21f765f5c8f372c05877862.zip |
Follow TermRefs when constant folding
A TermRef representing a constant value needs to be
considered a constant when folding.
Diffstat (limited to 'src/dotty/tools/dotc/core')
-rw-r--r-- | src/dotty/tools/dotc/core/Types.scala | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala index 5fd3b81d0..d04da30c0 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -715,6 +715,14 @@ object Types { case _ => this } + /** Widen from TermRef to its underlying non-termref + * base type, while also skipping Expr types. + */ + final def widenTermRefExpr(implicit ctx: Context): Type = stripTypeVar match { + case tp: TermRef if !tp.isOverloaded => tp.underlying.widenExpr.widenTermRefExpr + case _ => this + } + /** Widen from ExprType type to its result type. * (Note: no stripTypeVar needed because TypeVar's can't refer to ExprTypes.) */ |