@@ -549,4 +549,61 @@ trait RunScalacCompatTestDefinitions {
549
549
expect(res.out.trim() == s " version $actualScalaVersion" )
550
550
}
551
551
}
552
+
553
+ for {
554
+ useDirective <- Seq (true , false )
555
+ if ! Properties .isWin
556
+ optionsSource = if (useDirective) " using directive" else " command line"
557
+ if actualScalaVersion == Constants .scala3Next || actualScalaVersion == Constants .scala3NextRc
558
+ }
559
+ test(s " consecutive -Xmacro-settings:* flags are not ignored (passed via $optionsSource) " ) {
560
+ val sourceFileName = " example.scala"
561
+ val macroFileName = " macro.scala"
562
+ val macroSettings @ Seq (macroSetting1, macroSetting2, macroSetting3) =
563
+ Seq (" one" , " two" , " three" )
564
+ val macroSettingOptions = macroSettings.map(s => s " -Xmacro-settings: $s" )
565
+ val maybeDirectiveString =
566
+ if (useDirective) s " //> using options ${macroSettingOptions.mkString(" " )}" else " "
567
+ TestInputs (
568
+ os.rel / macroFileName ->
569
+ """ package x
570
+ |import scala.quoted.*
571
+ |object M:
572
+ | inline def settingsContains(inline x:String): Boolean = ${
573
+ | settingsContainsImpl('x)
574
+ | }
575
+ | def settingsContainsImpl(x:Expr[String])(using Quotes): Expr[Boolean] =
576
+ | import quotes.reflect.*
577
+ | val v = x.valueOrAbort
578
+ | val r = CompilationInfo.XmacroSettings.contains(v)
579
+ | Expr(r)
580
+ |""" .stripMargin,
581
+ os.rel / sourceFileName ->
582
+ s """ $maybeDirectiveString
583
+ |import x.M
584
+ |@main def main(): Unit = {
585
+ | val output = Seq(
586
+ | if M.settingsContains(" $macroSetting1") then Seq(" $macroSetting1") else Nil,
587
+ | if M.settingsContains(" $macroSetting2") then Seq(" $macroSetting2") else Nil,
588
+ | if M.settingsContains(" $macroSetting3") then Seq(" $macroSetting3") else Nil,
589
+ | if M.settingsContains("dummy") then Seq("dummy") else Nil,
590
+ | )
591
+ | println(output.flatten.mkString(", "))
592
+ |}
593
+ |
594
+ | """ .stripMargin
595
+ ).fromRoot { root =>
596
+ val r = os.proc(
597
+ TestUtil .cli,
598
+ " run" ,
599
+ " ." ,
600
+ " -O" ,
601
+ " -experimental" ,
602
+ if (useDirective) Nil else macroSettingOptions,
603
+ extraOptions
604
+ )
605
+ .call(cwd = root, stderr = os.Pipe )
606
+ expect(r.out.trim() == macroSettings.mkString(" , " ))
607
+ }
608
+ }
552
609
}
0 commit comments