File tree Expand file tree Collapse file tree 4 files changed +17
-3
lines changed
compiler/src/dotty/tools/dotc
library/src-bootstrapped/scala/internal Expand file tree Collapse file tree 4 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -713,6 +713,8 @@ class Definitions {
713
713
def InternalQuoted_exprSplice (implicit ctx : Context ): Symbol = InternalQuoted_exprSpliceR .symbol
714
714
lazy val InternalQuoted_typeQuoteR : TermRef = InternalQuotedModuleClass .requiredMethodRef(" typeQuote" .toTermName)
715
715
def InternalQuoted_typeQuote (implicit ctx : Context ): Symbol = InternalQuoted_typeQuoteR .symbol
716
+ lazy val InternalQuoted_TypeSpliceR : TypeRef = InternalQuotedModuleClass .requiredType(" TypeSplice" .toTypeName).typeRef
717
+ def InternalQuoted_TypeSplice (implicit ctx : Context ): Symbol = InternalQuoted_TypeSpliceR .symbol
716
718
717
719
lazy val QuotedExprsModule : TermSymbol = ctx.requiredModule(" scala.quoted.Exprs" )
718
720
def QuotedExprsClass (implicit ctx : Context ): ClassSymbol = QuotedExprsModule .asClass
Original file line number Diff line number Diff line change @@ -1944,13 +1944,22 @@ class Typer extends Namer
1944
1944
/** Translate `${ t: Expr[T] }` into expresiion `t.splice` while tracking the quotation level in the context */
1945
1945
def typedSplice (tree : untpd.Splice , pt : Type )(implicit ctx : Context ): Tree = track(" typedSplice" ) {
1946
1946
checkSpliceOutsideQuote(tree)
1947
- if (tree.isType) typedSelect(untpd.Select (tree.expr, nme.splice), pt)(spliceContext).withSpan(tree.span)
1948
- else typedApply(untpd.Apply (untpd.ref(defn.InternalQuoted_exprSpliceR ), tree.expr), pt)(spliceContext)
1947
+ typedApply(untpd.Apply (untpd.ref(defn.InternalQuoted_exprSpliceR ), tree.expr), pt)(spliceContext)
1949
1948
}
1950
1949
1951
1950
/** Translate ${ t: Type[T] }` into type `t.splice` while tracking the quotation level in the context */
1952
1951
def typedTypSplice (tree : untpd.TypSplice , pt : Type )(implicit ctx : Context ): Tree = track(" typedTypSplice" ) {
1953
1952
checkSpliceOutsideQuote(tree)
1953
+ // TODO desugar to defn.InternalQuoted_TypeSpliceR
1954
+ // dotc -Ycheck:all -Xprint:front,stag tests/pos/quote-1.scala
1955
+
1956
+ // val foo = untpd.TypeApply(untpd.ref(defn.InternalQuoted_TypeSpliceR), List(untpd.TypeTree(pt), ))
1957
+ println(" ========================" )
1958
+ println(tree.show)
1959
+ println()
1960
+ println(foo.show)
1961
+ println()
1962
+ println()
1954
1963
typedSelect(untpd.Select (tree.expr, tpnme.splice), pt)(spliceContext).withSpan(tree.span)
1955
1964
}
1956
1965
Original file line number Diff line number Diff line change @@ -16,4 +16,7 @@ object Quoted {
16
16
def typeQuote [T <: AnyKind ]: Type [T ] =
17
17
throw new Error (" Internal error: this method call should have been replaced by the compiler" )
18
18
19
+ /** A type splice is desugared by the compiler into a call to this type alias */
20
+ type TypeSplice [T , Typ <: Type [T ] with Singleton ] = T
21
+
19
22
}
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ object Test {
8
8
}
9
9
10
10
f(' {2 })(' [Int ])
11
- f(' { true })(' [Boolean ])
11
+ f(' { true })(' [Boolean ])
12
12
13
13
def g (es : Expr [String ], t : Type [String ]) =
14
14
f(' { ($es + " !" ) :: Nil })(' [List [$t]])
You can’t perform that action at this time.
0 commit comments