Skip to content

Commit 3ab5bcc

Browse files
committed
Add example that no longer compiles with Scala 3
1 parent a9464d3 commit 3ab5bcc

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

docs/docs/reference/changed/implicit-conversions-spec.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,15 @@ Views are applied in three situations:
4848
In Scala 2, views whose parameters are passed by-value take precedence
4949
over views whose parameters are passed by-name. This is no longer the
5050
case in Scala 3. A type error reporting the ambiguous conversions will
51-
be emitted in cases where this rule would be applied in Scala 2.
51+
be emitted in cases where this rule would be applied in Scala 2:
52+
53+
```scala
54+
implicit def conv1(x: Int): String = x.toString
55+
implicit def conv2(x: => Int): String = x.toString
56+
57+
val x: String = 0 // Compiles in Scala2 (uses `conv1`),
58+
// type error in Scala 3 because of ambiguity.
59+
```
5260

5361
In Scala 2, implicit values of a function type would be considered as
5462
potential views. In Scala 3, these implicit value need to have type

0 commit comments

Comments
 (0)