Skip to content

Commit a884556

Browse files
committed
Anchor import symbols at current owner
Needed to harmonize behavior of Typer/Namer and tpd. This is needed for making pickling, then unpickling the identity.
1 parent 7995851 commit a884556

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/dotty/tools/dotc/ast/tpd.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
244244
}
245245

246246
def Import(expr: Tree, selectors: List[untpd.Tree])(implicit ctx: Context): Import =
247-
ta.assignType(untpd.Import(expr, selectors), ctx.newImportSymbol(expr))
247+
ta.assignType(untpd.Import(expr, selectors), ctx.newImportSymbol(ctx.owner, expr))
248248

249249
def PackageDef(pid: RefTree, stats: List[Tree])(implicit ctx: Context): PackageDef =
250250
ta.assignType(untpd.PackageDef(pid, stats), pid)

src/dotty/tools/dotc/core/Symbols.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,8 @@ trait Symbols { this: Context =>
228228
newSymbol(cls, nme.localDummyName(cls), EmptyFlags, NoType)
229229

230230
/** Create an import symbol pointing back to given qualifier `expr`. */
231-
def newImportSymbol(expr: Tree, coord: Coord = NoCoord) =
232-
newSymbol(NoSymbol, nme.IMPORT, EmptyFlags, ImportType(expr), coord = coord)
231+
def newImportSymbol(owner: Symbol, expr: Tree, coord: Coord = NoCoord) =
232+
newSymbol(owner, nme.IMPORT, EmptyFlags, ImportType(expr), coord = coord)
233233

234234
/** Create a class constructor symbol for given class `cls`. */
235235
def newConstructor(cls: ClassSymbol, flags: FlagSet, paramNames: List[TermName], paramTypes: List[Type], privateWithin: Symbol = NoSymbol, coord: Coord = NoCoord) =

0 commit comments

Comments
 (0)