Skip to content

Commit 56b2d42

Browse files
road21tgodzik
authored andcommitted
doc: make TypeTest example compiling (scala#23009)
Current example is not compiling: ```scala import scala.reflect.{ClassTag, TypeTest} val tt: TypeTest[Any, String] = new TypeTest[Any, String]: def unapply(s: Any): Option[s.type & String] = s match case s: String => Some(s) // compiler error Found: (s : String) Required: (s² : Any) & String case _ => None ``` https://scastie.scala-lang.org/road21/jq3j9XsUTdeshqbHxDXv3w [Cherry-picked 6c021c6]
1 parent dec36c1 commit 56b2d42

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ We could create a type test at call site where the type test can be performed wi
6363
val tt: TypeTest[Any, String] =
6464
new TypeTest[Any, String]:
6565
def unapply(s: Any): Option[s.type & String] = s match
66-
case s: String => Some(s)
66+
case q: (s.type & String) => Some(q)
6767
case _ => None
6868

6969
f[AnyRef, String]("acb")(using tt)

docs/_spec/TODOreference/other-new-features/type-test.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ We could create a type test at call site where the type test can be performed wi
6363
val tt: TypeTest[Any, String] =
6464
new TypeTest[Any, String]:
6565
def unapply(s: Any): Option[s.type & String] = s match
66-
case s: String => Some(s)
66+
case q: (s.type & String) => Some(q)
6767
case _ => None
6868

6969
f[AnyRef, String]("acb")(using tt)

0 commit comments

Comments
 (0)