Skip to content

Commit f04003c

Browse files
committed
Remove T <: S and make S contravariant
1 parent 7b3e6f8 commit f04003c

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

docs/docs/reference/other-new-features/type-test.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ TypeTest
1010
`TypeTest.unapply` will return `Some(x.asInstanceOf[Y])` if `x` conforms to `Y`, otherwise it returns `None`.
1111

1212
```scala
13-
trait TypeTest[S, T <: S] extends Serializable {
13+
trait TypeTest[-S, T] extends Serializable {
1414
def unapply(s: S): Option[s.type & T]
1515
}
1616
```

library/src/scala/reflect/TypeTest.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package scala.reflect
22

3-
/** A `TypeTest[S, T]` (where `T <: S`) contains the logic needed to know at runtime if a value of
3+
/** A `TypeTest[S, T] contains the logic needed to know at runtime if a value of
44
* type `S` can be downcased to `T`.
55
*
66
* If a pattern match is performed on a term of type `s: S` that is uncheckable with `s.isInstanceOf[T]` and
@@ -12,7 +12,7 @@ package scala.reflect
1212
* Note: This is replacemet for `ClassTag.unapply` that can be sound for path dependent types
1313
*/
1414
@scala.annotation.implicitNotFound(msg = "No TypeTest available for [${S}, ${T}]")
15-
trait TypeTest[S, T <: S] extends Serializable {
15+
trait TypeTest[-S, T] extends Serializable {
1616

1717
/** A TypeTest[S, T] can serve as an extractor that matches only S of type T.
1818
*

0 commit comments

Comments
 (0)