File tree 2 files changed +34
-1
lines changed
compiler/src/dotty/tools/dotc/typer
2 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -1176,7 +1176,7 @@ trait Implicits:
1176
1176
case _ => info.derivesFrom(defn.ConversionClass )
1177
1177
def tryConversion (using Context ) = {
1178
1178
val untpdConv =
1179
- if ref.symbol.is( Given ) && producesConversion(ref.symbol.info) then
1179
+ if ref.symbol.isOneOf( GivenOrImplicit ) && producesConversion(ref.symbol.info) then
1180
1180
untpd.Select (
1181
1181
untpd.TypedSplice (
1182
1182
adapt(generated,
Original file line number Diff line number Diff line change
1
+ object ConversionChain {
2
+
3
+ class X (val value : Int )
4
+
5
+ class Y (val x : X )
6
+
7
+ class Z (val y : Y )
8
+
9
+ trait Conv [A , B ] extends Conversion [A , B ]
10
+
11
+ given xy : Conv [X , Y ] = { (x : X ) => new Y (x) }
12
+
13
+ given yz : Conv [Y , Z ] = { (y : Y ) => new Z (y) }
14
+
15
+ object ConvUtils {
16
+ implicit def hypotheticalSyllogism [A , B , C ]( // implicit def instead of given
17
+ using
18
+ ab : Conv [A , B ],
19
+ bc : Conv [B , C ]
20
+ ): Conv [A , C ] = {
21
+
22
+ new Conv [A , C ] {
23
+ def apply (a : A ): C = bc(ab(a))
24
+ }
25
+ }
26
+ }
27
+ import ConvUtils .hypotheticalSyllogism
28
+
29
+ def test (): Unit = {
30
+ val x = new X (42 )
31
+ val z : Z = x
32
+ }
33
+ }
You can’t perform that action at this time.
0 commit comments