To summarize the discussion in #12261:
-
There are 3 ways to write catch-all patterns for match types (case _ =>, case Any =>, and case ? =>)
-
All of them are already in use in the community build (see case ? => in scodecs)
-
The current syntax is quite inconsistent:
type A = _ // NOT OK
type B = ? // NOT OK
type M0[X] = X match { case ? => String } // OK
type M1[X] = X match { case Any => _ } // OK
type M2[X] = X match { case Any => ? } // OK
val a = "" match { case _: _ => () } // OK
val b = try { } catch { case _: ? => () } // OK
-
Disallowing those standalone ? types would be a relative simple change to the parser (5a81d5a / 8968cc1)