diff --git a/compiler/src/dotty/tools/dotc/typer/Implicits.scala b/compiler/src/dotty/tools/dotc/typer/Implicits.scala index 9c044207d4b3..29337165272a 100644 --- a/compiler/src/dotty/tools/dotc/typer/Implicits.scala +++ b/compiler/src/dotty/tools/dotc/typer/Implicits.scala @@ -1138,7 +1138,7 @@ trait Implicits: case _ => pt case _ => NoType def tryConversion(using Context) = { - val restpeConv = if ref.symbol.is(Given) then conversionResultType(ref.symbol.info) else NoType + val restpeConv = if ref.symbol.is(Given) then conversionResultType(ref.widenTermRefExpr) else NoType val untpdConv = if restpeConv.exists then untpd.Select( diff --git a/tests/pos/i15867.specs2.scala b/tests/pos/i15867.specs2.scala new file mode 100644 index 000000000000..da89b2cba9f0 --- /dev/null +++ b/tests/pos/i15867.specs2.scala @@ -0,0 +1,9 @@ +class Foo: + given Conversion[String, Data] with + def apply(str: String): Data = new Data(str) + + class Data(str: String): + def |(str: String) = new Data(this.str + str) + +class Bar extends Foo: + "str" | "ing"