Remove some unjustified usages of TypeParameterDescriptor#getUpperBoundsAsType
This commit is contained in:
+1
-1
@@ -34,7 +34,7 @@ import org.jetbrains.kotlin.psi.stubs.KotlinFileStub;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class KtFileElementType extends IStubFileElementType<KotlinFileStub> {
|
public class KtFileElementType extends IStubFileElementType<KotlinFileStub> {
|
||||||
public static final int STUB_VERSION = 62;
|
public static final int STUB_VERSION = 63;
|
||||||
|
|
||||||
private static final String NAME = "kotlin.FILE";
|
private static final String NAME = "kotlin.FILE";
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -14,8 +14,8 @@ public interface I2 : I1 {
|
|||||||
|
|
||||||
public interface Test1 {
|
public interface Test1 {
|
||||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
public abstract fun </*0*/ T : kotlin.Cloneable> foo(/*0*/ t: T): kotlin.Unit where T : java.io.Serializable
|
|
||||||
public abstract fun </*0*/ T : java.io.Serializable> foo(/*0*/ t: T): kotlin.Unit where T : kotlin.Cloneable
|
public abstract fun </*0*/ T : java.io.Serializable> foo(/*0*/ t: T): kotlin.Unit where T : kotlin.Cloneable
|
||||||
|
public abstract fun </*0*/ T : kotlin.Cloneable> foo(/*0*/ t: T): kotlin.Unit where T : java.io.Serializable
|
||||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -9,8 +9,8 @@ public interface A {
|
|||||||
|
|
||||||
public interface B : A {
|
public interface B : A {
|
||||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
public abstract fun </*0*/ T> foo(): kotlin.Unit where T : kotlin.Cloneable
|
|
||||||
public abstract override /*1*/ /*fake_override*/ fun </*0*/ T : kotlin.Any> foo(): kotlin.Unit where T : kotlin.Cloneable?
|
public abstract override /*1*/ /*fake_override*/ fun </*0*/ T : kotlin.Any> foo(): kotlin.Unit where T : kotlin.Cloneable?
|
||||||
|
public abstract fun </*0*/ T> foo(): kotlin.Unit where T : kotlin.Cloneable
|
||||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-2
@@ -25,6 +25,7 @@ import org.jetbrains.kotlin.descriptors.SourceElement;
|
|||||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor;
|
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor;
|
||||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
||||||
import org.jetbrains.kotlin.name.Name;
|
import org.jetbrains.kotlin.name.Name;
|
||||||
|
import org.jetbrains.kotlin.resolve.scopes.ChainedScope;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.KtScope;
|
import org.jetbrains.kotlin.resolve.scopes.KtScope;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.LazyScopeAdapter;
|
import org.jetbrains.kotlin.resolve.scopes.LazyScopeAdapter;
|
||||||
import org.jetbrains.kotlin.storage.NotNullLazyValue;
|
import org.jetbrains.kotlin.storage.NotNullLazyValue;
|
||||||
@@ -32,6 +33,7 @@ import org.jetbrains.kotlin.storage.StorageManager;
|
|||||||
import org.jetbrains.kotlin.types.*;
|
import org.jetbrains.kotlin.types.*;
|
||||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
|
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -54,7 +56,7 @@ public abstract class AbstractTypeParameterDescriptor extends DeclarationDescrip
|
|||||||
@NotNull final StorageManager storageManager,
|
@NotNull final StorageManager storageManager,
|
||||||
@NotNull DeclarationDescriptor containingDeclaration,
|
@NotNull DeclarationDescriptor containingDeclaration,
|
||||||
@NotNull Annotations annotations,
|
@NotNull Annotations annotations,
|
||||||
@NotNull Name name,
|
@NotNull final Name name,
|
||||||
@NotNull Variance variance,
|
@NotNull Variance variance,
|
||||||
boolean isReified,
|
boolean isReified,
|
||||||
int index,
|
int index,
|
||||||
@@ -81,7 +83,15 @@ public abstract class AbstractTypeParameterDescriptor extends DeclarationDescrip
|
|||||||
new Function0<KtScope>() {
|
new Function0<KtScope>() {
|
||||||
@Override
|
@Override
|
||||||
public KtScope invoke() {
|
public KtScope invoke() {
|
||||||
return getUpperBoundsAsType().getMemberScope();
|
List<KtScope> scopes = new ArrayList<KtScope>();
|
||||||
|
for (KotlinType bound : getUpperBounds()) {
|
||||||
|
scopes.add(bound.getMemberScope());
|
||||||
|
}
|
||||||
|
return new ChainedScope(
|
||||||
|
AbstractTypeParameterDescriptor.this,
|
||||||
|
"Scope for type parameter " + name.asString(),
|
||||||
|
scopes.toArray(new KtScope[scopes.size()])
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
))
|
))
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import org.jetbrains.kotlin.name.Name;
|
|||||||
import org.jetbrains.kotlin.renderer.DescriptorRenderer;
|
import org.jetbrains.kotlin.renderer.DescriptorRenderer;
|
||||||
import org.jetbrains.kotlin.renderer.DescriptorRendererModifier;
|
import org.jetbrains.kotlin.renderer.DescriptorRendererModifier;
|
||||||
import org.jetbrains.kotlin.renderer.DescriptorRendererOptions;
|
import org.jetbrains.kotlin.renderer.DescriptorRendererOptions;
|
||||||
|
import org.jetbrains.kotlin.types.KotlinType;
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -126,11 +127,19 @@ public class MemberComparator implements Comparator<DeclarationDescriptor> {
|
|||||||
List<TypeParameterDescriptor> c1TypeParameters = c1.getTypeParameters();
|
List<TypeParameterDescriptor> c1TypeParameters = c1.getTypeParameters();
|
||||||
List<TypeParameterDescriptor> c2TypeParameters = c2.getTypeParameters();
|
List<TypeParameterDescriptor> c2TypeParameters = c2.getTypeParameters();
|
||||||
for (int i = 0; i < Math.min(c1TypeParameters.size(), c2TypeParameters.size()); i++) {
|
for (int i = 0; i < Math.min(c1TypeParameters.size(), c2TypeParameters.size()); i++) {
|
||||||
String p1 = RENDERER.renderType(c1TypeParameters.get(i).getUpperBoundsAsType());
|
List<KotlinType> c1Bounds = c1TypeParameters.get(i).getUpperBounds();
|
||||||
String p2 = RENDERER.renderType(c2TypeParameters.get(i).getUpperBoundsAsType());
|
List<KotlinType> c2Bounds = c2TypeParameters.get(i).getUpperBounds();
|
||||||
int parametersCompareTo = p1.compareTo(p2);
|
int boundsCountCompareTo = c1Bounds.size() - c2Bounds.size();
|
||||||
if (parametersCompareTo != 0) {
|
if (boundsCountCompareTo != 0) {
|
||||||
return parametersCompareTo;
|
return boundsCountCompareTo;
|
||||||
|
}
|
||||||
|
for (int j = 0; j < c1Bounds.size(); j++) {
|
||||||
|
String b1 = RENDERER.renderType(c1Bounds.get(j));
|
||||||
|
String b2 = RENDERER.renderType(c2Bounds.get(j));
|
||||||
|
int boundCompareTo = b1.compareTo(b2);
|
||||||
|
if (boundCompareTo != 0) {
|
||||||
|
return boundCompareTo;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-7
@@ -23,9 +23,7 @@ import org.jetbrains.kotlin.descriptors.annotations.FilteredAnnotations
|
|||||||
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemImpl.ConstraintKind.EQUAL
|
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemImpl.ConstraintKind.EQUAL
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemImpl.ConstraintKind.SUB_TYPE
|
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemImpl.ConstraintKind.SUB_TYPE
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.TypeBounds.Bound
|
import org.jetbrains.kotlin.resolve.calls.inference.TypeBounds.Bound
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.TypeBounds.BoundKind.EXACT_BOUND
|
import org.jetbrains.kotlin.resolve.calls.inference.TypeBounds.BoundKind.*
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.TypeBounds.BoundKind.LOWER_BOUND
|
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.TypeBounds.BoundKind.UPPER_BOUND
|
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPosition
|
import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPosition
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind
|
import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind.TYPE_BOUND_POSITION
|
import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind.TYPE_BOUND_POSITION
|
||||||
@@ -419,12 +417,12 @@ public class ConstraintSystemImpl : ConstraintSystem {
|
|||||||
constraintContext: ConstraintContext
|
constraintContext: ConstraintContext
|
||||||
) {
|
) {
|
||||||
val typeVariable = getMyTypeVariable(parameterType)!!
|
val typeVariable = getMyTypeVariable(parameterType)!!
|
||||||
if (!typeVariable.getUpperBoundsAsType().isDefaultBound()
|
if (!typeVariable.upperBounds.let { it.size == 1 && it.single().isDefaultBound() } &&
|
||||||
&& constrainingTypeProjection.getProjectionKind() == Variance.IN_VARIANCE) {
|
constrainingTypeProjection.projectionKind == Variance.IN_VARIANCE) {
|
||||||
errors.add(CannotCapture(constraintContext.position, typeVariable))
|
errors.add(CannotCapture(constraintContext.position, typeVariable))
|
||||||
}
|
}
|
||||||
val typeProjection = if (parameterType.isMarkedNullable()) {
|
val typeProjection = if (parameterType.isMarkedNullable) {
|
||||||
TypeProjectionImpl(constrainingTypeProjection.getProjectionKind(), TypeUtils.makeNotNullable(constrainingTypeProjection.getType()))
|
TypeProjectionImpl(constrainingTypeProjection.projectionKind, TypeUtils.makeNotNullable(constrainingTypeProjection.type))
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
constrainingTypeProjection
|
constrainingTypeProjection
|
||||||
|
|||||||
@@ -229,13 +229,13 @@ public class CommonSupertypes {
|
|||||||
nullable |= type.isMarkedNullable();
|
nullable |= type.isMarkedNullable();
|
||||||
}
|
}
|
||||||
|
|
||||||
ClassifierDescriptor declarationDescriptor = constructor.getDeclarationDescriptor();
|
ClassifierDescriptor classifier = constructor.getDeclarationDescriptor();
|
||||||
KtScope newScope;
|
KtScope newScope;
|
||||||
if (declarationDescriptor instanceof ClassDescriptor) {
|
if (classifier instanceof ClassDescriptor) {
|
||||||
newScope = ((ClassDescriptor) declarationDescriptor).getMemberScope(newProjections);
|
newScope = ((ClassDescriptor) classifier).getMemberScope(newProjections);
|
||||||
}
|
}
|
||||||
else if (declarationDescriptor instanceof TypeParameterDescriptor) {
|
else if (classifier instanceof TypeParameterDescriptor) {
|
||||||
newScope = ((TypeParameterDescriptor) declarationDescriptor).getUpperBoundsAsType().getMemberScope();
|
newScope = classifier.getDefaultType().getMemberScope();
|
||||||
}
|
}
|
||||||
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);
|
||||||
|
|||||||
Reference in New Issue
Block a user