[FIR] Remove all usages of classes and methods from FE 1.0 from FIR checkers
This commit is contained in:
committed by
TeamCityServer
parent
0260bf8767
commit
15b77045ee
@@ -109,6 +109,11 @@ object StandardClassIds {
|
||||
val EnhancedNullability = ClassId(FqName("kotlin.jvm.internal"), Name.identifier("EnhancedNullability"))
|
||||
|
||||
val PublishedApi = "PublishedApi".baseId()
|
||||
|
||||
val SinceKotlin = "SinceKotlin".baseId()
|
||||
|
||||
val coroutineContext = CallableId(StandardNames.COROUTINES_PACKAGE_FQ_NAME, Name.identifier("coroutineContext"))
|
||||
val suspend = CallableId(BASE_KOTLIN_PACKAGE, Name.identifier("suspend"))
|
||||
}
|
||||
|
||||
private fun <K, V> Map<K, V>.inverseMap() = entries.associate { (k, v) -> v to k }
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.types
|
||||
|
||||
enum class EnrichedProjectionKind {
|
||||
IN, OUT, INV, STAR;
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun fromVariance(variance: Variance): EnrichedProjectionKind {
|
||||
return when (variance) {
|
||||
Variance.INVARIANT -> INV
|
||||
Variance.IN_VARIANCE -> IN
|
||||
Variance.OUT_VARIANCE -> OUT
|
||||
}
|
||||
}
|
||||
|
||||
// If class C<out T> then C<T> and C<out T> mean the same
|
||||
// out * out = out
|
||||
// out * in = *
|
||||
// out * inv = out
|
||||
//
|
||||
// in * out = *
|
||||
// in * in = in
|
||||
// in * inv = in
|
||||
//
|
||||
// inv * out = out
|
||||
// inv * in = out
|
||||
// inv * inv = inv
|
||||
fun getEffectiveProjectionKind(
|
||||
typeParameterVariance: Variance,
|
||||
typeArgumentVariance: Variance
|
||||
): EnrichedProjectionKind {
|
||||
var a = typeParameterVariance
|
||||
var b = typeArgumentVariance
|
||||
|
||||
// If they are not both invariant, let's make b not invariant for sure
|
||||
if (b === Variance.INVARIANT) {
|
||||
val t = a
|
||||
a = b
|
||||
b = t
|
||||
}
|
||||
|
||||
// Opposites yield STAR
|
||||
if (a === Variance.IN_VARIANCE && b === Variance.OUT_VARIANCE) {
|
||||
return STAR
|
||||
}
|
||||
return if (a === Variance.OUT_VARIANCE && b === Variance.IN_VARIANCE) {
|
||||
STAR
|
||||
} else fromVariance(b)
|
||||
|
||||
// If they are not opposite, return b, because b is either equal to a or b is in/out and a is inv
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -126,23 +126,6 @@ public class TypeCheckingProcedure {
|
||||
&& isSubtypeOf(inflexibleType, FlexibleTypesKt.asFlexibleType(flexibleType).getUpperBound());
|
||||
}
|
||||
|
||||
public enum EnrichedProjectionKind {
|
||||
IN, OUT, INV, STAR;
|
||||
|
||||
@NotNull
|
||||
public static EnrichedProjectionKind fromVariance(@NotNull Variance variance) {
|
||||
switch (variance) {
|
||||
case INVARIANT:
|
||||
return INV;
|
||||
case IN_VARIANCE:
|
||||
return IN;
|
||||
case OUT_VARIANCE:
|
||||
return OUT;
|
||||
}
|
||||
throw new IllegalStateException("Unknown variance");
|
||||
}
|
||||
}
|
||||
|
||||
public static EnrichedProjectionKind getEffectiveProjectionKind(
|
||||
@NotNull TypeParameterDescriptor typeParameter,
|
||||
@NotNull TypeProjection typeArgument
|
||||
@@ -166,26 +149,7 @@ public class TypeCheckingProcedure {
|
||||
@NotNull Variance typeParameterVariance,
|
||||
@NotNull Variance typeArgumentVariance
|
||||
) {
|
||||
Variance a = typeParameterVariance;
|
||||
Variance b = typeArgumentVariance;
|
||||
|
||||
// If they are not both invariant, let's make b not invariant for sure
|
||||
if (b == INVARIANT) {
|
||||
Variance t = a;
|
||||
a = b;
|
||||
b = t;
|
||||
}
|
||||
|
||||
// Opposites yield STAR
|
||||
if (a == IN_VARIANCE && b == OUT_VARIANCE) {
|
||||
return EnrichedProjectionKind.STAR;
|
||||
}
|
||||
if (a == OUT_VARIANCE && b == IN_VARIANCE) {
|
||||
return EnrichedProjectionKind.STAR;
|
||||
}
|
||||
|
||||
// If they are not opposite, return b, because b is either equal to a or b is in/out and a is inv
|
||||
return EnrichedProjectionKind.fromVariance(b);
|
||||
return EnrichedProjectionKind.Companion.getEffectiveProjectionKind(typeParameterVariance, typeArgumentVariance);
|
||||
}
|
||||
|
||||
public boolean isSubtypeOf(@NotNull KotlinType subtype, @NotNull KotlinType supertype) {
|
||||
|
||||
Reference in New Issue
Block a user