KTIJ-24768 Fix IllegalArgumentException in KtType.isPrimitiveBacked
This commit is contained in:
committed by
Space Team
parent
8d1cfe0017
commit
164cbc9968
+7
@@ -12,6 +12,7 @@ import org.jetbrains.org.objectweb.asm.Type
|
||||
|
||||
public abstract class KtJvmTypeMapper : KtAnalysisSessionComponent() {
|
||||
public abstract fun mapTypeToJvmType(type: KtType, mode: TypeMappingMode): Type
|
||||
public abstract fun isPrimitiveBacked(type: KtType): Boolean
|
||||
}
|
||||
|
||||
public interface KtJvmTypeMapperMixIn : KtAnalysisSessionMixIn {
|
||||
@@ -22,4 +23,10 @@ public interface KtJvmTypeMapperMixIn : KtAnalysisSessionMixIn {
|
||||
*/
|
||||
public fun KtType.mapTypeToJvmType(mode: TypeMappingMode = TypeMappingMode.DEFAULT): Type =
|
||||
withValidityAssertion { analysisSession.jvmTypeMapper.mapTypeToJvmType(this, mode) }
|
||||
|
||||
/**
|
||||
* Returns true if the type is backed by a single JVM primitive type
|
||||
*/
|
||||
public val KtType.isPrimitiveBacked: Boolean
|
||||
get() = withValidityAssertion { analysisSession.jvmTypeMapper.isPrimitiveBacked(this) }
|
||||
}
|
||||
|
||||
-11
@@ -15,7 +15,6 @@ import org.jetbrains.kotlin.analysis.api.types.KtTypeNullability
|
||||
import org.jetbrains.kotlin.builtins.StandardNames
|
||||
import org.jetbrains.kotlin.builtins.functions.FunctionTypeKind
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.org.objectweb.asm.Type
|
||||
|
||||
public abstract class KtTypeInfoProvider : KtAnalysisSessionComponent() {
|
||||
public abstract fun isFunctionalInterfaceType(type: KtType): Boolean
|
||||
@@ -144,16 +143,6 @@ public interface KtTypeInfoProviderMixIn : KtAnalysisSessionMixIn {
|
||||
return this.classId in DefaultTypeClassIds.PRIMITIVES
|
||||
}
|
||||
|
||||
context(KtJvmTypeMapperMixIn)
|
||||
public val KtType.isPrimitiveBacked: Boolean
|
||||
get() = withValidityAssertion {
|
||||
if (this !is KtNonErrorClassType) return false
|
||||
return when (this.mapTypeToJvmType().sort) {
|
||||
Type.BOOLEAN, Type.CHAR, Type.BYTE, Type.SHORT, Type.INT, Type.FLOAT, Type.LONG, Type.DOUBLE -> true
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
public val KtType.defaultInitializer: String?
|
||||
get() = withValidityAssertion {
|
||||
when {
|
||||
|
||||
Reference in New Issue
Block a user