diff options
author | Martin Odersky <odersky@gmail.com> | 2013-12-22 17:00:14 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2013-12-22 17:00:19 +0100 |
commit | c9d8d291687de687fa2bcdb806fc85293c3ba4dc (patch) | |
tree | d74e6a624ebab99ffbb2136e7b5cc4f5331e9403 /src/dotty/tools | |
parent | 70e57128bb7623998f76aaf2ad8541d438b4b2b8 (diff) | |
download | dotty-c9d8d291687de687fa2bcdb806fc85293c3ba4dc.tar.gz dotty-c9d8d291687de687fa2bcdb806fc85293c3ba4dc.tar.bz2 dotty-c9d8d291687de687fa2bcdb806fc85293c3ba4dc.zip |
Generalized ensure constructor logic from Java classes to all classes or traits except Java modules.
We now assume that all classes or traits (with the exception of Java statics) have a constructor.
Diffstat (limited to 'src/dotty/tools')
-rw-r--r-- | src/dotty/tools/dotc/core/pickling/ClassfileParser.scala | 7 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/pickling/UnPickler.scala | 4 |
2 files changed, 4 insertions, 7 deletions
diff --git a/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala b/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala index ad45f4d19..81bdc7809 100644 --- a/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala +++ b/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala @@ -123,13 +123,6 @@ class ClassfileParser( for (i <- 0 until in.nextChar) parseMember(method = false) for (i <- 0 until in.nextChar) parseMember(method = true) - - val needsConstructor = - instanceScope.lookup(nme.CONSTRUCTOR) == NoSymbol && !(sflags is Flags.Interface) - - if (needsConstructor) - classRoot.enter(cctx.newDefaultConstructor(classRoot.symbol.asClass), instanceScope) - classInfo = parseAttributes(classRoot.symbol, classInfo) setClassInfo(classRoot, classInfo) setClassInfo(moduleRoot, staticInfo) diff --git a/src/dotty/tools/dotc/core/pickling/UnPickler.scala b/src/dotty/tools/dotc/core/pickling/UnPickler.scala index 0351c948d..2f063fd4c 100644 --- a/src/dotty/tools/dotc/core/pickling/UnPickler.scala +++ b/src/dotty/tools/dotc/core/pickling/UnPickler.scala @@ -89,6 +89,9 @@ object UnPickler { tp.derivedPolyType(paramNames, tp.paramBounds, arrayToRepeated(tp.resultType)) } + def ensureConstructor(cls: ClassSymbol, scope: Scope)(implicit ctx: Context) = + if (scope.lookup(nme.CONSTRUCTOR) == NoSymbol) cls.enter(ctx.newDefaultConstructor(cls), scope) + def setClassInfo(denot: ClassDenotation, info: Type, selfInfo: Type = NoType)(implicit ctx: Context): Unit = { val cls = denot.classSymbol val (tparams, TempClassInfoType(parents, decls, clazz)) = info match { @@ -105,6 +108,7 @@ object UnPickler { if ((selfInfo eq NoType) && (denot is ModuleClass)) denot.owner.thisType select denot.sourceModule else selfInfo + if (!(denot.flagsUNSAFE is JavaModule)) ensureConstructor(denot.symbol.asClass, decls) denot.info = ClassInfo(denot.owner.thisType, denot.classSymbol, parentRefs, decls, ost) } } |