Skip to content

Commit 20c95d3

Browse files
Merge branch 'master' into fix-#8841
2 parents 06013a6 + 6f51dbb commit 20c95d3

File tree

5 files changed

+42
-2
lines changed

5 files changed

+42
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
510510
*/
511511
def constToLiteral(tree: Tree)(implicit ctx: Context): Tree = {
512512
val tree1 = ConstFold(tree)
513-
tree1.tpe.widenTermRefExpr match {
513+
tree1.tpe.widenTermRefExpr.dealias match {
514514
case ConstantType(value) =>
515515
if (isIdempotentExpr(tree1)) Literal(value).withSpan(tree.span)
516516
else tree1 match {

compiler/src/dotty/tools/dotc/typer/Checking.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,7 @@ trait Checking {
887887
if sym.is(Inline, butNot = DeferredOrTermParamOrAccessor) && !ctx.erasedTypes && !ctx.inInlineMethod then
888888
// final vals can be marked inline even if they're not pure, see Typer#patchFinalVals
889889
val purityLevel = if (sym.is(Final)) Idempotent else Pure
890-
tpt.tpe.widenTermRefExpr match
890+
tpt.tpe.widenTermRefExpr.dealias match
891891
case tp: ConstantType =>
892892
if !(exprPurity(tree) >= purityLevel) then
893893
ctx.error(em"inline value must be pure", tree.sourcePos)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import compiletime._
2+
3+
class C:
4+
type X <: Tuple
5+
6+
def test: Unit =
7+
val a: C { type X = Tuple1[Any] } = ???
8+
f(a)
9+
10+
inline def f(c: C): Unit = {
11+
inline val size = constValue[Tuple.Size[c.X]]
12+
val n = size
13+
val m: Int = n
14+
???
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import compiletime._
2+
3+
class C:
4+
type N <: Int
5+
6+
def test: Unit =
7+
val a: C { type N = 3 } = ???
8+
f(a)
9+
10+
inline def f(c: C): Unit = {
11+
inline val size = constValue[c.N]
12+
val n = size
13+
val m: Int = n
14+
???
15+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
inline def f[N <: Int]: Unit = {
3+
inline val size = compiletime.constValue[N]
4+
inline val n = size
5+
val m: Int = n
6+
???
7+
}
8+
9+
type N = 4
10+
def test: Unit = f[N]

0 commit comments

Comments
 (0)