Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3f10858

Browse files
committed
Make typeArgs in QuotesImpl work for AnnotatedTypes
Fixes #24006
1 parent 20c62f8 commit 3f10858

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

‎compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1911,6 +1911,7 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
19111911

19121912
def typeArgs: List[TypeRepr] = self match
19131913
case AppliedType(_, args) => args
1914+
case AnnotatedType(parent, _) => parent.typeArgs
19141915
case _ => List.empty
19151916
end extension
19161917
end TypeReprMethods

‎tests/neg-macros/i23008.check‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
| Exception occurred while executing macro expansion.
66
| java.lang.IllegalArgumentException: requirement failed: value of StringConstant cannot be `null`
77
| at scala.Predef$.require(Predef.scala:393)
8+
| at scala.quoted.runtime.impl.QuotesImpl$reflect$StringConstant$.apply(QuotesImpl.scala:2541)
89
| at scala.quoted.runtime.impl.QuotesImpl$reflect$StringConstant$.apply(QuotesImpl.scala:2540)
9-
| at scala.quoted.runtime.impl.QuotesImpl$reflect$StringConstant$.apply(QuotesImpl.scala:2539)
1010
| at scala.quoted.ToExpr$StringToExpr.apply(ToExpr.scala:82)
1111
| at scala.quoted.ToExpr$StringToExpr.apply(ToExpr.scala:80)
1212
| at scala.quoted.Expr$.apply(Expr.scala:72)

‎tests/run-macros/i24006/Eval.scala‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
import scala.quoted._
3+
4+
object Eval:
5+
6+
inline def eval[T](x: List[T]) = ${ evalImpl[T]('x) }
7+
def evalImpl[A](x: Expr[List[A]])(using Quotes): Expr[Unit] =
8+
import quotes.reflect.*
9+
println(x.asTerm.tpe.widen)
10+
x.asTerm.tpe.widen.typeArgs.head
11+
'{()}

‎tests/run-macros/i24006/Test.scala‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import Eval.eval
2+
3+
@main def Test() = eval(List(1) :+ 4)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /