Code cleanup: type parameters can have in / out variance
This commit is contained in:
+1
-1
@@ -152,7 +152,7 @@ private fun List<Annotations>.compositeAnnotationsOrSingle() = when (size) {
|
||||
|
||||
private fun TypeComponentPosition.shouldEnhance() = this != TypeComponentPosition.INFLEXIBLE
|
||||
|
||||
private data class EnhancementResult<T>(val result: T, val enhancementAnnotations: Annotations?)
|
||||
private data class EnhancementResult<out T>(val result: T, val enhancementAnnotations: Annotations?)
|
||||
private fun <T> T.noChange() = EnhancementResult(this, null)
|
||||
private fun <T> T.enhancedNullability() = EnhancementResult(this, ENHANCED_NULLABILITY_ANNOTATIONS)
|
||||
private fun <T> T.enhancedMutability() = EnhancementResult(this, ENHANCED_MUTABILITY_ANNOTATIONS)
|
||||
|
||||
+1
-1
@@ -347,7 +347,7 @@ abstract class AbstractBinaryClassAnnotationAndConstantLoader<A : Any, C : Any,
|
||||
}
|
||||
}
|
||||
|
||||
private class Storage<A, C>(
|
||||
private class Storage<out A, out C>(
|
||||
val memberAnnotations: Map<MemberSignature, List<A>>,
|
||||
val propertyConstants: Map<MemberSignature, C>
|
||||
)
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.builtins
|
||||
|
||||
import org.jetbrains.kotlin.utils.sure
|
||||
|
||||
class BuiltInsInitializer<T : KotlinBuiltIns>(
|
||||
class BuiltInsInitializer<out T : KotlinBuiltIns>(
|
||||
private val constructor: () -> T
|
||||
) {
|
||||
@Volatile private var instance: T? = null
|
||||
|
||||
@@ -33,7 +33,7 @@ abstract class ConstantValue<out T>(open val value: T) {
|
||||
override fun toString() = value.toString()
|
||||
}
|
||||
|
||||
abstract class IntegerValueConstant<T> protected constructor(value: T) : ConstantValue<T>(value)
|
||||
abstract class IntegerValueConstant<out T> protected constructor(value: T) : ConstantValue<T>(value)
|
||||
|
||||
class AnnotationValue(value: AnnotationDescriptor) : ConstantValue<AnnotationDescriptor>(value) {
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
|
||||
import org.jetbrains.kotlin.types.typeUtil.builtIns
|
||||
import java.util.*
|
||||
|
||||
data class ApproximationBounds<T>(
|
||||
data class ApproximationBounds<out T>(
|
||||
val lower: T,
|
||||
val upper: T
|
||||
)
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
// The MessageLite instance everywhere should be Constructor, Function or Property
|
||||
// TODO: simplify this interface
|
||||
interface AnnotationAndConstantLoader<A : Any, C : Any, T : Any> {
|
||||
interface AnnotationAndConstantLoader<out A : Any, out C : Any, out T : Any> {
|
||||
fun loadClassAnnotations(
|
||||
container: ProtoContainer.Class
|
||||
): List<A>
|
||||
|
||||
@@ -18,20 +18,20 @@ package org.jetbrains.kotlin.storage
|
||||
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
interface MemoizedFunctionToNotNull<P, R : Any> : Function1<P, R> {
|
||||
interface MemoizedFunctionToNotNull<in P, out R : Any> : Function1<P, R> {
|
||||
fun isComputed(key: P): Boolean
|
||||
}
|
||||
|
||||
interface MemoizedFunctionToNullable<P, R : Any> : Function1<P, R?> {
|
||||
interface MemoizedFunctionToNullable<in P, out R : Any> : Function1<P, R?> {
|
||||
fun isComputed(key: P): Boolean
|
||||
}
|
||||
|
||||
interface NotNullLazyValue<T : Any> : Function0<T> {
|
||||
interface NotNullLazyValue<out T : Any> : Function0<T> {
|
||||
fun isComputed(): Boolean
|
||||
fun isComputing(): Boolean
|
||||
}
|
||||
|
||||
interface NullableLazyValue<T : Any> : Function0<T?> {
|
||||
interface NullableLazyValue<out T : Any> : Function0<T?> {
|
||||
fun isComputed(): Boolean
|
||||
fun isComputing(): Boolean
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user