Skip to content

Commit 5dced62

Browse files
authored
Merge pull request #6244 from milessabin/topic/i6241
Reimplement valueOf as an implicit match
2 parents 2cb5dd6 + 40739da commit 5dced62

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

library/src-bootstrapped/dotty/DottyPredef.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ object DottyPredef {
3232
* }}}
3333
* @group utilities
3434
*/
35-
@forceInline def valueOf[T](implicit vt: ValueOf[T]): T = vt.value
35+
inline def valueOf[T]: T = implicit match {
36+
case ev: ValueOf[T] => ev.value
37+
}
3638

3739
inline def the[T](implicit x: T): x.type = x
3840
}

tests/pos/i6241.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
object Test {
2+
inline def v[T] = valueOf[T]
3+
4+
v["foo"]
5+
}

0 commit comments

Comments
 (0)