mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-03-24 08:31:30 +00:00
Write KotlinSyntheticClass annotation on when-by-enum mapping classes
This commit is contained in:
@@ -30,6 +30,8 @@ import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.jetbrains.kotlin.codegen.AsmUtil.writeKotlinSyntheticClassAnnotation;
|
||||
import static org.jetbrains.kotlin.load.java.JvmAnnotationNames.KotlinSyntheticClass.Kind.WHEN_ON_ENUM_MAPPINGS;
|
||||
import static org.jetbrains.kotlin.resolve.jvm.AsmTypes.OBJECT_TYPE;
|
||||
import static org.jetbrains.org.objectweb.asm.Opcodes.*;
|
||||
|
||||
@@ -56,6 +58,8 @@ public class MappingClassesForWhenByEnumCodegen {
|
||||
generateFields(cb, mappings);
|
||||
generateInitialization(cb, mappings);
|
||||
|
||||
writeKotlinSyntheticClassAnnotation(cb, WHEN_ON_ENUM_MAPPINGS);
|
||||
|
||||
cb.done();
|
||||
}
|
||||
|
||||
|
||||
@@ -143,6 +143,15 @@ public class KotlinSyntheticClassAnnotationTest extends CodegenTestCase {
|
||||
);
|
||||
}
|
||||
|
||||
public void testWhenMappings() {
|
||||
doTestKotlinSyntheticClass(
|
||||
"enum class E { A }\n" +
|
||||
"val x = when (E.A) { E.A -> 1; else -> 0; }",
|
||||
"WhenMappings",
|
||||
WHEN_ON_ENUM_MAPPINGS
|
||||
);
|
||||
}
|
||||
|
||||
private void doTestKotlinSyntheticClass(
|
||||
@NotNull String code,
|
||||
@NotNull String classFilePart,
|
||||
|
||||
@@ -78,6 +78,7 @@ public final class JvmAnnotationNames {
|
||||
CALLABLE_REFERENCE_WRAPPER,
|
||||
LOCAL_FUNCTION,
|
||||
ANONYMOUS_FUNCTION,
|
||||
WHEN_ON_ENUM_MAPPINGS,
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,5 +34,6 @@ public @interface KotlinSyntheticClass {
|
||||
CALLABLE_REFERENCE_WRAPPER,
|
||||
LOCAL_FUNCTION,
|
||||
ANONYMOUS_FUNCTION,
|
||||
WHEN_ON_ENUM_MAPPINGS,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user