-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
1 parent
551eae4
commit 5ff35a9
Showing
4 changed files
with
46 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import scala.compiletime.* | ||
import scala.language.dynamics | ||
|
||
abstract class % extends Selectable | ||
|
||
trait Select { type Out <: % } | ||
trait Selector extends Dynamic { | ||
def selectDynamic[S <: Singleton & String](label: S): Any = ??? | ||
|
||
def unapply[R: RecordLike](record: R)(using | ||
t: Select, | ||
r: RecordLike[t.Out] | ||
): r.ElemTypes = ??? | ||
} | ||
|
||
trait RecordLike[R] { | ||
type ElemTypes <: Tuple | ||
} | ||
|
||
|
||
@main def Test = { | ||
val r: %{ val name: String; } = ??? | ||
|
||
// originally derived in macro, use dummy instance instead | ||
transparent inline given outputRecordLike[R <: %]: RecordLike[R] = null.asInstanceOf[ | ||
RecordLike[R] { | ||
type ElemTypes = String *: EmptyTuple | ||
} | ||
] | ||
|
||
type FieldSelector = Select { type Out = % { val name: String } } | ||
given fieldSelector: FieldSelector = ??? | ||
val selector: Selector = ??? | ||
|
||
val works = selector.unapply(r) | ||
val works2 = selector.unapply(r)(using summon, fieldSelector, summon) | ||
r match { | ||
case selector(value) => value // compilation error | ||
} | ||
} |