Skip to content

Commit 09a4ce3

Browse files
authored
Merge pull request #14668 from dotty-staging/fix-14656
Generate opaque proxies also for base classes
2 parents 6e18b2a + cb764b0 commit 09a4ce3

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(using Context) {
597597
def addOpaqueProxies(tp: Type, span: Span, forThisProxy: Boolean)(using Context): Unit =
598598
tp.foreachPart {
599599
case ref: TermRef =>
600-
for cls <- ref.widen.classSymbols do
600+
for cls <- ref.widen.baseClasses do
601601
if cls.containsOpaques
602602
&& (forThisProxy || inlinedMethod.isContainedIn(cls))
603603
&& mapRef(ref).isEmpty

tests/pos/i14656.scala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
trait BigDecimalNewType:
3+
opaque type Type = BigDecimal
4+
def apply(value: BigDecimal): Type = value
5+
extension (self: Type)
6+
def value: BigDecimal = self
7+
inline def +(y: Type): Type = apply(self.value + y.value)
8+
9+
object Amount extends BigDecimalNewType {
10+
val x = Amount(0)
11+
val y = (x + x) + x
12+
}

0 commit comments

Comments
 (0)