Skip to content

Commit 88781e7

Browse files
committed
Dealias arg type to detect opaque types
Fixes #14653
1 parent 400427d commit 88781e7

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(using Context) {
677677
* map them to their opaque proxies.
678678
*/
679679
def mapOpaquesInValueArg(arg: Tree)(using Context): Tree =
680-
val argType = arg.tpe.widen
680+
val argType = arg.tpe.widenDealias
681681
addOpaqueProxies(argType, arg.span, forThisProxy = false)
682682
if opaqueProxies.nonEmpty then
683683
val mappedType = mapOpaques.typeMap(argType)

tests/neg/i14653.scala renamed to tests/pos/i14653.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ object Amount:
1111
val aa: Amount = Amount(1)
1212
val ab: Amount = Amount(2)
1313
val ac: Amount = Amount(2)
14-
val as1: Amount = aa + ab // error
15-
val as2: Amount = aa + ab + ac // error
14+
val as1: Amount = aa + ab
15+
val as2: Amount = aa + ab + ac
1616

1717
println(s"aa + ab = ${as1}")
1818
println(s"aa + ab = ${as2}")

tests/pos/i14653b.scala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
type Amount = Amount.Type
2+
object Amount:
3+
opaque type Type = Int
4+
inline def twice(x: Type): Type = x + x
5+
6+
def a: Amount = ???
7+
def b: Amount.Type = ???
8+
def test(c: Amount, d: Amount.Type): Unit =
9+
Amount.twice(a)
10+
Amount.twice(b)
11+
Amount.twice(c)
12+
Amount.twice(d)

0 commit comments

Comments
 (0)