diff --git a/compiler/src/dotty/tools/dotc/typer/Inliner.scala b/compiler/src/dotty/tools/dotc/typer/Inliner.scala index d097ed8dcc4e..00557e97fbaa 100644 --- a/compiler/src/dotty/tools/dotc/typer/Inliner.scala +++ b/compiler/src/dotty/tools/dotc/typer/Inliner.scala @@ -677,7 +677,7 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(using Context) { * map them to their opaque proxies. */ def mapOpaquesInValueArg(arg: Tree)(using Context): Tree = - val argType = arg.tpe.widen + val argType = arg.tpe.widenDealias addOpaqueProxies(argType, arg.span, forThisProxy = false) if opaqueProxies.nonEmpty then val mappedType = mapOpaques.typeMap(argType) diff --git a/tests/neg/i14653.scala b/tests/pos/i14653.scala similarity index 83% rename from tests/neg/i14653.scala rename to tests/pos/i14653.scala index 29a013534159..0d29cac4d818 100644 --- a/tests/neg/i14653.scala +++ b/tests/pos/i14653.scala @@ -11,8 +11,8 @@ object Amount: val aa: Amount = Amount(1) val ab: Amount = Amount(2) val ac: Amount = Amount(2) - val as1: Amount = aa + ab // error - val as2: Amount = aa + ab + ac // error + val as1: Amount = aa + ab + val as2: Amount = aa + ab + ac println(s"aa + ab = ${as1}") println(s"aa + ab = ${as2}") diff --git a/tests/pos/i14653b.scala b/tests/pos/i14653b.scala new file mode 100644 index 000000000000..75f4c0c3370f --- /dev/null +++ b/tests/pos/i14653b.scala @@ -0,0 +1,12 @@ +type Amount = Amount.Type +object Amount: + opaque type Type = Int + inline def twice(x: Type): Type = x + x + +def a: Amount = ??? +def b: Amount.Type = ??? +def test(c: Amount, d: Amount.Type): Unit = + Amount.twice(a) + Amount.twice(b) + Amount.twice(c) + Amount.twice(d)