Rename KotlinTypeFactory::simpleType to simpleTypeWithNonTrivialMemberScope
To state it must be used only for limited number of cases
This commit is contained in:
@@ -65,7 +65,7 @@ class TypeAliasExpander(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun TypeAliasExpansion.createAbbreviation(annotations: Annotations, isNullable: Boolean) =
|
private fun TypeAliasExpansion.createAbbreviation(annotations: Annotations, isNullable: Boolean) =
|
||||||
KotlinTypeFactory.simpleType(
|
KotlinTypeFactory.simpleTypeWithNonTrivialMemberScope(
|
||||||
annotations,
|
annotations,
|
||||||
descriptor.typeConstructor,
|
descriptor.typeConstructor,
|
||||||
arguments,
|
arguments,
|
||||||
|
|||||||
@@ -369,11 +369,11 @@ class TypeResolver(
|
|||||||
return if (scopeForTypeParameter is ErrorUtils.ErrorScope)
|
return if (scopeForTypeParameter is ErrorUtils.ErrorScope)
|
||||||
ErrorUtils.createErrorType("?")
|
ErrorUtils.createErrorType("?")
|
||||||
else
|
else
|
||||||
KotlinTypeFactory.simpleType(annotations,
|
KotlinTypeFactory.simpleTypeWithNonTrivialMemberScope(annotations,
|
||||||
typeParameter.typeConstructor,
|
typeParameter.typeConstructor,
|
||||||
listOf(),
|
listOf(),
|
||||||
false,
|
false,
|
||||||
scopeForTypeParameter)
|
scopeForTypeParameter)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getScopeForTypeParameter(c: TypeResolutionContext, typeParameterDescriptor: TypeParameterDescriptor): MemberScope {
|
private fun getScopeForTypeParameter(c: TypeResolutionContext, typeParameterDescriptor: TypeParameterDescriptor): MemberScope {
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ fun replaceReturnTypeForCallable(type: KotlinType, given: KotlinType): KotlinTyp
|
|||||||
fun replaceReturnTypeByUnknown(type: KotlinType) = replaceReturnTypeForCallable(type, DONT_CARE)
|
fun replaceReturnTypeByUnknown(type: KotlinType) = replaceReturnTypeForCallable(type, DONT_CARE)
|
||||||
|
|
||||||
private fun replaceTypeArguments(type: KotlinType, newArguments: List<TypeProjection>) =
|
private fun replaceTypeArguments(type: KotlinType, newArguments: List<TypeProjection>) =
|
||||||
KotlinTypeFactory.simpleType(type.annotations, type.constructor, newArguments, type.isMarkedNullable, type.memberScope)
|
KotlinTypeFactory.simpleTypeWithNonTrivialMemberScope(type.annotations, type.constructor, newArguments, type.isMarkedNullable, type.memberScope)
|
||||||
|
|
||||||
private fun getParameterArgumentsOfCallableType(type: KotlinType) =
|
private fun getParameterArgumentsOfCallableType(type: KotlinType) =
|
||||||
type.arguments.dropLast(1)
|
type.arguments.dropLast(1)
|
||||||
@@ -126,8 +126,8 @@ fun getErasedReceiverType(receiverParameterDescriptor: ReceiverParameterDescript
|
|||||||
receiverType.constructor
|
receiverType.constructor
|
||||||
}
|
}
|
||||||
|
|
||||||
return KotlinTypeFactory.simpleType(receiverType.annotations, receiverTypeConstructor, fakeTypeArguments,
|
return KotlinTypeFactory.simpleTypeWithNonTrivialMemberScope(receiverType.annotations, receiverTypeConstructor, fakeTypeArguments,
|
||||||
receiverType.isMarkedNullable, ErrorUtils.createErrorScope("Error scope for erased receiver type", /*throwExceptions=*/true))
|
receiverType.isMarkedNullable, ErrorUtils.createErrorScope("Error scope for erased receiver type", /*throwExceptions=*/true))
|
||||||
}
|
}
|
||||||
|
|
||||||
fun isOrOverridesSynthesized(descriptor: CallableMemberDescriptor): Boolean {
|
fun isOrOverridesSynthesized(descriptor: CallableMemberDescriptor): Boolean {
|
||||||
|
|||||||
@@ -234,7 +234,7 @@ public class CommonSupertypes {
|
|||||||
else {
|
else {
|
||||||
newScope = ErrorUtils.createErrorScope("A scope for common supertype which is not a normal classifier", true);
|
newScope = ErrorUtils.createErrorScope("A scope for common supertype which is not a normal classifier", true);
|
||||||
}
|
}
|
||||||
return KotlinTypeFactory.simpleType(Annotations.Companion.getEMPTY(), constructor, newProjections, nullable, newScope);
|
return KotlinTypeFactory.simpleTypeWithNonTrivialMemberScope(Annotations.Companion.getEMPTY(), constructor, newProjections, nullable, newScope);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ public class TypeIntersector {
|
|||||||
|
|
||||||
IntersectionTypeConstructor constructor = new IntersectionTypeConstructor(resultingTypes);
|
IntersectionTypeConstructor constructor = new IntersectionTypeConstructor(resultingTypes);
|
||||||
|
|
||||||
return KotlinTypeFactory.simpleType(
|
return KotlinTypeFactory.simpleTypeWithNonTrivialMemberScope(
|
||||||
Annotations.Companion.getEMPTY(),
|
Annotations.Companion.getEMPTY(),
|
||||||
constructor,
|
constructor,
|
||||||
Collections.emptyList(),
|
Collections.emptyList(),
|
||||||
|
|||||||
+2
-2
@@ -78,7 +78,7 @@ class JvmSharedVariablesManager(val builtIns: KotlinBuiltIns) : SharedVariablesM
|
|||||||
ClassConstructorDescriptorImpl.create(genericRefClass, Annotations.EMPTY, true, SourceElement.NO_SOURCE).apply {
|
ClassConstructorDescriptorImpl.create(genericRefClass, Annotations.EMPTY, true, SourceElement.NO_SOURCE).apply {
|
||||||
initialize(emptyList(), Visibilities.PUBLIC)
|
initialize(emptyList(), Visibilities.PUBLIC)
|
||||||
val typeParameter = typeParameters[0]
|
val typeParameter = typeParameters[0]
|
||||||
val typeParameterType = KotlinTypeFactory.simpleType(Annotations.EMPTY, typeParameter.typeConstructor, listOf(), false, MemberScope.Empty)
|
val typeParameterType = KotlinTypeFactory.simpleTypeWithNonTrivialMemberScope(Annotations.EMPTY, typeParameter.typeConstructor, listOf(), false, MemberScope.Empty)
|
||||||
returnType = KotlinTypeFactory.simpleNotNullType(Annotations.EMPTY, genericRefClass, listOf(TypeProjectionImpl(Variance.INVARIANT, typeParameterType)))
|
returnType = KotlinTypeFactory.simpleNotNullType(Annotations.EMPTY, genericRefClass, listOf(TypeProjectionImpl(Variance.INVARIANT, typeParameterType)))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,7 +182,7 @@ class JvmSharedVariablesManager(val builtIns: KotlinBuiltIns) : SharedVariablesM
|
|||||||
private fun getSharedVariableType(valueType: KotlinType): KotlinType =
|
private fun getSharedVariableType(valueType: KotlinType): KotlinType =
|
||||||
primitiveRefDescriptorProviders[getPrimitiveType(valueType)]?.refType ?:
|
primitiveRefDescriptorProviders[getPrimitiveType(valueType)]?.refType ?:
|
||||||
objectRefDescriptorsProvider.getRefType(valueType)
|
objectRefDescriptorsProvider.getRefType(valueType)
|
||||||
|
|
||||||
private fun getPrimitiveType(type: KotlinType): PrimitiveType? =
|
private fun getPrimitiveType(type: KotlinType): PrimitiveType? =
|
||||||
when {
|
when {
|
||||||
KotlinBuiltIns.isBoolean(type) -> PrimitiveType.BOOLEAN
|
KotlinBuiltIns.isBoolean(type) -> PrimitiveType.BOOLEAN
|
||||||
|
|||||||
+2
-2
@@ -46,7 +46,7 @@ sealed class NewTypeVariable(builtIns: KotlinBuiltIns, name: String) {
|
|||||||
|
|
||||||
// member scope is used if we have receiver with type TypeVariable(T)
|
// member scope is used if we have receiver with type TypeVariable(T)
|
||||||
// todo add to member scope methods from supertypes for type variable
|
// todo add to member scope methods from supertypes for type variable
|
||||||
val defaultType: SimpleType = KotlinTypeFactory.simpleType(
|
val defaultType: SimpleType = KotlinTypeFactory.simpleTypeWithNonTrivialMemberScope(
|
||||||
Annotations.EMPTY, freshTypeConstructor, arguments = emptyList(),
|
Annotations.EMPTY, freshTypeConstructor, arguments = emptyList(),
|
||||||
nullable = false, memberScope = builtIns.any.unsubstitutedMemberScope)
|
nullable = false, memberScope = builtIns.any.unsubstitutedMemberScope)
|
||||||
|
|
||||||
@@ -61,4 +61,4 @@ class TypeVariableForLambdaReturnType(
|
|||||||
val lambdaArgument: LambdaKotlinCallArgument,
|
val lambdaArgument: LambdaKotlinCallArgument,
|
||||||
builtIns: KotlinBuiltIns,
|
builtIns: KotlinBuiltIns,
|
||||||
name: String
|
name: String
|
||||||
) : NewTypeVariable(builtIns, name)
|
) : NewTypeVariable(builtIns, name)
|
||||||
|
|||||||
+2
-2
@@ -64,8 +64,8 @@ class ConstraintSystemTestData(
|
|||||||
val matcher = INTEGER_VALUE_TYPE_PATTERN.matcher(name)
|
val matcher = INTEGER_VALUE_TYPE_PATTERN.matcher(name)
|
||||||
if (matcher.find()) {
|
if (matcher.find()) {
|
||||||
val number = matcher.group(1)!!
|
val number = matcher.group(1)!!
|
||||||
return KotlinTypeFactory.simpleType(Annotations.EMPTY, IntegerValueTypeConstructor(number.toLong(), functionFoo.builtIns),
|
return KotlinTypeFactory.simpleTypeWithNonTrivialMemberScope(Annotations.EMPTY, IntegerValueTypeConstructor(number.toLong(), functionFoo.builtIns),
|
||||||
listOf(), false, MemberScope.Empty
|
listOf(), false, MemberScope.Empty
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
return typeResolver.resolveType(
|
return typeResolver.resolveType(
|
||||||
|
|||||||
+1
-1
@@ -125,7 +125,7 @@ internal object RawSubstitution : TypeSubstitution() {
|
|||||||
|
|
||||||
if (type.isError) return ErrorUtils.createErrorType("Raw error type: ${type.constructor}") to false
|
if (type.isError) return ErrorUtils.createErrorType("Raw error type: ${type.constructor}") to false
|
||||||
|
|
||||||
return KotlinTypeFactory.simpleType(
|
return KotlinTypeFactory.simpleTypeWithNonTrivialMemberScope(
|
||||||
type.annotations, type.constructor,
|
type.annotations, type.constructor,
|
||||||
type.constructor.parameters.map {
|
type.constructor.parameters.map {
|
||||||
parameter ->
|
parameter ->
|
||||||
|
|||||||
+1
-1
@@ -68,7 +68,7 @@ public abstract class AbstractTypeParameterDescriptor extends DeclarationDescrip
|
|||||||
this.defaultType = storageManager.createLazyValue(new Function0<SimpleType>() {
|
this.defaultType = storageManager.createLazyValue(new Function0<SimpleType>() {
|
||||||
@Override
|
@Override
|
||||||
public SimpleType invoke() {
|
public SimpleType invoke() {
|
||||||
return KotlinTypeFactory.simpleType(
|
return KotlinTypeFactory.simpleTypeWithNonTrivialMemberScope(
|
||||||
Annotations.Companion.getEMPTY(),
|
Annotations.Companion.getEMPTY(),
|
||||||
getTypeConstructor(), Collections.<TypeProjection>emptyList(), false,
|
getTypeConstructor(), Collections.<TypeProjection>emptyList(), false,
|
||||||
new LazyScopeAdapter(storageManager.createLazyValue(
|
new LazyScopeAdapter(storageManager.createLazyValue(
|
||||||
|
|||||||
@@ -99,8 +99,8 @@ class IntegerValueTypeConstant(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val unknownIntegerType = KotlinTypeFactory.simpleType(Annotations.EMPTY, typeConstructor, emptyList<TypeProjection>(),
|
val unknownIntegerType = KotlinTypeFactory.simpleTypeWithNonTrivialMemberScope(Annotations.EMPTY, typeConstructor, emptyList<TypeProjection>(),
|
||||||
false, ErrorUtils.createErrorScope("Scope for number value type (" + typeConstructor.toString() + ")", true)
|
false, ErrorUtils.createErrorScope("Scope for number value type (" + typeConstructor.toString() + ")", true)
|
||||||
)
|
)
|
||||||
|
|
||||||
fun getType(expectedType: KotlinType): KotlinType = TypeUtils.getPrimitiveNumberType(typeConstructor, expectedType)
|
fun getType(expectedType: KotlinType): KotlinType = TypeUtils.getPrimitiveNumberType(typeConstructor, expectedType)
|
||||||
|
|||||||
@@ -50,11 +50,11 @@ object KotlinTypeFactory {
|
|||||||
return constructor.declarationDescriptor!!.defaultType
|
return constructor.declarationDescriptor!!.defaultType
|
||||||
}
|
}
|
||||||
|
|
||||||
return simpleType(annotations, constructor, arguments, nullable, computeMemberScope(constructor, arguments))
|
return simpleTypeWithNonTrivialMemberScope(annotations, constructor, arguments, nullable, computeMemberScope(constructor, arguments))
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun simpleType(
|
fun simpleTypeWithNonTrivialMemberScope(
|
||||||
annotations: Annotations,
|
annotations: Annotations,
|
||||||
constructor: TypeConstructor,
|
constructor: TypeConstructor,
|
||||||
arguments: List<TypeProjection>,
|
arguments: List<TypeProjection>,
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ fun SimpleType.replace(
|
|||||||
if (newArguments.isEmpty() && newAnnotations === annotations) return this
|
if (newArguments.isEmpty() && newAnnotations === annotations) return this
|
||||||
|
|
||||||
if (newArguments.isEmpty()) {
|
if (newArguments.isEmpty()) {
|
||||||
return KotlinTypeFactory.simpleType(
|
return KotlinTypeFactory.simpleTypeWithNonTrivialMemberScope(
|
||||||
newAnnotations,
|
newAnnotations,
|
||||||
constructor,
|
constructor,
|
||||||
arguments,
|
arguments,
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ public class TypeUtils {
|
|||||||
}
|
}
|
||||||
TypeConstructor typeConstructor = classifierDescriptor.getTypeConstructor();
|
TypeConstructor typeConstructor = classifierDescriptor.getTypeConstructor();
|
||||||
List<TypeProjection> arguments = getDefaultTypeProjections(typeConstructor.getParameters());
|
List<TypeProjection> arguments = getDefaultTypeProjections(typeConstructor.getParameters());
|
||||||
return KotlinTypeFactory.simpleType(
|
return KotlinTypeFactory.simpleTypeWithNonTrivialMemberScope(
|
||||||
Annotations.Companion.getEMPTY(),
|
Annotations.Companion.getEMPTY(),
|
||||||
typeConstructor,
|
typeConstructor,
|
||||||
arguments,
|
arguments,
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ object TypeIntersector {
|
|||||||
if (filteredSuperAndEqualTypes.size < 2) return filteredSuperAndEqualTypes.single()
|
if (filteredSuperAndEqualTypes.size < 2) return filteredSuperAndEqualTypes.single()
|
||||||
|
|
||||||
val constructor = IntersectionTypeConstructor(inputTypes)
|
val constructor = IntersectionTypeConstructor(inputTypes)
|
||||||
return KotlinTypeFactory.simpleType(Annotations.EMPTY, constructor, listOf(), false, constructor.createScopeForKotlinType())
|
return KotlinTypeFactory.simpleTypeWithNonTrivialMemberScope(Annotations.EMPTY, constructor, listOf(), false, constructor.createScopeForKotlinType())
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun isStrictSupertype(subtype: KotlinType, supertype: KotlinType): Boolean {
|
private fun isStrictSupertype(subtype: KotlinType, supertype: KotlinType): Boolean {
|
||||||
@@ -165,4 +165,4 @@ object TypeIntersector {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -142,13 +142,13 @@ object NewKotlinTypeChecker : KotlinTypeChecker {
|
|||||||
|
|
||||||
is IntegerValueTypeConstructor -> {
|
is IntegerValueTypeConstructor -> {
|
||||||
val newConstructor = IntersectionTypeConstructor(constructor.supertypes.map { TypeUtils.makeNullableAsSpecified(it, type.isMarkedNullable) })
|
val newConstructor = IntersectionTypeConstructor(constructor.supertypes.map { TypeUtils.makeNullableAsSpecified(it, type.isMarkedNullable) })
|
||||||
return KotlinTypeFactory.simpleType(type.annotations, newConstructor, listOf(), false, type.memberScope)
|
return KotlinTypeFactory.simpleTypeWithNonTrivialMemberScope(type.annotations, newConstructor, listOf(), false, type.memberScope)
|
||||||
}
|
}
|
||||||
|
|
||||||
is IntersectionTypeConstructor -> if (type.isMarkedNullable) {
|
is IntersectionTypeConstructor -> if (type.isMarkedNullable) {
|
||||||
val newSuperTypes = constructor.supertypes.map { it.makeNullable() }
|
val newSuperTypes = constructor.supertypes.map { it.makeNullable() }
|
||||||
val newConstructor = IntersectionTypeConstructor(newSuperTypes)
|
val newConstructor = IntersectionTypeConstructor(newSuperTypes)
|
||||||
return KotlinTypeFactory.simpleType(type.annotations, newConstructor, listOf(), false, newConstructor.createScopeForKotlinType())
|
return KotlinTypeFactory.simpleTypeWithNonTrivialMemberScope(type.annotations, newConstructor, listOf(), false, newConstructor.createScopeForKotlinType())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -76,11 +76,11 @@ private fun KotlinType.approximateNonDynamicFlexibleTypes(
|
|||||||
(unwrap() as? AbbreviatedType)?.let {
|
(unwrap() as? AbbreviatedType)?.let {
|
||||||
return AbbreviatedType(it.expandedType, it.abbreviation.approximateNonDynamicFlexibleTypes(preferNotNull))
|
return AbbreviatedType(it.expandedType, it.abbreviation.approximateNonDynamicFlexibleTypes(preferNotNull))
|
||||||
}
|
}
|
||||||
return KotlinTypeFactory.simpleType(annotations,
|
return KotlinTypeFactory.simpleTypeWithNonTrivialMemberScope(annotations,
|
||||||
constructor,
|
constructor,
|
||||||
arguments.map { it.substitute { type -> type.approximateFlexibleTypes(preferNotNull = true) } },
|
arguments.map { it.substitute { type -> type.approximateFlexibleTypes(preferNotNull = true) } },
|
||||||
isMarkedNullable,
|
isMarkedNullable,
|
||||||
ErrorUtils.createErrorScope("This type is not supposed to be used in member resolution", true)
|
ErrorUtils.createErrorScope("This type is not supposed to be used in member resolution", true)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,4 +155,4 @@ fun KotlinType.getResolvableApproximations(
|
|||||||
fun KotlinType.isAbstract(): Boolean {
|
fun KotlinType.isAbstract(): Boolean {
|
||||||
val modality = (constructor.declarationDescriptor as? ClassDescriptor)?.modality
|
val modality = (constructor.declarationDescriptor as? ClassDescriptor)?.modality
|
||||||
return modality == Modality.ABSTRACT || modality == Modality.SEALED
|
return modality == Modality.ABSTRACT || modality == Modality.SEALED
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -286,7 +286,7 @@ internal fun KotlinType.substitute(substitution: KotlinTypeSubstitution, varianc
|
|||||||
val (projection, typeParameter) = pair
|
val (projection, typeParameter) = pair
|
||||||
TypeProjectionImpl(Variance.INVARIANT, projection.type.substitute(substitution, typeParameter.variance))
|
TypeProjectionImpl(Variance.INVARIANT, projection.type.substitute(substitution, typeParameter.variance))
|
||||||
}
|
}
|
||||||
KotlinTypeFactory.simpleType(annotations, constructor, newArguments, isMarkedNullable, memberScope)
|
KotlinTypeFactory.simpleTypeWithNonTrivialMemberScope(annotations, constructor, newArguments, isMarkedNullable, memberScope)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -51,7 +51,7 @@ object CreateIteratorFunctionActionFactory : CreateCallableMemberFromUsageFactor
|
|||||||
|
|
||||||
val returnJetTypeParameterType = TypeProjectionImpl(returnJetTypeParameterTypes[0])
|
val returnJetTypeParameterType = TypeProjectionImpl(returnJetTypeParameterTypes[0])
|
||||||
val returnJetTypeArguments = Collections.singletonList(returnJetTypeParameterType)
|
val returnJetTypeArguments = Collections.singletonList(returnJetTypeParameterType)
|
||||||
val newReturnJetType = KotlinTypeFactory.simpleType(returnJetType.annotations,
|
val newReturnJetType = KotlinTypeFactory.simpleTypeWithNonTrivialMemberScope(returnJetType.annotations,
|
||||||
returnJetType.constructor,
|
returnJetType.constructor,
|
||||||
returnJetTypeArguments,
|
returnJetTypeArguments,
|
||||||
returnJetType.isMarkedNullable,
|
returnJetType.isMarkedNullable,
|
||||||
|
|||||||
+2
-2
@@ -101,7 +101,7 @@ private object ForceTypeCopySubstitution : TypeSubstitution() {
|
|||||||
override fun get(key: KotlinType) =
|
override fun get(key: KotlinType) =
|
||||||
with(key) {
|
with(key) {
|
||||||
if (isError) return@with asTypeProjection()
|
if (isError) return@with asTypeProjection()
|
||||||
KotlinTypeFactory.simpleType(annotations, constructor, arguments, isMarkedNullable, memberScope).asTypeProjection()
|
KotlinTypeFactory.simpleTypeWithNonTrivialMemberScope(annotations, constructor, arguments, isMarkedNullable, memberScope).asTypeProjection()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun isEmpty() = false
|
override fun isEmpty() = false
|
||||||
@@ -118,4 +118,4 @@ fun suggestReceiverNames(project: Project, descriptor: CallableDescriptor): List
|
|||||||
} ?: CollectingNameValidator(paramNames)
|
} ?: CollectingNameValidator(paramNames)
|
||||||
val receiverType = descriptor.extensionReceiverParameter?.type ?: return emptyList()
|
val receiverType = descriptor.extensionReceiverParameter?.type ?: return emptyList()
|
||||||
return KotlinNameSuggester.suggestNamesByType(receiverType, validator, "receiver")
|
return KotlinNameSuggester.suggestNamesByType(receiverType, validator, "receiver")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user