File tree 5 files changed +81
-1
lines changed
compiler/src/dotty/tools/dotc
5 files changed +81
-1
lines changed Original file line number Diff line number Diff line change @@ -69,7 +69,12 @@ class TreeTypeMap(
69
69
}
70
70
71
71
def mapType (tp : Type ): Type =
72
- mapOwnerThis(typeMap(tp).substSym(substFrom, substTo))
72
+ val substMap = new TypeMap ():
73
+ def apply (tp : Type ): Type = tp match
74
+ case tp : TermRef if tp.symbol.isImport => mapOver(tp)
75
+ case tp => tp.substSym(substFrom, substTo)
76
+ mapOwnerThis(substMap(typeMap(tp)))
77
+ end mapType
73
78
74
79
private def updateDecls (prevStats : List [Tree ], newStats : List [Tree ]): Unit =
75
80
if (prevStats.isEmpty) assert(newStats.isEmpty)
Original file line number Diff line number Diff line change @@ -6295,6 +6295,12 @@ object Types extends TypeUtils {
6295
6295
val ctx = this .mapCtx // optimization for performance
6296
6296
given Context = ctx
6297
6297
tp match {
6298
+ case tp : TermRef if tp.symbol.isImport =>
6299
+ // see tests/pos/i19493.scala for examples requiring mapping over imports
6300
+ val ImportType (e) = tp.info: @ unchecked
6301
+ val e1 = singleton(apply(e.tpe))
6302
+ newImportSymbol(tp.symbol.owner, e1).termRef
6303
+
6298
6304
case tp : NamedType =>
6299
6305
if stopBecauseStaticOrLocal(tp) then tp
6300
6306
else
Original file line number Diff line number Diff line change
1
+
2
+ import scala .quoted .*
3
+ import scala .compiletime .summonInline
4
+
5
+ trait SomeImplicits :
6
+ given int : Int
7
+
8
+ object Macro :
9
+
10
+ transparent inline def testSummon : SomeImplicits => Int = $ { testSummonImpl }
11
+
12
+ private def testSummonImpl (using Quotes ): Expr [SomeImplicits => Int ] =
13
+ import quotes .reflect .*
14
+ ' {
15
+ (x : SomeImplicits ) =>
16
+ import x .given
17
+ summonInline[Int ]
18
+ }
Original file line number Diff line number Diff line change
1
+
2
+ def fn : Unit = Macro .testSummon
Original file line number Diff line number Diff line change
1
+ import scala .compiletime .{summonAll , summonInline }
2
+ import deriving .Mirror
3
+
4
+ type Sc [X ] = X
5
+ case class Row [T [_]](name : T [String ])
6
+
7
+ class DialectTypeMappers :
8
+ given String = ???
9
+
10
+ inline def metadata (dialect : DialectTypeMappers )(using m : Mirror .Of [Row [Sc ]]): m.MirroredElemTypes =
11
+ import dialect .given
12
+ summonAll[m.MirroredElemTypes ]
13
+
14
+ def f = metadata(??? )
15
+
16
+
17
+ object Minimization :
18
+
19
+ class GivesString :
20
+ given aString : String = ???
21
+
22
+ inline def foo (x : GivesString ): Unit =
23
+ import x .aString
24
+ summon[String ] // ok
25
+ summonInline[String ] // was error
26
+
27
+ foo(??? )
28
+
29
+
30
+ trait A :
31
+ val x : GivesString
32
+
33
+ inline def bar : Unit =
34
+ import this .x .aString
35
+ summon[String ] // ok
36
+ summonInline[String ] // was error
37
+
38
+ val a : A = ???
39
+ a.bar
40
+
41
+
42
+ inline def baz () = (x : GivesString ) =>
43
+ import x .aString
44
+ summon[String ] // ok
45
+ summonInline[String ] // was error
46
+
47
+ baz()
48
+
49
+ end Minimization
You can’t perform that action at this time.
0 commit comments