[FE 1.0] Use the new type intersection to intersect types
This commit is contained in:
committed by
teamcity
parent
941a33a184
commit
bc1c2adae1
@@ -56,6 +56,7 @@ import org.jetbrains.kotlin.resolve.source.getPsi
|
||||
import org.jetbrains.kotlin.resolve.source.toSourceElement
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.Variance.*
|
||||
import org.jetbrains.kotlin.types.checker.intersectWrappedTypes
|
||||
import org.jetbrains.kotlin.types.error.ErrorTypeKind
|
||||
import org.jetbrains.kotlin.types.error.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.error.ErrorScope
|
||||
@@ -538,9 +539,9 @@ class TypeResolver(
|
||||
|
||||
private fun getScopeForTypeParameter(c: TypeResolutionContext, typeParameterDescriptor: TypeParameterDescriptor): MemberScope {
|
||||
return when {
|
||||
c.checkBounds -> TypeIntersector.getUpperBoundsAsType(typeParameterDescriptor).memberScope
|
||||
c.checkBounds -> intersectWrappedTypes(typeParameterDescriptor.upperBounds).memberScope
|
||||
else -> LazyScopeAdapter {
|
||||
TypeIntersector.getUpperBoundsAsType(typeParameterDescriptor).memberScope
|
||||
intersectWrappedTypes(typeParameterDescriptor.upperBounds).memberScope
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.ClassifierDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor;
|
||||
import org.jetbrains.kotlin.types.checker.IntersectionTypeKt;
|
||||
import org.jetbrains.kotlin.utils.DFS;
|
||||
|
||||
import java.util.Collections;
|
||||
@@ -57,7 +58,7 @@ public class BoundsSubstitutor {
|
||||
|
||||
// todo assert: no loops
|
||||
for (TypeParameterDescriptor descriptor : topologicallySortTypeParameters(typeParameters)) {
|
||||
KotlinType upperBoundsAsType = TypeIntersector.getUpperBoundsAsType(descriptor);
|
||||
KotlinType upperBoundsAsType = IntersectionTypeKt.intersectWrappedTypes(descriptor.getUpperBounds());
|
||||
KotlinType substitutedUpperBoundsAsType = substitutor.substitute(upperBoundsAsType, Variance.INVARIANT);
|
||||
mutableSubstitution.put(descriptor.getTypeConstructor(), new TypeProjectionImpl(substitutedUpperBoundsAsType));
|
||||
}
|
||||
|
||||
@@ -20,9 +20,8 @@ import org.jetbrains.kotlin.builtins.DefaultBuiltIns
|
||||
import org.jetbrains.kotlin.test.KotlinTestWithEnvironmentManagement
|
||||
import org.jetbrains.kotlin.types.AbstractNullabilityChecker
|
||||
import org.jetbrains.kotlin.types.KotlinTypeFactory
|
||||
import org.jetbrains.kotlin.types.SimpleType
|
||||
import org.jetbrains.kotlin.types.TypeIntersector
|
||||
import org.jetbrains.kotlin.types.checker.createClassicTypeCheckerState
|
||||
import org.jetbrains.kotlin.types.checker.intersectTypes
|
||||
|
||||
class SlowTypeAssertionsEnabledTest : KotlinTestWithEnvironmentManagement() {
|
||||
|
||||
@@ -43,10 +42,10 @@ class SlowTypeAssertionsEnabledTest : KotlinTestWithEnvironmentManagement() {
|
||||
val builtIns = DefaultBuiltIns.Instance
|
||||
|
||||
try {
|
||||
val superType = TypeIntersector.intersectTypes(listOf(builtIns.charSequence.defaultType, builtIns.comparable.defaultType))
|
||||
val superType = intersectTypes(listOf(builtIns.charSequence.defaultType, builtIns.comparable.defaultType))
|
||||
AbstractNullabilityChecker.isPossibleSubtype(
|
||||
createClassicTypeCheckerState(isErrorTypeEqualsToAnything = true), builtIns.annotationType,
|
||||
superType as SimpleType
|
||||
superType
|
||||
)
|
||||
} catch (e: AssertionError) {
|
||||
assertEquals("Not singleClassifierType superType: {CharSequence & Comparable<T>}", e.message)
|
||||
|
||||
@@ -44,6 +44,7 @@ import org.jetbrains.kotlin.test.KotlinTestUtils;
|
||||
import org.jetbrains.kotlin.test.KotlinTestWithEnvironment;
|
||||
import org.jetbrains.kotlin.tests.di.ContainerForTests;
|
||||
import org.jetbrains.kotlin.tests.di.InjectionKt;
|
||||
import org.jetbrains.kotlin.types.checker.IntersectionTypeKt;
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
|
||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices;
|
||||
|
||||
@@ -505,7 +506,7 @@ public class KotlinTypeCheckerTest extends KotlinTestWithEnvironment {
|
||||
for (String type : types) {
|
||||
typesToIntersect.add(makeType(type));
|
||||
}
|
||||
KotlinType result = TypeIntersector.intersectTypes(typesToIntersect);
|
||||
KotlinType result = IntersectionTypeKt.intersectWrappedTypes(typesToIntersect);
|
||||
// assertNotNull("Intersection is null for " + typesToIntersect, result);
|
||||
assertEquals(makeType(expected), result);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user