Fix unbound class literals for inline classes

#KT-28361 Fixed
This commit is contained in:
Mikhail Zarechenskiy
2018-12-13 16:53:19 +03:00
parent 8f821c9ef5
commit c924a6efe8
6 changed files with 27 additions and 11 deletions
@@ -1217,8 +1217,16 @@ public class AsmUtil {
return JvmClassName.byFqNameWithoutInnerClasses(fqName).getInternalName();
}
public static void putJavaLangClassInstance(@NotNull InstructionAdapter v, @NotNull Type type) {
if (isPrimitive(type)) {
public static void putJavaLangClassInstance(
@NotNull InstructionAdapter v,
@NotNull Type type,
@Nullable KotlinType kotlinType,
@NotNull GenerationState state
) {
if (kotlinType != null && InlineClassesUtilsKt.isInlineClassType(kotlinType)) {
v.aconst(boxType(type, kotlinType, state));
}
else if (isPrimitive(type)) {
v.getstatic(boxType(type).getInternalName(), "TYPE", "Ljava/lang/Class;");
}
else {
@@ -402,7 +402,9 @@ public class ClosureCodegen extends MemberCodegen<KtElement> {
if (container instanceof ClassDescriptor) {
// TODO: would it work for arrays?
putJavaLangClassInstance(iv, state.getTypeMapper().mapClass((ClassDescriptor) container));
SimpleType containerKotlinType = ((ClassDescriptor) container).getDefaultType();
Type containerType = state.getTypeMapper().mapClass((ClassDescriptor) container);
putJavaLangClassInstance(iv, containerType, containerKotlinType, state);
}
else if (container instanceof PackageFragmentDescriptor) {
iv.aconst(state.getTypeMapper().mapOwner(descriptor));
@@ -3123,7 +3123,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
putReifiedOperationMarkerIfTypeIsReifiedParameter(type, ReifiedTypeInliner.OperationKind.JAVA_CLASS);
}
putJavaLangClassInstance(v, typeMapper.mapType(type));
putJavaLangClassInstance(v, typeMapper.mapType(type), type, state);
}
if (wrapIntoKClass) {