Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,14 @@ class ClassfileParser(
for (i <- 0 until in.nextChar) parseMember(method = false)
for (i <- 0 until in.nextChar) parseMember(method = true)
classInfo = parseAttributes(classRoot.symbol, classInfo)
if (isAnnotation) addAnnotationConstructor(classInfo)

classRoot.registerCompanion(moduleRoot.symbol)
moduleRoot.registerCompanion(classRoot.symbol)

setClassInfo(classRoot, classInfo, fromScala2 = false)
setClassInfo(moduleRoot, staticInfo, fromScala2 = false)
setClassInfo(classRoot, classInfo, fromScala2 = false, isAnnotation = isAnnotation)
setClassInfo(moduleRoot, staticInfo, fromScala2 = false, isAnnotation = isAnnotation)

if (isAnnotation) addAnnotationConstructor(classInfo)
} else if (result == Some(NoEmbedded)) {
for (sym <- List(moduleRoot.sourceModule, moduleRoot.symbol, classRoot.symbol)) {
classRoot.owner.asClass.delete(sym)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ object Scala2Unpickler {
cls.enter(constr, scope)
}

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

val scalacCompanion = denot.classSymbol.scalacLinkedClass

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
public @interface MyJava_1 {

public String value() default "MyJava";

public MyClassTypeA typeA();

public MyClassTypeB typeB() default @MyClassTypeB;

public enum MyClassTypeA {
A, B
}

public @interface MyClassTypeB {}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@MyJava_1("MyScala1", typeA = MyJava_1.MyClassTypeA.B)
object MyScala {
def a(mj: MyJava_1): Unit = {
println("MyJava")
}

@MyJava_1(typeA = MyJava_1.MyClassTypeA.A)
def b(): Int = 1

@MyJava_1(value = "MyScala2", typeA = MyJava_1.MyClassTypeA.B)
def c(): Int = 2
}