File tree Expand file tree Collapse file tree 2 files changed +34
-1
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -1134,7 +1134,7 @@ trait Implicits:
11341134 case _ => info.derivesFrom(defn.ConversionClass )
11351135 def tryConversion (using Context ) = {
11361136 val untpdConv =
1137- if ref.symbol.is( Given ) && producesConversion(ref.symbol.info) then
1137+ if ref.symbol.isOneOf( GivenOrImplicit ) && producesConversion(ref.symbol.info) then
11381138 untpd.Select (
11391139 untpd.TypedSplice (
11401140 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