@@ -175,6 +175,7 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
175
175
* +- LambdaType -+- MethodOrPoly -+- MethodType
176
176
* | | +- PolyType
177
177
* | +- TypeLambda
178
+ * +- MatchCase
178
179
* +- TypeBounds
179
180
* +- NoPrefix
180
181
*
@@ -2688,6 +2689,40 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
2688
2689
end extension
2689
2690
end TypeLambdaMethods
2690
2691
2692
+ /** Case of a `MatchType` containing pattern `case P => R`.
2693
+ *
2694
+ * Note: cases with type bindings are represented nested in a `TypeLambda`.
2695
+ */
2696
+ type MatchCase <: TypeRepr
2697
+
2698
+ /** `TypeTest` that allows testing at runtime in a pattern match if a `TypeRepr` is a `MatchCase` */
2699
+ given MatchCaseTypeTest : TypeTest [TypeRepr , MatchCase ]
2700
+
2701
+ /** Module object of `type MatchCase` */
2702
+ val MatchCase : MatchCaseModule
2703
+
2704
+ /** Methods of the module object `val MatchCase` */
2705
+ trait MatchCaseModule { this : MatchCase .type =>
2706
+ /* Create match type case `case <pattern> => <rhs>` */
2707
+ def apply (pattern : TypeRepr , rhs : TypeRepr ): MatchCase
2708
+ /* Matches a match type case `case <pattern> => <rhs>` */
2709
+ def unapply (x : MatchCase ): (TypeRepr , TypeRepr )
2710
+ }
2711
+
2712
+ /** Makes extension methods on `MatchCase` available without any imports */
2713
+ given MatchCaseMethods : MatchCaseMethods
2714
+
2715
+ /** Extension methods of `MatchCase` */
2716
+ trait MatchCaseMethods :
2717
+ extension (self : MatchCase )
2718
+ /** Pattern `P` of `case P => R` in a `MatchType` */
2719
+ def pattern : TypeRepr
2720
+ /** RHS `R` of `case P => R` in a `MatchType` */
2721
+ def rhs : TypeRepr
2722
+ end extension
2723
+ end MatchCaseMethods
2724
+
2725
+
2691
2726
// ----- TypeBounds -----------------------------------------------
2692
2727
2693
2728
/** Type bounds */
0 commit comments