ATypeTest[S, T] contains the logic needed to know at runtime if a value of typeS is an instance ofT.
If a pattern match is performed on a term of types: S that is uncheckable withs.isInstanceOf[T] and the pattern is one of the following forms:
t: Tt @ X() whereX.unapply takes an argument of typeT then a given instance ofTypeTest[S, T] is summoned and used to perform the test.ATypeTest[S, T] can serve as an extractor that matches if and only if a value of typeS is an instance ofT.
ATypeTest[S, T] can serve as an extractor that matches if and only if a value of typeS is an instance ofT.
The compiler tries to turn unchecked type tests in pattern matches into checked ones by wrapping a(_: T) type pattern astt(_: T), wherett is theTypeTest[S, T] instance. Type tests necessary before calling other extractors are treated similarly.SomeExtractor(...) is turned intott(SomeExtractor(...)) ifT inSomeExtractor.unapply(x: T) is uncheckable, but we have an instance ofTypeTest[S, T].