From 1ff1cf5393778b7dc21f765f5c8f372c05877862 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Tue, 8 Sep 2015 10:34:48 +0200 Subject: Follow TermRefs when constant folding A TermRef representing a constant value needs to be considered a constant when folding. --- src/dotty/tools/dotc/core/Types.scala | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/dotty/tools/dotc/core/Types.scala') 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.) */ -- cgit v1.2.3