@@ -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
*
@@ -2678,6 +2679,40 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
2678
2679
end extension
2679
2680
end TypeLambdaMethods
2680
2681
2682
+ /** Case of a `MatchType` containing pattern `case P => R`.
2683
+ *
2684
+ * Note: cases with type bindings are represented nested in a `TypeLambda`.
2685
+ */
2686
+ type MatchCase <: TypeRepr
2687
+
2688
+ /** `TypeTest` that allows testing at runtime in a pattern match if a `TypeRepr` is a `MatchCase` */
2689
+ given MatchCaseTypeTest : TypeTest [TypeRepr , MatchCase ]
2690
+
2691
+ /** Module object of `type MatchCase` */
2692
+ val MatchCase : MatchCaseModule
2693
+
2694
+ /** Methods of the module object `val MatchCase` */
2695
+ trait MatchCaseModule { this : MatchCase .type =>
2696
+ /* Create match type case `case <pattern> => <rhs>` */
2697
+ def apply (pattern : TypeRepr , rhs : TypeRepr ): MatchCase
2698
+ /* Matches a match type case `case <pattern> => <rhs>` */
2699
+ def unapply (x : MatchCase ): (TypeRepr , TypeRepr )
2700
+ }
2701
+
2702
+ /** Makes extension methods on `MatchCase` available without any imports */
2703
+ given MatchCaseMethods : MatchCaseMethods
2704
+
2705
+ /** Extension methods of `MatchCase` */
2706
+ trait MatchCaseMethods :
2707
+ extension (self : MatchCase )
2708
+ /** Pattern `P` of `case P => R` in a `MatchType` */
2709
+ def pattern : TypeRepr
2710
+ /** RHS `R` of `case P => R` in a `MatchType` */
2711
+ def rhs : TypeRepr
2712
+ end extension
2713
+ end MatchCaseMethods
2714
+
2715
+
2681
2716
// ----- TypeBounds -----------------------------------------------
2682
2717
2683
2718
/** Type bounds */
0 commit comments