diff options
Diffstat (limited to 'src/dotty/tools/dotc/core')
-rw-r--r-- | src/dotty/tools/dotc/core/Symbols.scala | 9 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/pickling/ClassfileParser.scala | 11 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/pickling/UnPickler.scala | 9 |
3 files changed, 15 insertions, 14 deletions
diff --git a/src/dotty/tools/dotc/core/Symbols.scala b/src/dotty/tools/dotc/core/Symbols.scala index a27ce3d6a..ed59a054d 100644 --- a/src/dotty/tools/dotc/core/Symbols.scala +++ b/src/dotty/tools/dotc/core/Symbols.scala @@ -161,6 +161,15 @@ trait Symbols { this: Context => owner.thisType, modcls, parents, decls, TermRef.withSymAndName(owner.thisType, module, name)), privateWithin, coord, assocFile) + def synthesizeCompanionMethod(name: TermName, ret: SymDenotation, owner: SymDenotation)(implicit ctx: Context) = { + if(owner.exists && ret.exists) ctx.newSymbol( + owner = owner.symbol, + name = name, + flags = Flags.Synthetic | Flags.Private, + info = ExprType(ret.typeRef)) + else NoSymbol + } + /** Create a package symbol with associated package class * from its non-info fields and a lazy type for loading the package's members. */ diff --git a/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala b/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala index 516b47c0a..898b47889 100644 --- a/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala +++ b/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala @@ -130,19 +130,14 @@ class ClassfileParser( for (i <- 0 until in.nextChar) parseMember(method = true) classInfo = parseAttributes(classRoot.symbol, classInfo) if (isAnnotation) addAnnotationConstructor(classInfo) - if (classRoot.exists) syntecizeCompanionMethod(nme.COMPANION_CLASS_METHOD, classRoot, moduleRoot) + val companionClassMethod = ctx.synthesizeCompanionMethod(nme.COMPANION_CLASS_METHOD, classRoot, moduleRoot) + if (companionClassMethod.exists) companionClassMethod.entered + setClassInfo(classRoot, classInfo) setClassInfo(moduleRoot, staticInfo) } - def syntecizeCompanionMethod(name: TermName, ret: SymDenotation, owner: SymDenotation)(implicit ctx: Context) = { - if(owner.exists) ctx.newSymbol( - owner = owner.symbol, - name = name, - flags = Flags.Synthetic | Flags.Private, - info = ExprType(ret.typeRef)).entered - } /** Add type parameters of enclosing classes */ def addEnclosingTParams()(implicit ctx: Context): Unit = { diff --git a/src/dotty/tools/dotc/core/pickling/UnPickler.scala b/src/dotty/tools/dotc/core/pickling/UnPickler.scala index e22d045ac..3466e8c8e 100644 --- a/src/dotty/tools/dotc/core/pickling/UnPickler.scala +++ b/src/dotty/tools/dotc/core/pickling/UnPickler.scala @@ -120,12 +120,9 @@ object UnPickler { if (!(denot.flagsUNSAFE is JavaModule)) ensureConstructor(denot.symbol.asClass, decls) if (denot.flagsUNSAFE is Module) { val scalacCompanion = denot.classSymbol.scalacLinkedClass - if (scalacCompanion.exists) - ctx.newSymbol( - owner = denot.classSymbol, - name = nme.COMPANION_CLASS_METHOD, - flags = Flags.Synthetic | Flags.Private, - info = ExprType(scalacCompanion.typeRef)).entered + val companionClassMethod = ctx.synthesizeCompanionMethod(nme.COMPANION_CLASS_METHOD, scalacCompanion, denot.classSymbol) + if (companionClassMethod.exists) + companionClassMethod.entered } denot.info = ClassInfo(denot.owner.thisType, denot.classSymbol, parentRefs, decls, ost) |