From e66860be41f48517a536c57c032018710e070abb Mon Sep 17 00:00:00 2001 From: Kacper Korban Date: Mon, 12 Aug 2024 11:30:28 +0200 Subject: [PATCH] fix: throw an error before assigning ErrorType when expanding constValue --- compiler/src/dotty/tools/dotc/inlines/Inlines.scala | 1 + tests/neg/i21359.scala | 6 ++++++ 2 files changed, 7 insertions(+) create mode 100644 tests/neg/i21359.scala diff --git a/compiler/src/dotty/tools/dotc/inlines/Inlines.scala b/compiler/src/dotty/tools/dotc/inlines/Inlines.scala index fffe87c3f57a..788ecbfebd4b 100644 --- a/compiler/src/dotty/tools/dotc/inlines/Inlines.scala +++ b/compiler/src/dotty/tools/dotc/inlines/Inlines.scala @@ -429,6 +429,7 @@ object Inlines: val constVal = tryConstValue(tpe) if constVal.isEmpty then val msg = NotConstant("cannot take constValue", tpe) + report.error(msg, callTypeArgs.head.srcPos) ref(defn.Predef_undefined).withSpan(callTypeArgs.head.span).withType(ErrorType(msg)) else constVal diff --git a/tests/neg/i21359.scala b/tests/neg/i21359.scala new file mode 100644 index 000000000000..9d588335c0e6 --- /dev/null +++ b/tests/neg/i21359.scala @@ -0,0 +1,6 @@ +import scala.compiletime.constValueTuple +import scala.deriving.Mirror + +case class Hello(a: Int) +val mirror = summon[Mirror.Of[Hello]] +val test = constValueTuple[mirror.MirroredElemTypes] // error