Skip to content

Commit 4afb0fc

Browse files
authored
Dealias in ConstantValue, for inline if cond (#16652)
Fixes #16641
2 parents 4fa0715 + 230622a commit 4afb0fc

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

compiler/src/dotty/tools/dotc/ast/TreeInfo.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1079,7 +1079,7 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
10791079
case Inlined(_, Nil, expr) => unapply(expr)
10801080
case Block(Nil, expr) => unapply(expr)
10811081
case _ =>
1082-
tree.tpe.widenTermRefExpr.normalized match
1082+
tree.tpe.widenTermRefExpr.dealias.normalized match
10831083
case ConstantType(Constant(x)) => Some(x)
10841084
case _ => None
10851085
}

tests/pos/i16641.scala

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
trait Logger {
2+
inline def debug: debug = valueOf[debug]
3+
final type debug = false
4+
5+
// fails
6+
inline final def log(inline s: String): Unit =
7+
inline if (debug) println(s)
8+
}
9+
10+
trait BaseLogger extends Logger {
11+
// fails
12+
def bar() = log("case1")
13+
}
14+
15+
object Logger {
16+
inline def log(s: String): Unit =
17+
inline if (valueOf[Logger#debug]) println(s)
18+
}
19+
20+
class Test:
21+
def fails(x: BaseLogger) =
22+
x.log("case2")
23+
24+
def works =
25+
Logger.log("case3")

0 commit comments

Comments
 (0)