Skip to content

Commit e9d4831

Browse files
authored
fix: throw an error before assigning ErrorType when expanding constValue (#21364)
fixes #21359
2 parents 4891858 + e66860b commit e9d4831

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

compiler/src/dotty/tools/dotc/inlines/Inlines.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,7 @@ object Inlines:
429429
val constVal = tryConstValue(tpe)
430430
if constVal.isEmpty then
431431
val msg = NotConstant("cannot take constValue", tpe)
432+
report.error(msg, callTypeArgs.head.srcPos)
432433
ref(defn.Predef_undefined).withSpan(callTypeArgs.head.span).withType(ErrorType(msg))
433434
else
434435
constVal

tests/neg/i21359.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import scala.compiletime.constValueTuple
2+
import scala.deriving.Mirror
3+
4+
case class Hello(a: Int)
5+
val mirror = summon[Mirror.Of[Hello]]
6+
val test = constValueTuple[mirror.MirroredElemTypes] // error

0 commit comments

Comments
 (0)