File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -715,6 +715,14 @@ object Types {
715
715
case _ => this
716
716
}
717
717
718
+ /** Widen from TermRef to its underlying non-termref
719
+ * base type, while also skipping Expr types.
720
+ */
721
+ final def widenTermRefExpr (implicit ctx : Context ): Type = stripTypeVar match {
722
+ case tp : TermRef if ! tp.isOverloaded => tp.underlying.widenExpr.widenTermRefExpr
723
+ case _ => this
724
+ }
725
+
718
726
/** Widen from ExprType type to its result type.
719
727
* (Note: no stripTypeVar needed because TypeVar's can't refer to ExprTypes.)
720
728
*/
Original file line number Diff line number Diff line change @@ -20,16 +20,16 @@ object ConstFold {
20
20
def apply (tree : Tree )(implicit ctx : Context ): Tree = finish(tree) {
21
21
tree match {
22
22
case Apply (Select (xt, op), yt :: Nil ) =>
23
- xt.tpe match {
23
+ xt.tpe.widenTermRefExpr match {
24
24
case ConstantType (x) =>
25
- yt.tpe match {
25
+ yt.tpe.widenTermRefExpr match {
26
26
case ConstantType (y) => foldBinop(op, x, y)
27
27
case _ => null
28
28
}
29
29
case _ => null
30
30
}
31
31
case Select (xt, op) =>
32
- xt.tpe match {
32
+ xt.tpe.widenTermRefExpr match {
33
33
case ConstantType (x) => foldUnop(op, x)
34
34
case _ => null
35
35
}
@@ -42,7 +42,7 @@ object ConstFold {
42
42
*/
43
43
def apply (tree : Tree , pt : Type )(implicit ctx : Context ): Tree =
44
44
finish(apply(tree)) {
45
- tree.tpe match {
45
+ tree.tpe.widenTermRefExpr match {
46
46
case ConstantType (x) => x convertTo pt
47
47
case _ => null
48
48
}
You can’t perform that action at this time.
0 commit comments