aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Petrashko <dmitry.petrashko@gmail.com>2015-03-25 18:21:58 +0100
committerDmitry Petrashko <dmitry.petrashko@gmail.com>2015-03-25 18:21:58 +0100
commitd01ecb733dc8990d1f5d432e1fb9eb488bb7e3b4 (patch)
treeaec4db023e4b21677077fe10f4aa5859c0fa9d2b
parent13a05d5119e33333000f969817434629443d6bb2 (diff)
downloaddotty-d01ecb733dc8990d1f5d432e1fb9eb488bb7e3b4.tar.gz
dotty-d01ecb733dc8990d1f5d432e1fb9eb488bb7e3b4.tar.bz2
dotty-d01ecb733dc8990d1f5d432e1fb9eb488bb7e3b4.zip
Add companion class methods for files read from scala & java
-rw-r--r--src/dotty/tools/dotc/core/pickling/ClassfileParser.scala10
-rw-r--r--src/dotty/tools/dotc/core/pickling/UnPickler.scala10
2 files changed, 20 insertions, 0 deletions
diff --git a/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala b/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala
index 3b8daab39..516b47c0a 100644
--- a/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala
+++ b/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala
@@ -130,10 +130,20 @@ 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)
+
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 = {
var sym = classRoot.owner
diff --git a/src/dotty/tools/dotc/core/pickling/UnPickler.scala b/src/dotty/tools/dotc/core/pickling/UnPickler.scala
index 170ebd28b..e22d045ac 100644
--- a/src/dotty/tools/dotc/core/pickling/UnPickler.scala
+++ b/src/dotty/tools/dotc/core/pickling/UnPickler.scala
@@ -118,6 +118,16 @@ object UnPickler {
denot.owner.thisType select denot.sourceModule
else selfInfo
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
+ }
+
denot.info = ClassInfo(denot.owner.thisType, denot.classSymbol, parentRefs, decls, ost)
}
}