Skip to content

Commit 912b4bc

Browse files
oderskyDarkDimius
authored andcommitted
Fix of #56 - newModuleSymbol & newCompleteModuleSymbol
Needs new TypeRef creation method that works for NoPrefix and at the same time does not need a denotation. This is provided by method TermRef.withNakedSymbol.
1 parent db950e5 commit 912b4bc

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ trait Symbols { this: Context =>
132132
infoFn(module, modcls), privateWithin)
133133
val mdenot = SymDenotation(
134134
module, owner, name, modFlags | ModuleCreationFlags,
135-
if (cdenot.isCompleted) TypeRef(owner.thisType, modclsName) withSym modcls
135+
if (cdenot.isCompleted) TypeRef.withSymAndName(owner.thisType, modcls, modclsName)
136136
else new ModuleCompleter(modcls))
137137
module.denot = mdenot
138138
modcls.denot = cdenot
@@ -157,7 +157,7 @@ trait Symbols { this: Context =>
157157
newModuleSymbol(
158158
owner, name, modFlags, clsFlags,
159159
(module, modcls) => ClassInfo(
160-
owner.thisType, modcls, parents, decls, TermRef(owner.thisType, name) withSym module),
160+
owner.thisType, modcls, parents, decls, TermRef.withSymAndName(owner.thisType, module, name)),
161161
privateWithin, coord, assocFile)
162162

163163
/** Create a package symbol with associated package class

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,8 +1167,10 @@ object Types {
11671167
def apply(prefix: Type, name: TermName)(implicit ctx: Context): TermRef =
11681168
ctx.uniqueNamedTypes.enterIfNew(prefix, name).asInstanceOf[TermRef]
11691169
def apply(prefix: Type, sym: TermSymbol)(implicit ctx: Context): TermRef =
1170-
if (prefix eq NoPrefix) unique(new NoPrefixTermRef(sym.name, sym))
1171-
else apply(prefix, sym.name) withSym sym
1170+
withSymAndName(prefix, sym, sym.name)
1171+
def withSymAndName(prefix: Type, sym: TermSymbol, name: TermName)(implicit ctx: Context): TermRef =
1172+
if (prefix eq NoPrefix) unique(new NoPrefixTermRef(name, sym))
1173+
else apply(prefix, name) withSym sym
11721174
def apply(prefix: Type, name: TermName, denot: Denotation)(implicit ctx: Context): TermRef =
11731175
(if (prefix eq NoPrefix) apply(prefix, denot.symbol.asTerm) else apply(prefix, name)) withDenot denot
11741176
def withSig(prefix: Type, name: TermName, sig: Signature)(implicit ctx: Context): TermRef =
@@ -1182,8 +1184,10 @@ object Types {
11821184
def apply(prefix: Type, name: TypeName)(implicit ctx: Context): TypeRef =
11831185
ctx.uniqueNamedTypes.enterIfNew(prefix, name).asInstanceOf[TypeRef]
11841186
def apply(prefix: Type, sym: TypeSymbol)(implicit ctx: Context): TypeRef =
1185-
if (prefix eq NoPrefix) unique(new NoPrefixTypeRef(sym.name, sym))
1186-
else apply(prefix, sym.name) withSym sym
1187+
withSymAndName(prefix, sym, sym.name)
1188+
def withSymAndName(prefix: Type, sym: TypeSymbol, name: TypeName)(implicit ctx: Context): TypeRef =
1189+
if (prefix eq NoPrefix) unique(new NoPrefixTypeRef(name, sym))
1190+
else apply(prefix, name) withSym sym
11871191
def apply(prefix: Type, name: TypeName, denot: Denotation)(implicit ctx: Context): TypeRef =
11881192
(if (prefix eq NoPrefix) apply(prefix, denot.symbol.asType) else apply(prefix, name)) withDenot denot
11891193
}

0 commit comments

Comments
 (0)