aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core
diff options
context:
space:
mode:
authorDmitry Petrashko <dmitry.petrashko@gmail.com>2015-03-26 17:32:33 +0100
committerDmitry Petrashko <dmitry.petrashko@gmail.com>2015-03-26 18:24:48 +0100
commit0a94d6e694703be747b5e3c72c5d903ecd6b3997 (patch)
treecc16abd661a3dc71647eaf31bf936eb45eecb47c /src/dotty/tools/dotc/core
parentf40c49817962235f074174dd740c3668fe9ac03f (diff)
downloaddotty-0a94d6e694703be747b5e3c72c5d903ecd6b3997.tar.gz
dotty-0a94d6e694703be747b5e3c72c5d903ecd6b3997.tar.bz2
dotty-0a94d6e694703be747b5e3c72c5d903ecd6b3997.zip
Remove code duplication between Namer, ClassfileParser and UnPickler
Diffstat (limited to 'src/dotty/tools/dotc/core')
-rw-r--r--src/dotty/tools/dotc/core/Symbols.scala9
-rw-r--r--src/dotty/tools/dotc/core/pickling/ClassfileParser.scala11
-rw-r--r--src/dotty/tools/dotc/core/pickling/UnPickler.scala9
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)