Skip to content

Commit abddd42

Browse files
committed
Add disabled string interpolation test
1 parent c19c240 commit abddd42

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

compiler/src/dotty/tools/dotc/typer/Inliner.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
240240
}
241241
computeParamBindings(tp.resultType, Nil, argss)
242242
case tp: MethodType =>
243+
assert(argss.nonEmpty, i"missing bindings: $tp in $call")
243244
(tp.paramNames, tp.paramInfos, argss.head).zipped.foreach { (name, paramtp, arg) =>
244245
paramBinding(name) = arg.tpe.dealias match {
245246
case _: SingletonType if isIdempotentExpr(arg) => arg.tpe
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import XmlQuote._
2+
3+
object Test {
4+
def main(args: Array[String]): Unit = {
5+
6+
assert(xml"Hello Allan!" == Xml("Hello Allan!", Nil))
7+
8+
val name = new Object{}
9+
assert(xml"Hello $name!" == Xml("Hello ??!", List(name)))
10+
}
11+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import scala.quoted._
2+
import scala.tasty.Tasty
3+
4+
import scala.language.implicitConversions
5+
6+
case class Xml(parts: String, args: List[Any])
7+
8+
object XmlQuote {
9+
10+
implicit object SCOps {
11+
inline def xml(this inline ctx: StringContext)(args: => Any*): Xml =
12+
~XmlQuote.impl(ctx, '(args))
13+
}
14+
15+
def impl(receiver: StringContext, args: Expr[Seq[Any]]): Expr[Xml] = {
16+
val string = receiver.parts.mkString("??")
17+
'(new Xml(~string.toExpr, (~args).toList))
18+
}
19+
}

0 commit comments

Comments
 (0)