Don't throw exception on error types in light classes mode
#KT-26829 Fixed #KT-26827 Fixed
This commit is contained in:
@@ -509,31 +509,35 @@ public class KotlinTypeMapper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Make sure this method is called only from back-end
|
||||||
|
// It uses staticTypeMappingConfiguration that throws exception on error types
|
||||||
@NotNull
|
@NotNull
|
||||||
public static Type mapInlineClassTypeAsDeclaration(@NotNull KotlinType kotlinType) {
|
public static Type mapInlineClassTypeAsDeclaration(@NotNull KotlinType kotlinType) {
|
||||||
return mapInlineClassType(kotlinType, TypeMappingMode.CLASS_DECLARATION);
|
return mapInlineClassType(kotlinType, TypeMappingMode.CLASS_DECLARATION, staticTypeMappingConfiguration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Make sure this method is called only from back-end
|
||||||
|
// It uses staticTypeMappingConfiguration that throws exception on error types
|
||||||
@NotNull
|
@NotNull
|
||||||
public static Type mapUnderlyingTypeOfInlineClassType(@NotNull KotlinType kotlinType) {
|
public static Type mapUnderlyingTypeOfInlineClassType(@NotNull KotlinType kotlinType) {
|
||||||
KotlinType underlyingType = InlineClassesUtilsKt.unsubstitutedUnderlyingType(kotlinType);
|
KotlinType underlyingType = InlineClassesUtilsKt.unsubstitutedUnderlyingType(kotlinType);
|
||||||
if (underlyingType == null) {
|
if (underlyingType == null) {
|
||||||
throw new IllegalStateException("There should be underlying type for inline class type: " + kotlinType);
|
throw new IllegalStateException("There should be underlying type for inline class type: " + kotlinType);
|
||||||
}
|
}
|
||||||
return mapInlineClassType(underlyingType, TypeMappingMode.DEFAULT);
|
return mapInlineClassType(underlyingType, TypeMappingMode.DEFAULT, staticTypeMappingConfiguration);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
private Type mapInlineClassType(@NotNull KotlinType kotlinType) {
|
||||||
public static Type mapInlineClassType(@NotNull KotlinType kotlinType) {
|
return mapInlineClassType(kotlinType, TypeMappingMode.DEFAULT, typeMappingConfiguration);
|
||||||
return mapInlineClassType(kotlinType, TypeMappingMode.DEFAULT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Type mapInlineClassType(
|
private static Type mapInlineClassType(
|
||||||
@NotNull KotlinType kotlinType,
|
@NotNull KotlinType kotlinType,
|
||||||
@NotNull TypeMappingMode mode
|
@NotNull TypeMappingMode mode,
|
||||||
|
@NotNull TypeMappingConfiguration<Type> configuration
|
||||||
) {
|
) {
|
||||||
return TypeSignatureMappingKt.mapType(
|
return TypeSignatureMappingKt.mapType(
|
||||||
kotlinType, AsmTypeFactory.INSTANCE, mode, staticTypeMappingConfiguration, null,
|
kotlinType, AsmTypeFactory.INSTANCE, mode, configuration, null,
|
||||||
(ktType, asmType, typeMappingMode) -> Unit.INSTANCE,
|
(ktType, asmType, typeMappingMode) -> Unit.INSTANCE,
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
@@ -1400,7 +1404,7 @@ public class KotlinTypeMapper {
|
|||||||
* In that case the generated method's return type should be boxed: otherwise it's not possible to use
|
* In that case the generated method's return type should be boxed: otherwise it's not possible to use
|
||||||
* this class from Java since javac issues errors when loading the class (incompatible return types)
|
* this class from Java since javac issues errors when loading the class (incompatible return types)
|
||||||
*/
|
*/
|
||||||
private static boolean forceBoxedReturnType(@NotNull FunctionDescriptor descriptor) {
|
private boolean forceBoxedReturnType(@NotNull FunctionDescriptor descriptor) {
|
||||||
if (isBoxMethodForInlineClass(descriptor)) return true;
|
if (isBoxMethodForInlineClass(descriptor)) return true;
|
||||||
|
|
||||||
//noinspection ConstantConditions
|
//noinspection ConstantConditions
|
||||||
@@ -1414,7 +1418,7 @@ public class KotlinTypeMapper {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isJvmPrimitive(@NotNull KotlinType kotlinType) {
|
private boolean isJvmPrimitive(@NotNull KotlinType kotlinType) {
|
||||||
if (KotlinBuiltIns.isPrimitiveType(kotlinType)) return true;
|
if (KotlinBuiltIns.isPrimitiveType(kotlinType)) return true;
|
||||||
|
|
||||||
if (InlineClassesUtilsKt.isInlineClassType(kotlinType) && !KotlinTypeKt.isError(kotlinType)) {
|
if (InlineClassesUtilsKt.isInlineClassType(kotlinType) && !KotlinTypeKt.isError(kotlinType)) {
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
// PROBLEM: none
|
||||||
|
// ERROR: Modifier 'data' is incompatible with 'inline'
|
||||||
|
// ERROR: Modifier 'inline' is incompatible with 'data'
|
||||||
|
// ERROR: Unresolved reference: Unresolved
|
||||||
|
|
||||||
|
data inline class Foo(val x: <caret>Unresolved)
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
// WITH_RUNTIME
|
||||||
|
// PROBLEM: none
|
||||||
|
|
||||||
|
inline class Inline(val x1: UInt)
|
||||||
|
class WrapInline(<caret>val x2: Inline)
|
||||||
+10
@@ -6178,6 +6178,11 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest {
|
|||||||
runTest("idea/testData/inspectionsLocal/unusedSymbol/companionViaImport.kt");
|
runTest("idea/testData/inspectionsLocal/unusedSymbol/companionViaImport.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("dataInlineClassDeclaration.kt")
|
||||||
|
public void testDataInlineClassDeclaration() throws Exception {
|
||||||
|
runTest("idea/testData/inspectionsLocal/unusedSymbol/dataInlineClassDeclaration.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("inAnonymous.kt")
|
@TestMetadata("inAnonymous.kt")
|
||||||
public void testInAnonymous() throws Exception {
|
public void testInAnonymous() throws Exception {
|
||||||
runTest("idea/testData/inspectionsLocal/unusedSymbol/inAnonymous.kt");
|
runTest("idea/testData/inspectionsLocal/unusedSymbol/inAnonymous.kt");
|
||||||
@@ -6198,6 +6203,11 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest {
|
|||||||
runTest("idea/testData/inspectionsLocal/unusedSymbol/internal.kt");
|
runTest("idea/testData/inspectionsLocal/unusedSymbol/internal.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("propertyOfInlineClassType.kt")
|
||||||
|
public void testPropertyOfInlineClassType() throws Exception {
|
||||||
|
runTest("idea/testData/inspectionsLocal/unusedSymbol/propertyOfInlineClassType.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("withJvmNameUsedFromKotlin.kt")
|
@TestMetadata("withJvmNameUsedFromKotlin.kt")
|
||||||
public void testWithJvmNameUsedFromKotlin() throws Exception {
|
public void testWithJvmNameUsedFromKotlin() throws Exception {
|
||||||
runTest("idea/testData/inspectionsLocal/unusedSymbol/withJvmNameUsedFromKotlin.kt");
|
runTest("idea/testData/inspectionsLocal/unusedSymbol/withJvmNameUsedFromKotlin.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user