File tree 3 files changed +20
-2
lines changed
compiler/src/dotty/tools/dotc
library/src/scala/quoted/runtime
3 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -882,6 +882,7 @@ class Definitions {
882
882
@ tu lazy val QuotedRuntimePatterns : Symbol = requiredModule(" scala.quoted.runtime.Patterns" )
883
883
@ tu lazy val QuotedRuntimePatterns_patternHole : Symbol = QuotedRuntimePatterns .requiredMethod(" patternHole" )
884
884
@ tu lazy val QuotedRuntimePatterns_higherOrderHole : Symbol = QuotedRuntimePatterns .requiredMethod(" higherOrderHole" )
885
+ @ tu lazy val QuotedRuntimePatterns_higherOrderHoleWithTypes : Symbol = QuotedRuntimePatterns .requiredMethod(" higherOrderHoleWithTypes" )
885
886
@ tu lazy val QuotedRuntimePatterns_patternTypeAnnot : ClassSymbol = QuotedRuntimePatterns .requiredClass(" patternType" )
886
887
@ tu lazy val QuotedRuntimePatterns_fromAboveAnnot : ClassSymbol = QuotedRuntimePatterns .requiredClass(" fromAbove" )
887
888
Original file line number Diff line number Diff line change @@ -205,8 +205,16 @@ object QuotePatterns:
205
205
val patType1 = patType.translateFromRepeated(toArray = false )
206
206
val pat1 = if (patType eq patType1) pat else pat.withType(patType1)
207
207
patBuf += pat1
208
- if args.isEmpty then ref(defn.QuotedRuntimePatterns_patternHole .termRef).appliedToType(tree.tpe).withSpan(tree.span)
209
- else ref(defn.QuotedRuntimePatterns_higherOrderHole .termRef).appliedToType(tree.tpe).appliedTo(SeqLiteral (args, TypeTree (defn.AnyType ))).withSpan(tree.span)
208
+ if typeargs.isEmpty && args.isEmpty then ref(defn.QuotedRuntimePatterns_patternHole .termRef).appliedToType(tree.tpe).withSpan(tree.span)
209
+ else if typeargs.isEmpty then
210
+ ref(defn.QuotedRuntimePatterns_higherOrderHole .termRef)
211
+ .appliedToType(tree.tpe)
212
+ .appliedTo(SeqLiteral (args, TypeTree (defn.AnyType )))
213
+ .withSpan(tree.span)
214
+ else ref(defn.QuotedRuntimePatterns_higherOrderHoleWithTypes .termRef)
215
+ .appliedToTypeTrees(List (TypeTree (tree.tpe), tpd.hkNestedPairsTypeTree(typeargs)))
216
+ .appliedTo(SeqLiteral (args, TypeTree (defn.AnyType )))
217
+ .withSpan(tree.span)
210
218
case _ =>
211
219
super .transform(tree)
212
220
}
Original file line number Diff line number Diff line change 1
1
package scala .quoted .runtime
2
2
3
3
import scala .annotation .{Annotation , compileTimeOnly }
4
+ import scala .annotation .experimental
4
5
5
6
@ compileTimeOnly(" Illegal reference to `scala.quoted.runtime.Patterns`" )
6
7
object Patterns {
@@ -26,6 +27,14 @@ object Patterns {
26
27
@ compileTimeOnly(" Illegal reference to `scala.quoted.runtime.Patterns.higherOrderHole`" )
27
28
def higherOrderHole [U ](args : Any * ): U = ???
28
29
30
+ /** A higher order splice in a quoted pattern is desugared by the compiler into a call to this method.
31
+ *
32
+ * Calling this method in source has undefined behavior at compile-time
33
+ */
34
+ @ experimental
35
+ @ compileTimeOnly(" Illegal reference to `scala.quoted.runtime.Patterns.higherOrderHole`" )
36
+ def higherOrderHoleWithTypes [U , T ](args : Any * ): U = ???
37
+
29
38
/** A splice of a name in a quoted pattern is that marks the definition of a type splice.
30
39
*
31
40
* Adding this annotation in source has undefined behavior at compile-time
You can’t perform that action at this time.
0 commit comments