Fixes and refactors
This commit is contained in:
committed by
Dmitriy Novozhilov
parent
2e2e70fede
commit
19bfc43bee
+2
-5
@@ -30,10 +30,7 @@ import org.jetbrains.kotlin.resolve.DescriptorFactory
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameUnsafe
|
||||
import org.jetbrains.kotlin.resolve.source.PsiSourceElement
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.KotlinTypeFactory
|
||||
import org.jetbrains.kotlin.types.SimpleType
|
||||
import org.jetbrains.kotlin.types.StarProjectionImpl
|
||||
import org.jetbrains.kotlin.types.*
|
||||
|
||||
private class XmlSourceElement(override val psi: PsiElement) : PsiSourceElement
|
||||
|
||||
@@ -70,7 +67,7 @@ internal fun genPropertyForWidget(
|
||||
}
|
||||
else {
|
||||
KotlinTypeFactory.simpleNotNullType(
|
||||
Annotations.EMPTY, classDescriptor, defaultType.constructor.parameters.map(::StarProjectionImpl))
|
||||
TypeAttributes.Empty, classDescriptor, defaultType.constructor.parameters.map(::StarProjectionImpl))
|
||||
}
|
||||
} ?: context.view
|
||||
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@ internal fun ClassDescriptor.createSerializerTypeFor(argument: SimpleType, baseS
|
||||
val types = listOf(TypeProjectionImpl(projectionType, argument))
|
||||
val descriptor = module.findClassAcrossModuleDependencies(ClassId.topLevel(baseSerializerInterface))
|
||||
?: throw IllegalArgumentException("Can't locate $baseSerializerInterface. Is kotlinx-serialization library present in compile classpath?")
|
||||
return KotlinTypeFactory.simpleNotNullType(Annotations.EMPTY, descriptor, types)
|
||||
return KotlinTypeFactory.simpleNotNullType(TypeAttributes.Empty, descriptor, types)
|
||||
}
|
||||
|
||||
internal fun extractKSerializerArgumentFromImplementation(implementationClass: ClassDescriptor): KotlinType? {
|
||||
|
||||
+8
-8
@@ -58,7 +58,7 @@ object KSerializerDescriptorResolver {
|
||||
if (!classDescriptor.needSerializerFactory()) return
|
||||
val serializerFactoryClass =
|
||||
classDescriptor.module.getClassFromInternalSerializationPackage("SerializerFactory")
|
||||
supertypes.add(KotlinTypeFactory.simpleNotNullType(Annotations.EMPTY, serializerFactoryClass, listOf()))
|
||||
supertypes.add(KotlinTypeFactory.simpleNotNullType(TypeAttributes.Empty, serializerFactoryClass, listOf()))
|
||||
}
|
||||
|
||||
fun addSerializerSupertypes(classDescriptor: ClassDescriptor, supertypes: MutableList<KotlinType>) {
|
||||
@@ -393,7 +393,7 @@ object KSerializerDescriptorResolver {
|
||||
assert(serializableDescriptor.declaredTypeParameters.size == typeParameters.size)
|
||||
val args = List(serializableDescriptor.declaredTypeParameters.size) { index ->
|
||||
val pType = KotlinTypeFactory.simpleNotNullType(
|
||||
Annotations.EMPTY,
|
||||
TypeAttributes.Empty,
|
||||
serializerClass,
|
||||
listOf(TypeProjectionImpl(typeParameters[index].defaultType))
|
||||
)
|
||||
@@ -430,7 +430,7 @@ object KSerializerDescriptorResolver {
|
||||
)
|
||||
|
||||
val pType =
|
||||
KotlinTypeFactory.simpleNotNullType(Annotations.EMPTY, serializerClass, listOf(TypeProjectionImpl(targ.defaultType)))
|
||||
KotlinTypeFactory.simpleNotNullType(TypeAttributes.Empty, serializerClass, listOf(TypeProjectionImpl(targ.defaultType)))
|
||||
|
||||
args.add(
|
||||
ValueParameterDescriptorImpl(
|
||||
@@ -467,7 +467,7 @@ object KSerializerDescriptorResolver {
|
||||
|
||||
val kSerializerStarType =
|
||||
KotlinTypeFactory.simpleNotNullType(
|
||||
Annotations.EMPTY,
|
||||
TypeAttributes.Empty,
|
||||
serializerClass,
|
||||
listOf(StarProjectionImpl(serializerClass.typeConstructor.parameters.first()))
|
||||
)
|
||||
@@ -517,9 +517,9 @@ object KSerializerDescriptorResolver {
|
||||
val (typeArgs, args) = createKSerializerParamsForEachGenericArgument(f, serializableClass)
|
||||
|
||||
val newSerializableType =
|
||||
KotlinTypeFactory.simpleNotNullType(Annotations.EMPTY, serializableClass, typeArgs.map { TypeProjectionImpl(it.defaultType) })
|
||||
KotlinTypeFactory.simpleNotNullType(TypeAttributes.Empty, serializableClass, typeArgs.map { TypeProjectionImpl(it.defaultType) })
|
||||
val serialReturnType =
|
||||
KotlinTypeFactory.simpleNotNullType(Annotations.EMPTY, serializerClass, listOf(TypeProjectionImpl(newSerializableType)))
|
||||
KotlinTypeFactory.simpleNotNullType(TypeAttributes.Empty, serializerClass, listOf(TypeProjectionImpl(newSerializableType)))
|
||||
|
||||
f.initialize(null, thisClass.thisAsReceiverParameter, emptyList(), typeArgs, args, serialReturnType, Modality.FINAL, DescriptorVisibilities.PUBLIC)
|
||||
return f
|
||||
@@ -550,7 +550,7 @@ object KSerializerDescriptorResolver {
|
||||
|
||||
// object
|
||||
val objectType =
|
||||
KotlinTypeFactory.simpleNotNullType(Annotations.EMPTY, thisClass, typeArgs.map { TypeProjectionImpl(it.defaultType) })
|
||||
KotlinTypeFactory.simpleNotNullType(TypeAttributes.Empty, thisClass, typeArgs.map { TypeProjectionImpl(it.defaultType) })
|
||||
args.add(
|
||||
ValueParameterDescriptorImpl(
|
||||
containingDeclaration = f,
|
||||
@@ -646,7 +646,7 @@ object KSerializerDescriptorResolver {
|
||||
val param = serializerDescriptor.declaredTypeParameters[index]
|
||||
val pType =
|
||||
KotlinTypeFactory.simpleNotNullType(
|
||||
Annotations.EMPTY,
|
||||
TypeAttributes.Empty,
|
||||
serializerClass,
|
||||
listOf(TypeProjectionImpl(param.defaultType))
|
||||
)
|
||||
|
||||
+2
-1
@@ -18,6 +18,7 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.module
|
||||
import org.jetbrains.kotlin.resolve.lazy.descriptors.LazyAnnotationDescriptor
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.KotlinTypeFactory
|
||||
import org.jetbrains.kotlin.types.TypeAttributes
|
||||
|
||||
internal fun ClassConstructorDescriptor.isSerializationCtor(): Boolean {
|
||||
/*kind == CallableMemberDescriptor.Kind.SYNTHESIZED does not work because DeserializedClassConstructorDescriptor loses its kind*/
|
||||
@@ -117,7 +118,7 @@ internal fun ClassDescriptor.getClassFromInternalSerializationPackage(classSimpl
|
||||
module.getClassFromInternalSerializationPackage(classSimpleName)
|
||||
|
||||
fun ClassDescriptor.toSimpleType(nullable: Boolean = false) =
|
||||
KotlinTypeFactory.simpleType(Annotations.EMPTY, this.typeConstructor, emptyList(), nullable)
|
||||
KotlinTypeFactory.simpleType(TypeAttributes.Empty, this.typeConstructor, emptyList(), nullable)
|
||||
|
||||
internal fun Annotated.annotationsWithArguments(): List<Triple<ClassDescriptor, List<ValueArgument>, List<ValueParameterDescriptor>>> =
|
||||
annotations.asSequence()
|
||||
|
||||
+1
-1
@@ -69,7 +69,7 @@ private fun KotlinType.approximateNonDynamicFlexibleTypes(
|
||||
return AbbreviatedType(it.expandedType, it.abbreviation.approximateNonDynamicFlexibleTypes(preferNotNull))
|
||||
}
|
||||
return KotlinTypeFactory.simpleTypeWithNonTrivialMemberScope(
|
||||
annotations,
|
||||
attributes,
|
||||
constructor,
|
||||
arguments.map { it.substitute { type -> type.approximateFlexibleTypes(preferNotNull = true) } },
|
||||
isMarkedNullable,
|
||||
|
||||
Reference in New Issue
Block a user