Skip to content

Commit

Permalink
Merge pull request #13662 from dotty-staging/fix-12955
Browse files Browse the repository at this point in the history
Allow using clauses to introduce Scala-2 conversions
  • Loading branch information
odersky authored Oct 4, 2021
2 parents a19f5dc + f94e390 commit d4ba729
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 5 additions & 1 deletion compiler/src/dotty/tools/dotc/typer/Implicits.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1041,9 +1041,13 @@ trait Implicits:
adapt(generated, pt.widenExpr, locked)
else {
def untpdGenerated = untpd.TypedSplice(generated)
def producesConversion(info: Type): Boolean = info match
case info: PolyType => producesConversion(info.resType)
case info: MethodType if info.isImplicitMethod => producesConversion(info.resType)
case _ => info.derivesFrom(defn.ConversionClass)
def tryConversion(using Context) = {
val untpdConv =
if (ref.symbol.is(Given))
if ref.symbol.is(Given) && producesConversion(ref.symbol.info) then
untpd.Select(
untpd.TypedSplice(
adapt(generated,
Expand Down
2 changes: 2 additions & 0 deletions tests/pos/i12955.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def test[A, B](using c: A <:< B) =
val b: B = ??? : A

0 comments on commit d4ba729

Please sign in to comment.