File tree Expand file tree Collapse file tree 1 file changed +10
-14
lines changed
compiler/src/dotty/tools/dotc/quoted Expand file tree Collapse file tree 1 file changed +10
-14
lines changed Original file line number Diff line number Diff line change @@ -184,7 +184,14 @@ object PickledQuotes {
184
184
QuotesCache .getTree(pickled) match
185
185
case Some (tree) =>
186
186
quotePickling.println(s " **** Using cached quote for TASTY \n $tree" )
187
- tree
187
+ treeOwner(tree) match
188
+ case Some (owner) if owner == ctx.owner =>
189
+ // Copy the cached tree to make sure the all definitions are unique.
190
+ // If the owner is different, then changeOwnerOfTree will change the owner later.
191
+ TreeTypeMap (oldOwners = List (owner), newOwners = List (owner)).apply(tree)
192
+ case _ =>
193
+ tree
194
+
188
195
case _ =>
189
196
val bytes = pickled match
190
197
case pickled : String => TastyString .unpickle(pickled)
@@ -197,25 +204,14 @@ object PickledQuotes {
197
204
unpickler.enter(Set .empty)
198
205
199
206
val tree = unpickler.tree
200
-
201
- var cacheable = true // TODO: can we remove this?
207
+ QuotesCache (pickled) = tree
202
208
203
209
// Make sure trees and positions are fully loaded
204
210
new TreeTraverser {
205
- def traverse (tree : Tree )(using Context ): Unit =
206
- tree match
207
- case _ : DefTree =>
208
- if ! tree.symbol.hasAnnotation(defn.QuotedRuntime_SplicedTypeAnnot )
209
- && ! tree.symbol.hasAnnotation(defn.QuotedRuntimePatterns_patternTypeAnnot )
210
- then
211
- cacheable = false
212
- case _ =>
213
- traverseChildren(tree)
211
+ def traverse (tree : Tree )(using Context ): Unit = traverseChildren(tree)
214
212
}.traverse(tree)
215
213
216
214
quotePickling.println(i " **** unpickled quote \n $tree" )
217
- if cacheable then
218
- QuotesCache (pickled) = tree
219
215
220
216
tree
221
217
}
You can’t perform that action at this time.
0 commit comments