Skip to content

Commit db10393

Browse files
committed
Fix #6868, Move Adding Annotation Constructor after Setting ClassInfo in ClassfileParser
1 parent f87554b commit db10393

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,13 +166,14 @@ class ClassfileParser(
166166
for (i <- 0 until in.nextChar) parseMember(method = false)
167167
for (i <- 0 until in.nextChar) parseMember(method = true)
168168
classInfo = parseAttributes(classRoot.symbol, classInfo)
169-
if (isAnnotation) addAnnotationConstructor(classInfo)
170169

171170
classRoot.registerCompanion(moduleRoot.symbol)
172171
moduleRoot.registerCompanion(classRoot.symbol)
173172

174-
setClassInfo(classRoot, classInfo, fromScala2 = false)
175-
setClassInfo(moduleRoot, staticInfo, fromScala2 = false)
173+
setClassInfo(classRoot, classInfo, fromScala2 = false, isAnnotation = isAnnotation)
174+
setClassInfo(moduleRoot, staticInfo, fromScala2 = false, isAnnotation = isAnnotation)
175+
176+
if (isAnnotation) addAnnotationConstructor(classInfo)
176177
} else if (result == Some(NoEmbedded)) {
177178
for (sym <- List(moduleRoot.sourceModule, moduleRoot.symbol, classRoot.symbol)) {
178179
classRoot.owner.asClass.delete(sym)

compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ object Scala2Unpickler {
9595
cls.enter(constr, scope)
9696
}
9797

98-
def setClassInfo(denot: ClassDenotation, info: Type, fromScala2: Boolean, selfInfo: Type = NoType)(implicit ctx: Context): Unit = {
98+
def setClassInfo(denot: ClassDenotation, info: Type, fromScala2: Boolean, selfInfo: Type = NoType, isAnnotation: Boolean = false)(implicit ctx: Context): Unit = {
9999
val cls = denot.classSymbol
100100
val (tparams, TempClassInfoType(parents, decls, clazz)) = info match {
101101
case TempPolyType(tps, cinfo) => (tps, cinfo)
@@ -120,7 +120,8 @@ object Scala2Unpickler {
120120
if (tsym.exists) tsym.setFlag(TypeParam)
121121
else denot.enter(tparam, decls)
122122
}
123-
if (!denot.flagsUNSAFE.isAllOf(JavaModule)) ensureConstructor(denot.symbol.asClass, decls)
123+
if (!denot.flagsUNSAFE.isAllOf(JavaModule) && !isAnnotation)
124+
ensureConstructor(denot.symbol.asClass, decls)
124125

125126
val scalacCompanion = denot.classSymbol.scalacLinkedClass
126127

0 commit comments

Comments
 (0)