Introduce TypeSystemCommonBackendContext, use in KotlinTypeMapper.getVarianceForWildcard
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
* Copyright 2010-2019 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
|
||||
|
||||
import org.jetbrains.kotlin.types.model.TypeConstructorMarker
|
||||
import org.jetbrains.kotlin.types.model.TypeSystemContext
|
||||
|
||||
interface TypeSystemCommonBackendContext : TypeSystemContext {
|
||||
fun TypeConstructorMarker.isFinalClassOrEnumEntryOrAnnotationClassConstructor(): Boolean
|
||||
}
|
||||
+15
-10
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.types.typeUtil.contains
|
||||
import kotlin.contracts.ExperimentalContracts
|
||||
import kotlin.contracts.contract
|
||||
|
||||
interface ClassicTypeSystemContext : TypeSystemInferenceExtensionContext {
|
||||
interface ClassicTypeSystemContext : TypeSystemInferenceExtensionContext, TypeSystemCommonBackendContext {
|
||||
override fun TypeConstructorMarker.isDenotable(): Boolean {
|
||||
require(this is TypeConstructor, this::errorMessage)
|
||||
return this.isDenotable
|
||||
@@ -145,15 +145,6 @@ interface ClassicTypeSystemContext : TypeSystemInferenceExtensionContext {
|
||||
return this.projectionKind.convertVariance()
|
||||
}
|
||||
|
||||
|
||||
private fun TypeVariance.convertVariance(): Variance {
|
||||
return when (this) {
|
||||
TypeVariance.INV -> Variance.INVARIANT
|
||||
TypeVariance.IN -> Variance.IN_VARIANCE
|
||||
TypeVariance.OUT -> Variance.OUT_VARIANCE
|
||||
}
|
||||
}
|
||||
|
||||
override fun TypeArgumentMarker.getType(): KotlinTypeMarker {
|
||||
require(this is TypeProjection, this::errorMessage)
|
||||
return this.type.unwrap()
|
||||
@@ -214,6 +205,12 @@ interface ClassicTypeSystemContext : TypeSystemInferenceExtensionContext {
|
||||
classDescriptor.kind != ClassKind.ANNOTATION_CLASS
|
||||
}
|
||||
|
||||
override fun TypeConstructorMarker.isFinalClassOrEnumEntryOrAnnotationClassConstructor(): Boolean {
|
||||
require(this is TypeConstructor, this::errorMessage)
|
||||
val classDescriptor = declarationDescriptor
|
||||
return classDescriptor is ClassDescriptor && classDescriptor.isFinalClass
|
||||
}
|
||||
|
||||
override fun SimpleTypeMarker.asArgumentList(): TypeArgumentListMarker {
|
||||
require(this is SimpleType, this::errorMessage)
|
||||
return this
|
||||
@@ -490,6 +487,14 @@ interface ClassicTypeSystemContext : TypeSystemInferenceExtensionContext {
|
||||
|
||||
}
|
||||
|
||||
fun TypeVariance.convertVariance(): Variance {
|
||||
return when (this) {
|
||||
TypeVariance.INV -> Variance.INVARIANT
|
||||
TypeVariance.IN -> Variance.IN_VARIANCE
|
||||
TypeVariance.OUT -> Variance.OUT_VARIANCE
|
||||
}
|
||||
}
|
||||
|
||||
private fun captureFromExpressionInternal(type: UnwrappedType) = captureFromExpression(type)
|
||||
|
||||
private fun hasNoInferInternal(type: UnwrappedType): Boolean {
|
||||
|
||||
Reference in New Issue
Block a user