From b31b7bdc6246375ff240b62ccda555f95b825083 Mon Sep 17 00:00:00 2001 From: odersky Date: Fri, 20 Jun 2025 20:24:38 +0200 Subject: [PATCH] Fix isConversionTargetType test Was wrong for annotated types before. Fixes #23398 --- compiler/src/dotty/tools/dotc/core/Types.scala | 2 +- tests/pos/i23398.scala | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 tests/pos/i23398.scala diff --git a/compiler/src/dotty/tools/dotc/core/Types.scala b/compiler/src/dotty/tools/dotc/core/Types.scala index d9ea63267c0b..61b3b958fca3 100644 --- a/compiler/src/dotty/tools/dotc/core/Types.scala +++ b/compiler/src/dotty/tools/dotc/core/Types.scala @@ -472,7 +472,7 @@ object Types extends TypeUtils { case tp: TypeRef => (tp.symbol.isClass || tp.symbol.isOpaqueAlias) && tp.symbol.is(Into) case tp @ AppliedType(tycon, _) => - isInto || tycon.isConversionTargetType + tp.isInto || tycon.isConversionTargetType case tp: AndOrType => tp.tp1.isConversionTargetType && tp.tp2.isConversionTargetType case tp: TypeVar => diff --git a/tests/pos/i23398.scala b/tests/pos/i23398.scala new file mode 100644 index 000000000000..b38b139cc485 --- /dev/null +++ b/tests/pos/i23398.scala @@ -0,0 +1,16 @@ +//> using options -feature -Werror +import scala.language.experimental.into +import Conversion.into + +case class Foo(x: Int) + +given Conversion[Int, Foo] = Foo(_) + +def takeFoo(f: into[Foo]) = f +inline def inlineTakeFoo(f: into[Foo]) = f +inline def takeInlineFoo(inline f: into[Foo]) = f + +def test = + val f1 = takeFoo(1) + val f2 = inlineTakeFoo(1) + val f3 = takeInlineFoo(1)