Skip to content

Commit 46c6a6a

Browse files
nicolasstuckiodersky
authored andcommitted
Adapt macro tests to new by-name
1 parent 733e20f commit 46c6a6a

File tree

5 files changed

+13
-6
lines changed

5 files changed

+13
-6
lines changed

tests/neg-macros/i6976.check

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
-- Error: tests/neg-macros/i6976/Test_2.scala:5:44 ---------------------------------------------------------------------
33
5 | def main(args: Array[String]): Unit = mcr { 2 } // error
44
| ^^^^^^^^^
5-
| Exception occurred while executing macro expansion.
6-
| scala.MatchError: Inlined(EmptyTree,List(),Literal(Constant(2))) (of class dotty.tools.dotc.ast.Trees$Inlined)
7-
| at playground.macros$.mcrImpl(Macro_1.scala:10)
5+
| Exception occurred while executing macro expansion.
6+
| scala.MatchError: Inlined(EmptyTree,List(),Ident(x$proxy1)) (of class dotty.tools.dotc.ast.Trees$Inlined)
7+
| at playground.macros$.mcrImpl(Macro_1.scala:10)
88
|
99
| This location contains code that was inlined from Test_2.scala:5

tests/run-macros/i5119.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Select(Typed(Apply(Select(New(TypeIdent("StringContextOps")), "<init>"), List(Apply(Select(Select(Select(Ident("_root_"), "scala"), "StringContext"), "apply"), List(Typed(Repeated(List(Literal(StringConstant("Hello World ")), Literal(StringConstant("!"))), Inferred()), Inferred()))))), TypeIdent("StringContextOps")), "inline$sc")
1+
Apply(Select(Select(Typed(Apply(Select(New(TypeIdent("StringContextOps")), "<init>"), List(Apply(Ident("<byname>"), List(Apply(Select(Select(Select(Ident("_root_"), "scala"), "StringContext"), "apply"), List(Typed(Repeated(List(Literal(StringConstant("Hello World ")), Literal(StringConstant("!"))), Inferred()), Inferred()))))))), TypeIdent("StringContextOps")), "inline$sc"), "apply"), Nil)
22
Typed(Repeated(List(Literal(IntConstant(1))), Inferred()), Inferred())

tests/run-macros/tasty-extractors-1.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,6 @@ TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit")
115115
Inlined(None, Nil, Block(List(DefDef("f8", List(TermParamClause(List(ValDef("i", Annotated(Applied(Inferred(), List(TypeIdent("Int"))), Apply(Select(New(Inferred()), "<init>"), Nil)), None)))), TypeIdent("Int"), Some(Literal(IntConstant(9))))), Apply(Ident("f8"), List(Typed(Repeated(List(Literal(IntConstant(1)), Literal(IntConstant(2)), Literal(IntConstant(3))), Inferred()), Inferred())))))
116116
TypeRef(TermRef(ThisType(TypeRef(NoPrefix(), "<root>")), "scala"), "Int")
117117

118-
Inlined(None, Nil, Block(List(DefDef("f9", List(TermParamClause(List(ValDef("i", ByName(TypeIdent("Int")), None)))), TypeIdent("Int"), Some(Ident("i")))), Literal(UnitConstant())))
118+
Inlined(None, Nil, Block(List(DefDef("f9", List(TermParamClause(List(ValDef("i", ByName(TypeIdent("Int")), None)))), TypeIdent("Int"), Some(Apply(Select(Ident("i"), "apply"), Nil)))), Literal(UnitConstant())))
119119
TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Unit")
120120

tests/run-macros/tasty-interpolation-1/Macro.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ abstract class MacroStringInterpolator[T] {
5757
protected def getStaticStringContext(strCtxExpr: Expr[StringContext])(using Quotes) : StringContext = {
5858
import quotes.reflect.*
5959
strCtxExpr.asTerm.underlyingArgument match {
60+
case Apply(Select(Select(Typed(Apply(_, List(Apply(Ident("<byname>"), List(Apply(Select(Select(Select(Ident("_root_"), "scala"), "StringContext"), "apply"), List(Typed(Repeated(strCtxArgTrees, _), Inferred()))))))), _), _), _), Nil) =>
61+
val strCtxArgs = strCtxArgTrees.map {
62+
case Literal(StringConstant(str)) => str
63+
case tree => throw new NotStaticlyKnownError("Expected statically known StringContext", tree.asExpr)
64+
}
65+
StringContext(strCtxArgs*)
66+
// Old style by-name
6067
case Select(Typed(Apply(_, List(Apply(_, List(Typed(Repeated(strCtxArgTrees, _), Inferred()))))), _), _) =>
6168
val strCtxArgs = strCtxArgTrees.map {
6269
case Literal(StringConstant(str)) => str

tests/run-macros/xml-interpolation-2/XmlQuote_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ object XmlQuote {
3939
val parts: List[String] = stripTyped(receiver.asTerm.underlying) match {
4040
case Apply(conv, List(ctx1)) if isSCOpsConversion(conv) =>
4141
ctx1 match {
42-
case Apply(fun, List(Typed(Repeated(values, _), _))) if isStringContextApply(fun) =>
42+
case Apply(Ident("<byname>"), List(Apply(fun, List(Typed(Repeated(values, _), _))))) if isStringContextApply(fun) =>
4343
values.iterator.map {
4444
case Literal(StringConstant(value)) => value
4545
case _ =>

0 commit comments

Comments
 (0)