Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions compiler/src/dotty/tools/dotc/core/TypeEval.scala
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,12 @@ object TypeEval:
// currently not a concrete known type
case _: TypeParamRef => None
// constant if the term is constant
case t: TermRef => isConst(t.underlying)
case t: TermRef =>
if t.denot.symbol.flagsUNSAFE.is(Flags.Param) then
// might be substituted later
None
else
isConst(t.underlying)
// an operation type => recursively check all argument compositions
case applied: AppliedType if defn.isCompiletimeAppliedType(applied.typeSymbol) =>
val argsConst = applied.args.map(isConst)
Expand Down Expand Up @@ -239,4 +244,4 @@ object TypeEval:

case _ => NoType
end tryCompiletimeConstantFold
end TypeEval
end TypeEval
5 changes: 5 additions & 0 deletions tests/neg/singleton-ops-any.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,9 @@ object Test {
val t51 : true = isConst2[1, 1]
val t52 : false = isConst2[1, one.type]
val t53 : true = isConst2[1, two.type]

val t54: 2 = 2
summon[IsConst[t54.type] =:= true]
def isConst(arg: Int)(using IsConst[arg.type] =:= true): Unit = ???
isConst(t54)
}