Refactoring. Move flexible type creation to KotlinTypeFactory.

This commit is contained in:
Stanislav Erokhin
2016-05-25 13:15:13 +03:00
parent 3a451744c5
commit 957bae18be
22 changed files with 168 additions and 149 deletions
@@ -16,12 +16,11 @@
package org.jetbrains.kotlin.load.java
import org.jetbrains.kotlin.load.java.lazy.types.LazyJavaTypeResolver.FlexibleJavaClassifierTypeFactory
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.TypeResolver.TypeTransformerForTests
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.*
object InternalFlexibleTypeTransformer : TypeTransformerForTests() {
// This is a "magic" classifier: when type resolver sees it in the code, e.g. ft<Foo, Foo?>, instead of creating a normal type,
@@ -35,7 +34,7 @@ object InternalFlexibleTypeTransformer : TypeTransformerForTests() {
val descriptor = kotlinType.constructor.declarationDescriptor
if (descriptor != null && FLEXIBLE_TYPE_CLASSIFIER.asSingleFqName().toUnsafe() == DescriptorUtils.getFqName(descriptor)
&& kotlinType.arguments.size == 2) {
return FlexibleJavaClassifierTypeFactory.create(kotlinType.arguments[0].type, kotlinType.arguments[1].type)
return KotlinTypeFactory.flexibleType(kotlinType.arguments[0].type.asSimpleType(), kotlinType.arguments[1].type.asSimpleType())
}
return null
}
@@ -72,7 +72,8 @@ public class SingleAbstractMethodUtils {
"' should not end with conflict";
if (FlexibleTypesKt.isNullabilityFlexible(samType)) {
return LazyJavaTypeResolver.FlexibleJavaClassifierTypeFactory.INSTANCE.create(type, TypeUtils.makeNullable(type));
SimpleType simpleType = KotlinTypeKt.asSimpleType(type);
return KotlinTypeFactory.flexibleType(simpleType, TypeUtils.makeNullable(simpleType));
}
return TypeUtils.makeNullableAsSpecified(type, samType.isMarkedNullable());