-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The inliner replaces references to parameters by their corresponding proxys, including in singleton types. It did not handle the mapping over import types, the symbols of which way have depended on parameters. Both i19493 and i19436 require mapping the type of the expr in an `ImportType` which is itself the info of a `TermRef`. In the first issue, for the substitution of an inline def parameter proxy. In the second issue, for the parameter of a lambda returned from an inline def. Both can be handled in `TypeMap` by mapping over references to `ImportType`s. The second case also requires modifying `TreeTypeMap#mapType` such that the logic mapping over imports is done within a `TypeMap` doing the symbol substitutions. Also note these mappings are only necessary for `summonInline`s (which could have just been made non-inline) resolving post-inlining to givens imported within the inline definition. Fix #19493 Fix #19436
- Loading branch information
Showing
5 changed files
with
81 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
import scala.quoted.* | ||
import scala.compiletime.summonInline | ||
|
||
trait SomeImplicits: | ||
given int: Int | ||
|
||
object Macro: | ||
|
||
transparent inline def testSummon: SomeImplicits => Int = ${ testSummonImpl } | ||
|
||
private def testSummonImpl(using Quotes): Expr[SomeImplicits => Int] = | ||
import quotes.reflect.* | ||
'{ | ||
(x: SomeImplicits) => | ||
import x.given | ||
summonInline[Int] | ||
} |
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,2 @@ | ||
|
||
def fn: Unit = Macro.testSummon |
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,49 @@ | ||
import scala.compiletime.{summonAll, summonInline} | ||
import deriving.Mirror | ||
|
||
type Sc[X] = X | ||
case class Row[T[_]](name: T[String]) | ||
|
||
class DialectTypeMappers: | ||
given String = ??? | ||
|
||
inline def metadata(dialect: DialectTypeMappers)(using m: Mirror.Of[Row[Sc]]): m.MirroredElemTypes = | ||
import dialect.given | ||
summonAll[m.MirroredElemTypes] | ||
|
||
def f = metadata(???) | ||
|
||
|
||
object Minimization: | ||
|
||
class GivesString: | ||
given aString: String = ??? | ||
|
||
inline def foo(x: GivesString): Unit = | ||
import x.aString | ||
summon[String] // ok | ||
summonInline[String] // was error | ||
|
||
foo(???) | ||
|
||
|
||
trait A: | ||
val x: GivesString | ||
|
||
inline def bar: Unit = | ||
import this.x.aString | ||
summon[String] // ok | ||
summonInline[String] // was error | ||
|
||
val a: A = ??? | ||
a.bar | ||
|
||
|
||
inline def baz() = (x: GivesString) => | ||
import x.aString | ||
summon[String] // ok | ||
summonInline[String] // was error | ||
|
||
baz() | ||
|
||
end Minimization |