Skip to content

Commit d4b5d96

Browse files
committed
Inline transparent implicit parameters when typing Unapply trees
We needed to delay the inlining of the transparent inline when typing the unapply function application. We used the NoInline mode, but this also stopped the inlining of the arguments of the unapply. To fix this we introduce a new mode, NoInlineUnapply, which is used to delay only the inlining of the unapply method and not the implicit arguments. Fixes #19623
1 parent 551eae4 commit d4b5d96

File tree

4 files changed

+6
-1
lines changed

4 files changed

+6
-1
lines changed

compiler/src/dotty/tools/dotc/core/Mode.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ object Mode {
122122

123123
val PatternOrTypeBits: Mode = Pattern | Type
124124

125+
/** Skip inlining of unapply methods. */
126+
val NoInlineUnapply: Mode = newMode(18, "NoInlineUnapply")
127+
125128
/** We are elaborating the fully qualified name of a package clause.
126129
* In this case, identifiers should never be imported.
127130
*/

compiler/src/dotty/tools/dotc/inlines/Inlines.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package inlines
55
import ast.*, core.*
66
import Flags.*, Symbols.*, Types.*, Decorators.*, Constants.*, Contexts.*
77
import StdNames.{tpnme, nme}
8+
import NameOps.*
89
import typer.*
910
import NameKinds.BodyRetainerName
1011
import SymDenotations.SymDenotation
@@ -64,6 +65,7 @@ object Inlines:
6465
&& !ctx.typer.hasInliningErrors
6566
&& !ctx.base.stopInlining
6667
&& !ctx.mode.is(Mode.NoInline)
68+
&& !(ctx.mode.is(Mode.NoInlineUnapply) && tree.symbol.name.isUnapplyName)
6769
}
6870

6971
private def needsTransparentInlining(tree: Tree)(using Context): Boolean =

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1492,7 +1492,7 @@ trait Applications extends Compatibility {
14921492

14931493
val dummyArg = dummyTreeOfType(ownType)
14941494
val (newUnapplyFn, unapplyApp) =
1495-
val unapplyAppCall = withMode(Mode.NoInline):
1495+
val unapplyAppCall = withMode(Mode.NoInlineUnapply):
14961496
typedExpr(untpd.TypedSplice(Apply(unapplyFn, dummyArg :: Nil)))
14971497
inlinedUnapplyFnAndApp(dummyArg, unapplyAppCall)
14981498

tests/pos/i19623.scala

Whitespace-only changes.

0 commit comments

Comments
 (0)