Migrate UseExperimental->OptIn in project sources

This commit is contained in:
Alexander Udalov
2020-01-28 15:35:42 +01:00
parent 125b39d9be
commit 795d6ab407
164 changed files with 213 additions and 211 deletions
@@ -563,7 +563,7 @@ class LazyJavaClassMemberScope(
private fun computeSupertypes(): Collection<KotlinType> {
if (skipRefinement) return ownerDescriptor.typeConstructor.supertypes
@UseExperimental(TypeRefinement::class)
@OptIn(TypeRefinement::class)
return c.components.kotlinTypeChecker.kotlinTypeRefiner.refineSupertypes(ownerDescriptor)
}
@@ -91,7 +91,7 @@ class RawTypeImpl private constructor(lowerBound: SimpleType, upperBound: Simple
}
@TypeRefinement
@UseExperimental(TypeRefinement::class)
@OptIn(TypeRefinement::class)
override fun refine(kotlinTypeRefiner: KotlinTypeRefiner): FlexibleType {
return RawTypeImpl(
kotlinTypeRefiner.refineType(lowerBound) as SimpleType,
@@ -160,7 +160,7 @@ internal object RawSubstitution : TypeSubstitution() {
type.isMarkedNullable, memberScope
) factory@{ kotlinTypeRefiner ->
val classId = (declaration as? ClassDescriptor)?.classId ?: return@factory null
@UseExperimental(TypeRefinement::class)
@OptIn(TypeRefinement::class)
val refinedClassDescriptor = kotlinTypeRefiner.findClassAcrossModuleDependencies(classId) ?: return@factory null
if (refinedClassDescriptor == declaration) return@factory null
@@ -22,7 +22,7 @@ class ScopesHolderForClass<T : MemberScope> private constructor(
scopeFactory(kotlinTypeRefinerForOwnerModule)
}
@UseExperimental(TypeRefinement::class)
@OptIn(TypeRefinement::class)
fun getScope(kotlinTypeRefiner: KotlinTypeRefiner): T {
/*
* That check doesn't break anything, because scopeForOwnerModule _will_ anyway refine supertypes from module of
@@ -92,7 +92,7 @@ abstract class AbstractTypeAliasDescriptor(
protected abstract fun getTypeConstructorTypeParameters(): List<TypeParameterDescriptor>
@UseExperimental(TypeRefinement::class)
@OptIn(TypeRefinement::class)
protected fun computeDefaultType(): SimpleType =
TypeUtils.makeUnsubstitutedType(this, classDescriptor?.unsubstitutedMemberScope ?: MemberScope.Empty) { kotlinTypeRefiner ->
kotlinTypeRefiner.refineDescriptor(this)?.defaultType
@@ -121,7 +121,7 @@ abstract class AbstractTypeAliasDescriptor(
// There must be @TypeRefinement, but there is a bug with anonymous objects and experimental annotations
// See KT-31728
@UseExperimental(TypeRefinement::class)
@OptIn(TypeRefinement::class)
override fun refine(kotlinTypeRefiner: KotlinTypeRefiner): TypeConstructor = this
}
}
@@ -47,7 +47,7 @@ class ModuleDescriptorImpl @JvmOverloads constructor(
throw IllegalArgumentException("Module name must be special: $moduleName")
}
this.capabilities = capabilities.toMutableMap()
@UseExperimental(TypeRefinement::class)
@OptIn(TypeRefinement::class)
this.capabilities[REFINER_CAPABILITY] = Ref(null)
}
@@ -450,5 +450,5 @@ fun DeclarationDescriptor.isPrimaryConstructorOfInlineClass(): Boolean =
@TypeRefinement
fun ModuleDescriptor.getKotlinTypeRefiner(): KotlinTypeRefiner = getCapability(REFINER_CAPABILITY)?.value ?: KotlinTypeRefiner.Default
@UseExperimental(TypeRefinement::class)
@OptIn(TypeRefinement::class)
fun ModuleDescriptor.isTypeRefinementEnabled(): Boolean = getCapability(REFINER_CAPABILITY)?.value != null
@@ -45,7 +45,7 @@ abstract class AbstractTypeConstructor(storageManager: StorageManager) : TypeCon
result in deadlock
*/
private val refinedSupertypes by lazy(LazyThreadSafetyMode.PUBLICATION) {
@UseExperimental(TypeRefinement::class)
@OptIn(TypeRefinement::class)
kotlinTypeRefiner.refineTypes(this@AbstractTypeConstructor.getSupertypes())
}
@@ -72,7 +72,7 @@ class IntersectionTypeConstructor(typesToIntersect: Collection<KotlinType>) : Ty
return intersectedTypes == other.intersectedTypes
}
@UseExperimental(TypeRefinement::class)
@OptIn(TypeRefinement::class)
fun createType(): SimpleType =
KotlinTypeFactory.simpleTypeWithNonTrivialMemberScope(
Annotations.EMPTY, this, listOf(), false, this.createScopeForKotlinType()
@@ -35,7 +35,7 @@ typealias RefinedTypeFactory = (KotlinTypeRefiner) -> SimpleType?
object KotlinTypeFactory {
val EMPTY_REFINED_TYPE_FACTORY: RefinedTypeFactory = { _ -> null }
@UseExperimental(TypeRefinement::class)
@OptIn(TypeRefinement::class)
private fun computeMemberScope(
constructor: TypeConstructor,
arguments: List<TypeProjection>,
@@ -62,7 +62,7 @@ object KotlinTypeFactory {
@JvmStatic
@JvmOverloads
@UseExperimental(TypeRefinement::class)
@OptIn(TypeRefinement::class)
fun simpleType(
annotations: Annotations,
constructor: TypeConstructor,
@@ -112,7 +112,7 @@ object KotlinTypeFactory {
private class ExpandedTypeOrRefinedConstructor(val expandedType: SimpleType?, val refinedConstructor: TypeConstructor?)
@JvmStatic
@UseExperimental(TypeRefinement::class)
@OptIn(TypeRefinement::class)
fun simpleTypeWithNonTrivialMemberScope(
annotations: Annotations,
constructor: TypeConstructor,
@@ -58,7 +58,7 @@ class AbbreviatedType(override val delegate: SimpleType, val abbreviation: Simpl
override fun replaceDelegate(delegate: SimpleType) = AbbreviatedType(delegate, abbreviation)
@TypeRefinement
@UseExperimental(TypeRefinement::class)
@OptIn(TypeRefinement::class)
override fun refine(kotlinTypeRefiner: KotlinTypeRefiner): AbbreviatedType =
AbbreviatedType(
kotlinTypeRefiner.refineType(delegate) as SimpleType,
@@ -85,7 +85,7 @@ class LazyWrappedType(
override fun isComputed(): Boolean = lazyValue.isComputed()
@TypeRefinement
@UseExperimental(TypeRefinement::class)
@OptIn(TypeRefinement::class)
override fun refine(kotlinTypeRefiner: KotlinTypeRefiner) = LazyWrappedType(storageManager) {
kotlinTypeRefiner.refineType(computation())
}
@@ -45,7 +45,7 @@ class SimpleTypeWithEnhancement(
override fun replaceDelegate(delegate: SimpleType) = SimpleTypeWithEnhancement(delegate, enhancement)
@TypeRefinement
@UseExperimental(TypeRefinement::class)
@OptIn(TypeRefinement::class)
override fun refine(kotlinTypeRefiner: KotlinTypeRefiner): SimpleTypeWithEnhancement =
SimpleTypeWithEnhancement(
kotlinTypeRefiner.refineType(delegate) as SimpleType,
@@ -75,7 +75,7 @@ class FlexibleTypeWithEnhancement(
override val delegate: SimpleType get() = origin.delegate
@TypeRefinement
@UseExperimental(TypeRefinement::class)
@OptIn(TypeRefinement::class)
override fun refine(kotlinTypeRefiner: KotlinTypeRefiner) =
FlexibleTypeWithEnhancement(
kotlinTypeRefiner.refineType(origin) as FlexibleType,
@@ -35,7 +35,7 @@ open class ClassicTypeCheckerContext(
return NewKotlinTypeChecker.Default.transformToNewType(type.unwrap())
}
@UseExperimental(TypeRefinement::class)
@OptIn(TypeRefinement::class)
override fun refineType(type: KotlinTypeMarker): KotlinTypeMarker {
require(type is KotlinType, type::errorMessage)
return kotlinTypeRefiner.refineType(type)
@@ -685,7 +685,7 @@ fun Variance.convertVariance(): TypeVariance {
}
@UseExperimental(ExperimentalContracts::class)
@OptIn(ExperimentalContracts::class)
fun requireOrDescribe(condition: Boolean, value: Any?) {
contract {
returns() implies condition
@@ -138,7 +138,7 @@ class FlexibleTypeImpl(lowerBound: SimpleType, upperBound: SimpleType) : Flexibl
= KotlinTypeFactory.flexibleType(lowerBound.makeNullableAsSpecified(newNullability), upperBound.makeNullableAsSpecified(newNullability))
@TypeRefinement
@UseExperimental(TypeRefinement::class)
@OptIn(TypeRefinement::class)
override fun refine(kotlinTypeRefiner: KotlinTypeRefiner): FlexibleType {
return FlexibleTypeImpl(
kotlinTypeRefiner.refineType(lowerBound) as SimpleType,
@@ -227,7 +227,7 @@ class DeserializedClassDescriptor(
}
private val refinedSupertypes = c.storageManager.createLazyValue {
@UseExperimental(TypeRefinement::class)
@OptIn(TypeRefinement::class)
kotlinTypeRefiner.refineSupertypes(classDescriptor)
}