Skip to content

Commit

Permalink
Merge pull request #14668 from dotty-staging/fix-14656
Browse files Browse the repository at this point in the history
Generate opaque proxies also for base classes
  • Loading branch information
odersky committed Mar 14, 2022
2 parents 6e18b2a + cb764b0 commit 09a4ce3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/typer/Inliner.scala
Expand Up @@ -597,7 +597,7 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(using Context) {
def addOpaqueProxies(tp: Type, span: Span, forThisProxy: Boolean)(using Context): Unit =
tp.foreachPart {
case ref: TermRef =>
for cls <- ref.widen.classSymbols do
for cls <- ref.widen.baseClasses do
if cls.containsOpaques
&& (forThisProxy || inlinedMethod.isContainedIn(cls))
&& mapRef(ref).isEmpty
Expand Down
12 changes: 12 additions & 0 deletions tests/pos/i14656.scala
@@ -0,0 +1,12 @@

trait BigDecimalNewType:
opaque type Type = BigDecimal
def apply(value: BigDecimal): Type = value
extension (self: Type)
def value: BigDecimal = self
inline def +(y: Type): Type = apply(self.value + y.value)

object Amount extends BigDecimalNewType {
val x = Amount(0)
val y = (x + x) + x
}

0 comments on commit 09a4ce3

Please sign in to comment.