Skip to content

Commit d4ba729

Browse files
authored
Merge pull request #13662 from dotty-staging/fix-12955
Allow using clauses to introduce Scala-2 conversions
2 parents a19f5dc + f94e390 commit d4ba729

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

compiler/src/dotty/tools/dotc/typer/Implicits.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1041,9 +1041,13 @@ trait Implicits:
10411041
adapt(generated, pt.widenExpr, locked)
10421042
else {
10431043
def untpdGenerated = untpd.TypedSplice(generated)
1044+
def producesConversion(info: Type): Boolean = info match
1045+
case info: PolyType => producesConversion(info.resType)
1046+
case info: MethodType if info.isImplicitMethod => producesConversion(info.resType)
1047+
case _ => info.derivesFrom(defn.ConversionClass)
10441048
def tryConversion(using Context) = {
10451049
val untpdConv =
1046-
if (ref.symbol.is(Given))
1050+
if ref.symbol.is(Given) && producesConversion(ref.symbol.info) then
10471051
untpd.Select(
10481052
untpd.TypedSplice(
10491053
adapt(generated,

tests/pos/i12955.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
def test[A, B](using c: A <:< B) =
2+
val b: B = ??? : A

0 commit comments

Comments
 (0)