SLS specifies syntax of type parameter clause as
TypeParamClause ::= ‘[’ VariantTypeParam {‘,’ VariantTypeParam} ‘]’
FunTypeParamClause::= ‘[’ TypeParam {‘,’ TypeParam} ‘]’
VariantTypeParam ::= {Annotation} [‘+’ | ‘-’] TypeParam
TypeParam ::= (id | ‘_’) [TypeParamClause] [‘>:’ Type] [‘<:’ Type] {‘<%’ Type} {‘:’ Type} {‘<%’ Type} {‘<%’ Type}
where we see >:
, <:
, <%
, <%
, :
as allowed reserved names in type parameter clause. Is there a way we could use generalised type constraint symbolic names <:<
, =:=
in the type parameter clause such that
def f[T =:= 42] = ???
would expand to
def f[T](implicit ev: T =:= 42) = ???
similar to how context bound
def f[T: Numeric] = ???
expands to
def f[T](implicit ev: Numeric[T]) = ???