Skip to content

Commit cd0d0eb

Browse files
author
Dean Wampler
committed
Added new asMatchable feature to example
1 parent e081ccf commit cd0d0eb

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/script/scala/progscala3/typesystem/matchtypes/DepTypedMethods.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ type ElemR[X] = X match // "R" for "recursive"
88
case Option[t] => ElemR[t]
99
case AnyVal => X
1010

11-
def first[X](x: X): ElemR[X] = x.asInstanceOf[Matchable & X] match // <3>
11+
import compiletime.asMatchable // <3>
12+
def first[X](x: X): ElemR[X] = x.asMatchable match // <4>
1213
case s: String => s.charAt(0)
1314
case a: Array[t] => first(a(0))
1415
case i: Iterable[t] => first(i.head)

0 commit comments

Comments
 (0)