-
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.
Backport "Map over refs of ImportTypes in TypeMap" to 3.5.1 (#20957)
Backports #20837 to 3.5.1-RC1
- 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 |