File tree Expand file tree Collapse file tree 3 files changed +16
-5
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 3 files changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -1180,8 +1180,10 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
11801180
11811181 /** An extractor for typed splices */
11821182 object Splice {
1183- def apply (tree : Tree )(implicit ctx : Context ): Tree =
1184- ref(defn.InternalQuoted_exprSplice ).appliedTo(tree)
1183+ def apply (tree : Tree )(implicit ctx : Context ): Tree = {
1184+ val argType = tree.tpe.baseType(defn.QuotedExprClass ).argTypesHi.head
1185+ ref(defn.InternalQuoted_exprSplice ).appliedToType(argType).appliedTo(tree)
1186+ }
11851187 def unapply (tree : Tree )(implicit ctx : Context ): Option [Tree ] = tree match {
11861188 case Apply (fn, arg :: Nil ) if fn.symbol == defn.InternalQuoted_exprSplice => Some (arg)
11871189 case _ => None
Original file line number Diff line number Diff line change @@ -1963,7 +1963,7 @@ class Typer extends Namer
19631963 val exprTpt = ref(defn.QuotedExprType ).appliedToTypeTrees(tpt :: Nil )
19641964 transform(Splice (Typed (pat, exprTpt)))
19651965 case Splice (pat) =>
1966- try tasty. TreePickler . Hole (patBuf.length, Nil )
1966+ try holeForSplice(tree )
19671967 finally patBuf += pat
19681968 case _ =>
19691969 super .transform(tree)
@@ -1973,6 +1973,13 @@ class Typer extends Namer
19731973 (result, splitter.patBuf.toList)
19741974 }
19751975
1976+ // TODO: Currently, a hole is expressed as interal.quoted.ExprSplice[T](???)
1977+ // Settle on a different representation and apply Stagin
1978+ def holeForSplice (splice : Tree )(implicit ctx : Context ): Tree = {
1979+ val Apply (fn, arg) = splice
1980+ tpd.cpy.Apply (splice)(fn, ref(defn.Predef_undefined ) :: Nil )
1981+ }
1982+
19761983 def givenReflection (implicit ctx : Context ): Tree = Literal (Constant (null )) // FIXME: fill in
19771984
19781985 /** Translate `${ t: Expr[T] }` into expression `t.splice` while tracking the quotation level in the context */
Original file line number Diff line number Diff line change @@ -2,8 +2,10 @@ object Test {
22
33 val x = ' {1 + 2 }
44
5+ def f (x : Int ) = x
6+
57 x match {
6- case ' {1 + 2 } =>
7- case _ =>
8+ case ' {1 + 2 } => 0
9+ case ' {f($x)} => x
810 }
911}
You can’t perform that action at this time.
0 commit comments