Refactoring. Removed several usages of asSimpleType

This commit is contained in:
Stanislav Erokhin
2016-06-02 04:37:47 +03:00
parent 1d9ca06b96
commit f41c8dc045
12 changed files with 92 additions and 74 deletions
@@ -25,6 +25,7 @@ import org.jetbrains.kotlin.serialization.deserialization.findClassAcrossModuleD
import org.jetbrains.kotlin.storage.StorageManager
import org.jetbrains.kotlin.types.ErrorUtils
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.SimpleType
import java.util.*
class LazySyntheticElementResolveContext(private val module: ModuleDescriptor, storageManager: StorageManager) {
@@ -53,11 +54,11 @@ class LazySyntheticElementResolveContext(private val module: ModuleDescriptor, s
}
internal class SyntheticElementResolveContext(
val viewType: KotlinType,
val activityType: KotlinType,
val fragmentType: KotlinType?,
val supportActivityType: KotlinType?,
val supportFragmentType: KotlinType?) {
val viewType: SimpleType,
val activityType: SimpleType,
val fragmentType: SimpleType?,
val supportActivityType: SimpleType?,
val supportFragmentType: SimpleType?) {
companion object {
private fun errorType() = ErrorUtils.createErrorType("")
val ERROR_CONTEXT = SyntheticElementResolveContext(errorType(), errorType(), null, null, null)
@@ -71,12 +72,12 @@ internal class SyntheticElementResolveContext(
receivers
}
val fragmentTypes: List<Pair<KotlinType, KotlinType>> by lazy {
val fragmentTypes: List<Pair<SimpleType, SimpleType>> by lazy {
if (fragmentType == null) {
emptyList<Pair<KotlinType, KotlinType>>()
emptyList<Pair<SimpleType, SimpleType>>()
}
else {
val types = ArrayList<Pair<KotlinType, KotlinType>>(4)
val types = ArrayList<Pair<SimpleType, SimpleType>>(4)
types += Pair(activityType, fragmentType)
types += Pair(fragmentType, fragmentType)
if (supportActivityType != null && supportFragmentType != null) {
@@ -25,16 +25,14 @@ import org.jetbrains.kotlin.descriptors.annotations.Annotations
import org.jetbrains.kotlin.descriptors.impl.PropertyDescriptorImpl
import org.jetbrains.kotlin.descriptors.impl.PropertyGetterDescriptorImpl
import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl
import org.jetbrains.kotlin.load.java.lazy.types.LazyJavaTypeResolver
import org.jetbrains.kotlin.name.Name
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.asSimpleType
import org.jetbrains.kotlin.types.typeUtil.makeNullable
private class XmlSourceElement(override val psi: PsiElement) : PsiSourceElement
@@ -76,7 +74,7 @@ internal fun genPropertyForWidget(
internal fun genPropertyForFragment(
packageFragmentDescriptor: AndroidSyntheticPackageFragmentDescriptor,
receiverType: KotlinType,
type: KotlinType,
type: SimpleType,
fragment: AndroidResource.Fragment
): PropertyDescriptor {
val sourceElement = fragment.sourceElement?.let { XmlSourceElement(it) } ?: SourceElement.NO_SOURCE
@@ -86,7 +84,7 @@ internal fun genPropertyForFragment(
private fun genProperty(
id: ResourceIdentifier,
receiverType: KotlinType,
type: KotlinType,
type: SimpleType,
containingDeclaration: AndroidSyntheticPackageFragmentDescriptor,
sourceElement: SourceElement,
errorType: String?
@@ -110,7 +108,8 @@ private fun genProperty(
override val resourceId = id
}
val flexibleType = KotlinTypeFactory.flexibleType(type.asSimpleType(), type.makeNullable().asSimpleType())
// todo support (Mutable)List
val flexibleType = KotlinTypeFactory.flexibleType(type, type.makeNullableAsSpecified(true))
property.setType(
flexibleType,
emptyList<TypeParameterDescriptor>(),