An instance of A <:< B
witnesses that A
is a subtype of B
.
An instance of A <:< B
witnesses that A
is a subtype of B
.
Requiring an implicit argument of the type A <:< B
encodes
the generalized constraint A <: B
.
we need a new type constructor <:<
and evidence conforms
,
as reusing Function1
and identity
leads to ambiguities in
case of type errors (any2stringadd
is inferred)
To constrain any abstract type T that's in scope in a method's
argument list (not just the method's own type parameters) simply
add an implicit argument of type T <:< U
, where U
is the required
upper bound; or for lower-bounds, use: L <:< T
, where L
is the
required lower bound.
In part contributed by Jason Zaugg.
An instance of A =:= B
witnesses that the types A
and B
are equal.
An instance of A =:= B
witnesses that the types A
and B
are equal.
<:<
for expressing subtyping constraints
(Since version 2.11.0) Use implicitly[T <:< U]
or identity
instead.