Minor. Removed TypeParameterDescriptor#getLowerBounds
This commit is contained in:
@@ -321,7 +321,7 @@ class TypeResolver(
|
|||||||
KotlinTypeImpl.create(
|
KotlinTypeImpl.create(
|
||||||
annotations,
|
annotations,
|
||||||
typeParameter.typeConstructor,
|
typeParameter.typeConstructor,
|
||||||
TypeUtils.hasNullableLowerBound(typeParameter),
|
false,
|
||||||
listOf(),
|
listOf(),
|
||||||
scopeForTypeParameter)
|
scopeForTypeParameter)
|
||||||
}
|
}
|
||||||
|
|||||||
-1
@@ -562,7 +562,6 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
|||||||
getTypeConstructor().getSupertypes();
|
getTypeConstructor().getSupertypes();
|
||||||
for (TypeParameterDescriptor typeParameterDescriptor : getTypeConstructor().getParameters()) {
|
for (TypeParameterDescriptor typeParameterDescriptor : getTypeConstructor().getParameters()) {
|
||||||
typeParameterDescriptor.getUpperBounds();
|
typeParameterDescriptor.getUpperBounds();
|
||||||
typeParameterDescriptor.getLowerBounds();
|
|
||||||
}
|
}
|
||||||
getUnsubstitutedPrimaryConstructor();
|
getUnsubstitutedPrimaryConstructor();
|
||||||
getVisibility();
|
getVisibility();
|
||||||
|
|||||||
-1
@@ -143,7 +143,6 @@ public class LazyTypeParameterDescriptor extends AbstractLazyTypeParameterDescri
|
|||||||
getContainingDeclaration();
|
getContainingDeclaration();
|
||||||
getDefaultType();
|
getDefaultType();
|
||||||
getIndex();
|
getIndex();
|
||||||
ForceResolveUtil.forceResolveAllContents(getLowerBounds());
|
|
||||||
getOriginal();
|
getOriginal();
|
||||||
ForceResolveUtil.forceResolveAllContents(getTypeConstructor());
|
ForceResolveUtil.forceResolveAllContents(getTypeConstructor());
|
||||||
ForceResolveUtil.forceResolveAllContents(getUpperBounds());
|
ForceResolveUtil.forceResolveAllContents(getUpperBounds());
|
||||||
|
|||||||
+2
-1
@@ -22,6 +22,7 @@ import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
|||||||
import org.jetbrains.kotlin.load.java.components.TypeUsage
|
import org.jetbrains.kotlin.load.java.components.TypeUsage
|
||||||
import org.jetbrains.kotlin.renderer.CustomFlexibleRendering
|
import org.jetbrains.kotlin.renderer.CustomFlexibleRendering
|
||||||
import org.jetbrains.kotlin.renderer.DescriptorRenderer
|
import org.jetbrains.kotlin.renderer.DescriptorRenderer
|
||||||
|
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
|
||||||
import org.jetbrains.kotlin.types.*
|
import org.jetbrains.kotlin.types.*
|
||||||
|
|
||||||
object RawTypeTag : TypeCapability
|
object RawTypeTag : TypeCapability
|
||||||
@@ -150,7 +151,7 @@ internal object RawSubstitution : TypeSubstitution() {
|
|||||||
JavaTypeFlexibility.FLEXIBLE_UPPER_BOUND, JavaTypeFlexibility.INFLEXIBLE -> {
|
JavaTypeFlexibility.FLEXIBLE_UPPER_BOUND, JavaTypeFlexibility.INFLEXIBLE -> {
|
||||||
if (!parameter.variance.allowsOutPosition)
|
if (!parameter.variance.allowsOutPosition)
|
||||||
// in T -> Comparable<Nothing>
|
// in T -> Comparable<Nothing>
|
||||||
TypeProjectionImpl(Variance.INVARIANT, parameter.lowerBounds.first())
|
TypeProjectionImpl(Variance.INVARIANT, parameter.builtIns.nothingType)
|
||||||
else if (erasedUpperBound.constructor.parameters.isNotEmpty())
|
else if (erasedUpperBound.constructor.parameters.isNotEmpty())
|
||||||
// T : Enum<E> -> out Enum<*>
|
// T : Enum<E> -> out Enum<*>
|
||||||
TypeProjectionImpl(Variance.OUT_VARIANCE, erasedUpperBound)
|
TypeProjectionImpl(Variance.OUT_VARIANCE, erasedUpperBound)
|
||||||
|
|||||||
@@ -33,9 +33,6 @@ public interface TypeParameterDescriptor extends ClassifierDescriptor {
|
|||||||
@NotNull
|
@NotNull
|
||||||
List<KotlinType> getUpperBounds();
|
List<KotlinType> getUpperBounds();
|
||||||
|
|
||||||
@NotNull
|
|
||||||
List<KotlinType> getLowerBounds();
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
TypeConstructor getTypeConstructor();
|
TypeConstructor getTypeConstructor();
|
||||||
|
|||||||
-6
@@ -181,12 +181,6 @@ public abstract class AbstractTypeParameterDescriptor extends DeclarationDescrip
|
|||||||
return defaultType.invoke();
|
return defaultType.invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
public List<KotlinType> getLowerBounds() {
|
|
||||||
return Collections.singletonList(getBuiltIns(this).getNothingType());
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
|||||||
@@ -304,15 +304,6 @@ public class TypeUtils {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hasNullableLowerBound(@NotNull TypeParameterDescriptor typeParameterDescriptor) {
|
|
||||||
for (KotlinType bound : typeParameterDescriptor.getLowerBounds()) {
|
|
||||||
if (bound.isMarkedNullable()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A work-around of the generic nullability problem in the type checker
|
* A work-around of the generic nullability problem in the type checker
|
||||||
* Semantics should be the same as `!isSubtype(T, Any)`
|
* Semantics should be the same as `!isSubtype(T, Any)`
|
||||||
@@ -343,8 +334,7 @@ public class TypeUtils {
|
|||||||
if (FlexibleTypesKt.isFlexible(type) && acceptsNullable(FlexibleTypesKt.flexibility(type).getUpperBound())) {
|
if (FlexibleTypesKt.isFlexible(type) && acceptsNullable(FlexibleTypesKt.flexibility(type).getUpperBound())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
TypeParameterDescriptor typeParameterDescriptor = getTypeParameterDescriptorOrNull(type);
|
return false;
|
||||||
return typeParameterDescriptor != null && hasNullableLowerBound(typeParameterDescriptor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hasNullableSuperType(@NotNull KotlinType type) {
|
public static boolean hasNullableSuperType(@NotNull KotlinType type) {
|
||||||
|
|||||||
@@ -72,7 +72,6 @@ class FuzzyType(
|
|||||||
private fun MutableSet<TypeParameterDescriptor>.addUsedTypeParameters(type: KotlinType) {
|
private fun MutableSet<TypeParameterDescriptor>.addUsedTypeParameters(type: KotlinType) {
|
||||||
val typeParameter = type.constructor.declarationDescriptor as? TypeParameterDescriptor
|
val typeParameter = type.constructor.declarationDescriptor as? TypeParameterDescriptor
|
||||||
if (typeParameter != null && add(typeParameter)) {
|
if (typeParameter != null && add(typeParameter)) {
|
||||||
typeParameter.lowerBounds.forEach { addUsedTypeParameters(it) }
|
|
||||||
typeParameter.upperBounds.forEach { addUsedTypeParameters(it) }
|
typeParameter.upperBounds.forEach { addUsedTypeParameters(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
-1
@@ -621,7 +621,6 @@ class KotlinPsiUnifier(
|
|||||||
desc2: TypeParameterDescriptor
|
desc2: TypeParameterDescriptor
|
||||||
): Status {
|
): Status {
|
||||||
if (desc1.variance != desc2.variance) return UNMATCHED
|
if (desc1.variance != desc2.variance) return UNMATCHED
|
||||||
if (!matchTypes(desc1.lowerBounds, desc2.lowerBounds)) return UNMATCHED
|
|
||||||
if (!matchTypes(desc1.upperBounds, desc2.upperBounds)) return UNMATCHED
|
if (!matchTypes(desc1.upperBounds, desc2.upperBounds)) return UNMATCHED
|
||||||
return MATCHED
|
return MATCHED
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user