Fixes and refactors
This commit is contained in:
committed by
Dmitriy Novozhilov
parent
2e2e70fede
commit
19bfc43bee
@@ -341,7 +341,7 @@ class CollectionStubMethodGenerator(
|
||||
}
|
||||
|
||||
private fun newType(classDescriptor: ClassDescriptor, typeArguments: List<TypeProjection>): KotlinType {
|
||||
return KotlinTypeFactory.simpleNotNullType(Annotations.EMPTY, classDescriptor, typeArguments)
|
||||
return KotlinTypeFactory.simpleNotNullType(TypeAttributes.Empty, classDescriptor, typeArguments)
|
||||
}
|
||||
|
||||
private fun FunctionDescriptor.signature(): JvmMethodGenericSignature =
|
||||
|
||||
@@ -402,16 +402,20 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext, ConeTypeCo
|
||||
|
||||
override fun unionTypeAttributes(types: List<KotlinTypeMarker>): List<AnnotationMarker> {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
types as List<ConeKotlinType>
|
||||
return types.map { it.attributes }.reduce { x, y -> x.union(y) }.toList()
|
||||
return (types as List<ConeKotlinType>).map { it.attributes }.reduce { x, y -> x.union(y) }.toList()
|
||||
}
|
||||
|
||||
override fun KotlinTypeMarker.replaceTypeAttributes(newAttributes: List<AnnotationMarker>): KotlinTypeMarker {
|
||||
require(this is ConeKotlinType)
|
||||
val typeAttributes = newAttributes.filterIsInstance<ConeAttribute<*>>()
|
||||
require(typeAttributes.size == newAttributes.size)
|
||||
if (newAttributes.isEmpty()) return this
|
||||
return createSimpleType(this.typeConstructor(), this.getArguments(), this.isNullable, this.isExtensionFunctionType, typeAttributes)
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return createSimpleType(
|
||||
this.typeConstructor(),
|
||||
this.getArguments(),
|
||||
this.isNullable,
|
||||
this.isExtensionFunctionType,
|
||||
newAttributes as List<ConeAttribute<*>>
|
||||
)
|
||||
}
|
||||
|
||||
override fun TypeConstructorMarker.getApproximatedIntegerLiteralType(): KotlinTypeMarker {
|
||||
|
||||
@@ -420,6 +420,12 @@ interface ConeTypeContext : TypeSystemContext, TypeSystemOptimizationContext, Ty
|
||||
return attributes.toList()
|
||||
}
|
||||
|
||||
override fun KotlinTypeMarker.getCustomAttributes(): List<AnnotationMarker> {
|
||||
require(this is ConeKotlinType)
|
||||
val compilerAttributes = CompilerConeAttributes.classIdByCompilerAttribute
|
||||
return attributes.filterNot { it in compilerAttributes || it is CustomAnnotationTypeAttribute }
|
||||
}
|
||||
|
||||
override fun SimpleTypeMarker.isStubType(): Boolean {
|
||||
return this is ConeStubType
|
||||
}
|
||||
|
||||
+12
-10
@@ -24,22 +24,24 @@ import org.jetbrains.kotlin.resolve.BindingTrace
|
||||
import org.jetbrains.kotlin.resolve.DeclarationReturnTypeSanitizer
|
||||
import org.jetbrains.kotlin.types.UnwrappedType
|
||||
import org.jetbrains.kotlin.types.WrappedTypeFactory
|
||||
import org.jetbrains.kotlin.types.replaceAnnotations
|
||||
|
||||
object JvmDeclarationReturnTypeSanitizer : DeclarationReturnTypeSanitizer {
|
||||
override fun sanitizeReturnType(
|
||||
inferred: UnwrappedType,
|
||||
wrappedTypeFactory: WrappedTypeFactory,
|
||||
trace: BindingTrace,
|
||||
languageVersionSettings: LanguageVersionSettings
|
||||
inferred: UnwrappedType,
|
||||
wrappedTypeFactory: WrappedTypeFactory,
|
||||
trace: BindingTrace,
|
||||
languageVersionSettings: LanguageVersionSettings
|
||||
): UnwrappedType =
|
||||
if (languageVersionSettings.supportsFeature(LanguageFeature.StrictJavaNullabilityAssertions)) {
|
||||
// NB can't check for presence of EnhancedNullability here,
|
||||
// because it will also cause recursion in declaration type resolution.
|
||||
inferred.replaceAnnotations(
|
||||
if (languageVersionSettings.supportsFeature(LanguageFeature.StrictJavaNullabilityAssertions)) {
|
||||
// NB can't check for presence of EnhancedNullability here,
|
||||
// because it will also cause recursion in declaration type resolution.
|
||||
inferred.replaceAttributes(
|
||||
inferred.attributes.replaceAnnotations(
|
||||
FilteredAnnotations(inferred.annotations, languageVersionSettings.supportsFeature(LanguageFeature.NewInference)) {
|
||||
it != JvmAnnotationNames.ENHANCED_NULLABILITY_ANNOTATION
|
||||
}
|
||||
)
|
||||
}
|
||||
else inferred
|
||||
)
|
||||
} else inferred
|
||||
}
|
||||
+4
-3
@@ -20,12 +20,12 @@ import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.resolve.calls.checkers.CallChecker
|
||||
import org.jetbrains.kotlin.resolve.calls.checkers.CallCheckerContext
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm
|
||||
import org.jetbrains.kotlin.types.KotlinTypeFactory
|
||||
import org.jetbrains.kotlin.types.TypeAttributes
|
||||
import org.jetbrains.kotlin.types.TypeProjectionImpl
|
||||
|
||||
class JavaClassOnCompanionChecker : CallChecker {
|
||||
@@ -44,8 +44,9 @@ class JavaClassOnCompanionChecker : CallChecker {
|
||||
val javaLangClass = actualType.constructor.declarationDescriptor as? ClassDescriptor ?: return
|
||||
|
||||
val arguments = listOf(TypeProjectionImpl(containingClass.defaultType))
|
||||
val expectedType = KotlinTypeFactory.simpleType(Annotations.EMPTY, javaLangClass.typeConstructor, arguments,
|
||||
actualType.isMarkedNullable)
|
||||
val expectedType = KotlinTypeFactory.simpleType(
|
||||
TypeAttributes.Empty, javaLangClass.typeConstructor, arguments,
|
||||
actualType.isMarkedNullable)
|
||||
context.trace.report(ErrorsJvm.JAVA_CLASS_ON_COMPANION.on(reportOn, actualType, expectedType))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@ import org.jetbrains.kotlin.types.expressions.DeclarationScopeProviderForLocalCl
|
||||
import org.jetbrains.kotlin.types.expressions.LocalClassDescriptorHolder
|
||||
import org.jetbrains.kotlin.types.expressions.LocalLazyDeclarationResolver
|
||||
import org.jetbrains.kotlin.types.extensions.TypeAttributeTranslators
|
||||
import org.jetbrains.kotlin.types.extensions.TypeAttributeTranslatorsForInjection
|
||||
import org.jetbrains.kotlin.util.ProgressManagerBasedCancellationChecker
|
||||
|
||||
fun StorageComponentContainer.configureModule(
|
||||
@@ -80,7 +81,7 @@ fun StorageComponentContainer.configureModule(
|
||||
analyzerServices.platformConfigurator.configureModuleComponents(this)
|
||||
analyzerServices.platformConfigurator.configureModuleDependentCheckers(this)
|
||||
|
||||
useInstance(TypeAttributeTranslators(moduleContext.project).translators)
|
||||
useImpl<TypeAttributeTranslatorsForInjection>()
|
||||
|
||||
for (extension in StorageComponentContainerContributor.getInstances(moduleContext.project)) {
|
||||
extension.registerModuleComponents(this, platform, moduleContext.module)
|
||||
|
||||
@@ -242,7 +242,7 @@ class DeclarationsChecker(
|
||||
private fun checkTypeAliasExpansion(declaration: KtTypeAlias, typeAliasDescriptor: TypeAliasDescriptor) {
|
||||
val typeAliasExpansion = TypeAliasExpansion.createWithFormalArguments(typeAliasDescriptor)
|
||||
val reportStrategy = TypeAliasDeclarationCheckingReportStrategy(trace, typeAliasDescriptor, declaration, upperBoundChecker)
|
||||
TypeAliasExpander(reportStrategy, true).expandWithoutAbbreviation(typeAliasExpansion, Annotations.EMPTY)
|
||||
TypeAliasExpander(reportStrategy, true).expandWithoutAbbreviation(typeAliasExpansion, TypeAttributes.Empty)
|
||||
}
|
||||
|
||||
private fun checkConstructorDeclaration(constructorDescriptor: ClassConstructorDescriptor, declaration: KtConstructor<*>) {
|
||||
|
||||
@@ -105,7 +105,7 @@ class TypeResolver(
|
||||
|
||||
fun resolveExpandedTypeForTypeAlias(typeAliasDescriptor: TypeAliasDescriptor): SimpleType {
|
||||
val typeAliasExpansion = TypeAliasExpansion.createWithFormalArguments(typeAliasDescriptor)
|
||||
val expandedType = TypeAliasExpander.NON_REPORTING.expandWithoutAbbreviation(typeAliasExpansion, Annotations.EMPTY)
|
||||
val expandedType = TypeAliasExpander.NON_REPORTING.expandWithoutAbbreviation(typeAliasExpansion, TypeAttributes.Empty)
|
||||
return expandedType
|
||||
}
|
||||
|
||||
@@ -523,7 +523,7 @@ class TypeResolver(
|
||||
ErrorUtils.createErrorType("?")
|
||||
else
|
||||
KotlinTypeFactory.simpleTypeWithNonTrivialMemberScope(
|
||||
typeAttributeTranslators.toAttributes(annotations),
|
||||
typeAttributeTranslators.toAttributes(annotations, typeParameter.typeConstructor, containing),
|
||||
typeParameter.typeConstructor,
|
||||
listOf(),
|
||||
false,
|
||||
@@ -605,7 +605,11 @@ class TypeResolver(
|
||||
}
|
||||
|
||||
val resultingType =
|
||||
KotlinTypeFactory.simpleNotNullType(typeAttributeTranslators.toAttributes(annotations), classDescriptor, arguments)
|
||||
KotlinTypeFactory.simpleNotNullType(
|
||||
typeAttributeTranslators.toAttributes(annotations, classDescriptor.typeConstructor, c.scope.ownerDescriptor),
|
||||
classDescriptor,
|
||||
arguments
|
||||
)
|
||||
|
||||
// We create flexible types by convention here
|
||||
// This is not intended to be used in normal users' environments, only for tests and debugger etc
|
||||
@@ -701,9 +705,11 @@ class TypeResolver(
|
||||
return createErrorTypeForTypeConstructor(c, projectionFromAllQualifierParts, typeConstructor)
|
||||
}
|
||||
|
||||
val attributes = typeAttributeTranslators.toAttributes(annotations, descriptor.typeConstructor, c.scope.ownerDescriptor)
|
||||
|
||||
return if (c.abbreviated) {
|
||||
val abbreviatedType = KotlinTypeFactory.simpleType(
|
||||
typeAttributeTranslators.toAttributes(annotations),
|
||||
attributes,
|
||||
descriptor.typeConstructor,
|
||||
arguments,
|
||||
false
|
||||
@@ -711,7 +717,7 @@ class TypeResolver(
|
||||
type(abbreviatedType)
|
||||
} else {
|
||||
val typeAliasExpansion = TypeAliasExpansion.create(null, descriptor, arguments)
|
||||
val expandedType = TypeAliasExpander(reportStrategy, c.checkBounds).expand(typeAliasExpansion, annotations)
|
||||
val expandedType = TypeAliasExpander(reportStrategy, c.checkBounds).expand(typeAliasExpansion, attributes)
|
||||
type(expandedType)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -331,7 +331,7 @@ class CallCompleter(
|
||||
val value = constant.getValue(TypeUtils.NO_EXPECTED_TYPE).safeAs<Number>()?.toLong() ?: return null
|
||||
val typeConstructor = IntegerValueTypeConstructor(value, moduleDescriptor, constant.parameters)
|
||||
return KotlinTypeFactory.simpleTypeWithNonTrivialMemberScope(
|
||||
Annotations.EMPTY, typeConstructor, emptyList(), false,
|
||||
TypeAttributes.Empty, typeConstructor, emptyList(), false,
|
||||
ErrorUtils.createErrorScope("Scope for number value type ($typeConstructor)", true)
|
||||
)
|
||||
}
|
||||
|
||||
-2
@@ -54,8 +54,6 @@ class TypeTemplate(
|
||||
typeVariable.originalTypeParameter.builtIns.nothingType,
|
||||
typeVariable.originalTypeParameter.builtIns.anyType.makeNullableAsSpecified(nullable)
|
||||
) {
|
||||
override fun replaceAnnotations(newAnnotations: Annotations) = this
|
||||
|
||||
override fun replaceAttributes(newAttributes: TypeAttributes) = this
|
||||
|
||||
override fun makeNullableAsSpecified(newNullability: Boolean) = TypeTemplate(typeVariable, builderInferenceData, newNullability)
|
||||
|
||||
+1
-1
@@ -394,7 +394,7 @@ class KotlinToResolvedCallTransformer(
|
||||
val value = constant.getValue(TypeUtils.NO_EXPECTED_TYPE).safeAs<Number>()?.toLong() ?: return null
|
||||
val typeConstructor = IntegerLiteralTypeConstructor(value, moduleDescriptor, constant.parameters)
|
||||
return KotlinTypeFactory.simpleTypeWithNonTrivialMemberScope(
|
||||
Annotations.EMPTY, typeConstructor, emptyList(), false,
|
||||
TypeAttributes.Empty, typeConstructor, emptyList(), false,
|
||||
ErrorUtils.createErrorScope("Scope for number value type ($typeConstructor)", true),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ fun replaceReturnTypeForCallable(type: KotlinType, given: KotlinType): KotlinTyp
|
||||
fun replaceReturnTypeByUnknown(type: KotlinType) = replaceReturnTypeForCallable(type, DONT_CARE)
|
||||
|
||||
private fun replaceTypeArguments(type: KotlinType, newArguments: List<TypeProjection>) =
|
||||
KotlinTypeFactory.simpleType(type.annotations, type.constructor, newArguments, type.isMarkedNullable)
|
||||
KotlinTypeFactory.simpleType(type.attributes, type.constructor, newArguments, type.isMarkedNullable)
|
||||
|
||||
private fun getParameterArgumentsOfCallableType(type: KotlinType) =
|
||||
type.arguments.dropLast(1)
|
||||
@@ -126,7 +126,7 @@ fun getErasedReceiverType(receiverParameterDescriptor: ReceiverParameterDescript
|
||||
}
|
||||
|
||||
return KotlinTypeFactory.simpleTypeWithNonTrivialMemberScope(
|
||||
receiverType.annotations, receiverTypeConstructor, fakeTypeArguments,
|
||||
receiverType.attributes, receiverTypeConstructor, fakeTypeArguments,
|
||||
receiverType.isMarkedNullable, ErrorUtils.createErrorScope("Error scope for erased receiver type", /*throwExceptions=*/true)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ import org.jetbrains.kotlin.storage.StorageManager
|
||||
import org.jetbrains.kotlin.storage.getValue
|
||||
import org.jetbrains.kotlin.types.AbbreviatedType
|
||||
import org.jetbrains.kotlin.types.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.typeUtil.replaceAnnotations
|
||||
|
||||
abstract class LazyAnnotationsContext(
|
||||
val annotationResolver: AnnotationResolver,
|
||||
|
||||
@@ -272,7 +272,7 @@ public class CommonSupertypes {
|
||||
else {
|
||||
newScope = ErrorUtils.createErrorScope("A scope for common supertype which is not a normal classifier", true);
|
||||
}
|
||||
return KotlinTypeFactory.simpleTypeWithNonTrivialMemberScope(Annotations.Companion.getEMPTY(), constructor, newProjections, nullable, newScope);
|
||||
return KotlinTypeFactory.simpleTypeWithNonTrivialMemberScope(TypeAttributes.Companion.getEmpty(), constructor, newProjections, nullable, newScope);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+1
-1
@@ -498,7 +498,7 @@ class DoubleColonExpressionResolver(
|
||||
|
||||
val arguments = descriptor.typeConstructor.parameters.map(TypeUtils::makeStarProjection)
|
||||
KotlinTypeFactory.simpleType(
|
||||
Annotations.EMPTY, descriptor.typeConstructor, arguments,
|
||||
TypeAttributes.Empty, descriptor.typeConstructor, arguments,
|
||||
possiblyBareType.isNullable || doubleColonExpression.hasQuestionMarks
|
||||
)
|
||||
} else {
|
||||
|
||||
@@ -286,7 +286,7 @@ open class IrBasedTypeParameterDescriptor(owner: IrTypeParameter) : TypeParamete
|
||||
|
||||
private val _defaultType: SimpleType by lazy {
|
||||
KotlinTypeFactory.simpleTypeWithNonTrivialMemberScope(
|
||||
Annotations.EMPTY, typeConstructor, emptyList(), false,
|
||||
TypeAttributes.Empty, typeConstructor, emptyList(), false,
|
||||
LazyScopeAdapter {
|
||||
TypeIntersectionScope.create(
|
||||
"Scope for type parameter " + name.asString(),
|
||||
|
||||
+2
-2
@@ -405,8 +405,8 @@ class IrBuiltInsOverDescriptors(
|
||||
|
||||
override val checkNotNullSymbol = defineCheckNotNullOperator()
|
||||
|
||||
private fun TypeConstructor.makeNonNullType() = KotlinTypeFactory.simpleType(Annotations.EMPTY, this, listOf(), false)
|
||||
private fun TypeConstructor.makeNullableType() = KotlinTypeFactory.simpleType(Annotations.EMPTY, this, listOf(), true)
|
||||
private fun TypeConstructor.makeNonNullType() = KotlinTypeFactory.simpleType(TypeAttributes.Empty, this, listOf(), false)
|
||||
private fun TypeConstructor.makeNullableType() = KotlinTypeFactory.simpleType(TypeAttributes.Empty, this, listOf(), true)
|
||||
|
||||
override val dataClassArrayMemberHashCodeSymbol = defineOperator("dataClassArrayMemberHashCode", intType, listOf(anyType))
|
||||
|
||||
|
||||
@@ -406,6 +406,11 @@ interface IrTypeSystemContext : TypeSystemContext, TypeSystemCommonSuperTypesCon
|
||||
return this.annotations.map { object : AnnotationMarker, IrElement by it {} }
|
||||
}
|
||||
|
||||
override fun KotlinTypeMarker.getCustomAttributes(): List<AnnotationMarker> {
|
||||
require(this is IrType)
|
||||
return emptyList()
|
||||
}
|
||||
|
||||
override fun createErrorType(debugName: String): SimpleTypeMarker {
|
||||
TODO("IrTypeSystemContext doesn't support constraint system resolution")
|
||||
}
|
||||
|
||||
+9
-6
@@ -60,7 +60,14 @@ class MutableVariableWithConstraints private constructor(
|
||||
&& previousConstraint.isNullabilityConstraint == constraint.isNullabilityConstraint
|
||||
) {
|
||||
if (newConstraintIsUseless(previousConstraint, constraint)) {
|
||||
return previousConstraint to false
|
||||
// Preserve constraints with different custom type attributes.
|
||||
// This allows us to union type attributes in NewCommonSuperTypeCalculator.kt
|
||||
with(context) {
|
||||
val prevAttributes = previousConstraint.type.getCustomAttributes()
|
||||
if (prevAttributes.isEmpty() || prevAttributes == constraint.type.getCustomAttributes()) {
|
||||
return previousConstraint to false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val isMatchingForSimplification = when (previousConstraint.kind) {
|
||||
@@ -139,11 +146,7 @@ class MutableVariableWithConstraints private constructor(
|
||||
return false
|
||||
|
||||
return when (old.kind) {
|
||||
ConstraintKind.EQUALITY -> {
|
||||
with(context) {
|
||||
old.type.getAttributes() == new.type.getAttributes()
|
||||
}
|
||||
}
|
||||
ConstraintKind.EQUALITY -> true
|
||||
ConstraintKind.LOWER -> new.kind.isLower()
|
||||
ConstraintKind.UPPER -> new.kind.isUpper()
|
||||
}
|
||||
|
||||
+1
-1
@@ -291,7 +291,7 @@ class KotlinConstraintSystemCompleter(
|
||||
csBuilder.registerVariable(returnVariable)
|
||||
val functionalType: KotlinType = csBuilder.buildCurrentSubstitutor().safeSubstitute(candidate.getSystem().asConstraintSystemCompleterContext(), atom.expectedType!!) as KotlinType
|
||||
val expectedType = KotlinTypeFactory.simpleType(
|
||||
functionalType.annotations,
|
||||
functionalType.attributes,
|
||||
functionalType.constructor,
|
||||
functionalType.arguments.dropLast(1) + returnVariable.defaultType.asTypeProjection(),
|
||||
functionalType.isMarkedNullable
|
||||
|
||||
+3
-1
@@ -148,7 +148,9 @@ interface NewTypeSubstitutor : TypeSubstitutorMarker {
|
||||
// simple classifier type
|
||||
var replacement = substituteNotNullTypeWithConstructor(typeConstructor) ?: return null
|
||||
if (keepAnnotation) {
|
||||
replacement = replacement.replaceAnnotations(CompositeAnnotations(replacement.annotations, type.annotations))
|
||||
replacement = replacement.replaceAttributes(
|
||||
replacement.attributes.add(type.attributes)
|
||||
)
|
||||
}
|
||||
if (type.isMarkedNullable) {
|
||||
replacement = replacement.makeNullableAsSpecified(true)
|
||||
|
||||
+2
-6
@@ -23,15 +23,11 @@ import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.resolve.calls.model.PostponableKotlinCallArgument
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.hasOnlyInputTypesAnnotation
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.KotlinTypeFactory
|
||||
import org.jetbrains.kotlin.types.SimpleType
|
||||
import org.jetbrains.kotlin.types.TypeConstructor
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeRefiner
|
||||
import org.jetbrains.kotlin.types.checker.NewTypeVariableConstructor
|
||||
import org.jetbrains.kotlin.types.model.TypeVariableMarker
|
||||
import org.jetbrains.kotlin.types.model.TypeVariableTypeConstructorMarker
|
||||
import org.jetbrains.kotlin.types.TypeRefinement
|
||||
|
||||
|
||||
class TypeVariableTypeConstructor(
|
||||
@@ -74,7 +70,7 @@ sealed class NewTypeVariable(
|
||||
fun TypeConstructor.typeForTypeVariable(): SimpleType {
|
||||
require(this is TypeVariableTypeConstructor)
|
||||
return KotlinTypeFactory.simpleTypeWithNonTrivialMemberScope(
|
||||
Annotations.EMPTY, this, arguments = emptyList(),
|
||||
TypeAttributes.Empty, this, arguments = emptyList(),
|
||||
nullable = false, memberScope = builtIns.any.unsubstitutedMemberScope
|
||||
)
|
||||
}
|
||||
|
||||
+2
-1
@@ -33,6 +33,7 @@ import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
||||
import org.jetbrains.kotlin.test.DummyTraces
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.KotlinTypeFactory
|
||||
import org.jetbrains.kotlin.types.TypeAttributes
|
||||
import java.util.regex.Pattern
|
||||
|
||||
class ConstraintSystemTestData(
|
||||
@@ -67,7 +68,7 @@ class ConstraintSystemTestData(
|
||||
val number = matcher.group(1)!!
|
||||
val parameters = CompileTimeConstant.Parameters(false, false, false, false, false, false, false, false)
|
||||
return KotlinTypeFactory.simpleTypeWithNonTrivialMemberScope(
|
||||
Annotations.EMPTY,
|
||||
TypeAttributes.Empty,
|
||||
IntegerValueTypeConstructor(number.toLong(), functionFoo.module, parameters),
|
||||
listOf(),
|
||||
false,
|
||||
|
||||
@@ -500,6 +500,8 @@ interface TypeSystemContext : TypeSystemOptimizationContext {
|
||||
|
||||
fun KotlinTypeMarker.getAttributes(): List<AnnotationMarker>
|
||||
|
||||
fun KotlinTypeMarker.getCustomAttributes(): List<AnnotationMarker>
|
||||
|
||||
fun substitutionSupertypePolicy(type: SimpleTypeMarker): TypeCheckerState.SupertypesPolicy
|
||||
|
||||
fun KotlinTypeMarker.isTypeVariableType(): Boolean
|
||||
|
||||
+1
-1
@@ -281,7 +281,7 @@ class LazyJavaClassDescriptor(
|
||||
else -> return null
|
||||
}
|
||||
|
||||
return KotlinTypeFactory.simpleNotNullType(Annotations.EMPTY, classDescriptor, parametersAsTypeProjections)
|
||||
return KotlinTypeFactory.simpleNotNullType(TypeAttributes.Empty, classDescriptor, parametersAsTypeProjections)
|
||||
}
|
||||
|
||||
private fun getPurelyImplementsFqNameFromAnnotation(): FqName? {
|
||||
|
||||
+3
-3
@@ -119,8 +119,8 @@ class JavaTypeResolver(
|
||||
attr: JavaTypeAttributes,
|
||||
lowerResult: SimpleType?
|
||||
): SimpleType? {
|
||||
val annotations =
|
||||
lowerResult?.annotations ?: LazyJavaAnnotations(c, javaType)
|
||||
val attributes =
|
||||
lowerResult?.attributes ?: LazyJavaAnnotations(c, javaType).toDefaultAttributes()
|
||||
val constructor = computeTypeConstructor(javaType, attr) ?: return null
|
||||
val isNullable = attr.isNullable()
|
||||
|
||||
@@ -130,7 +130,7 @@ class JavaTypeResolver(
|
||||
|
||||
val arguments = computeArguments(javaType, attr, constructor)
|
||||
|
||||
return KotlinTypeFactory.simpleType(annotations, constructor, arguments, isNullable)
|
||||
return KotlinTypeFactory.simpleType(attributes, constructor, arguments, isNullable)
|
||||
}
|
||||
|
||||
private fun computeTypeConstructor(javaType: JavaClassifierType, attr: JavaTypeAttributes): TypeConstructor? {
|
||||
|
||||
@@ -54,9 +54,6 @@ class RawTypeImpl private constructor(lowerBound: SimpleType, upperBound: Simple
|
||||
return classDescriptor.getMemberScope(RawSubstitution())
|
||||
}
|
||||
|
||||
override fun replaceAnnotations(newAnnotations: Annotations) =
|
||||
RawTypeImpl(lowerBound.replaceAnnotations(newAnnotations), upperBound.replaceAnnotations(newAnnotations))
|
||||
|
||||
override fun replaceAttributes(newAttributes: TypeAttributes) =
|
||||
RawTypeImpl(lowerBound.replaceAttributes(newAttributes), upperBound.replaceAttributes(newAttributes))
|
||||
|
||||
@@ -148,7 +145,7 @@ internal class RawSubstitution(typeParameterUpperBoundEraser: TypeParameterUpper
|
||||
TypeProjectionImpl(componentTypeProjection.projectionKind, eraseType(componentTypeProjection.type, attr))
|
||||
)
|
||||
return KotlinTypeFactory.simpleType(
|
||||
type.annotations, type.constructor, arguments, type.isMarkedNullable
|
||||
type.attributes, type.constructor, arguments, type.isMarkedNullable
|
||||
) to false
|
||||
}
|
||||
|
||||
@@ -156,7 +153,7 @@ internal class RawSubstitution(typeParameterUpperBoundEraser: TypeParameterUpper
|
||||
|
||||
val memberScope = declaration.getMemberScope(this)
|
||||
return KotlinTypeFactory.simpleTypeWithNonTrivialMemberScope(
|
||||
type.annotations, declaration.typeConstructor,
|
||||
type.attributes, declaration.typeConstructor,
|
||||
declaration.typeConstructor.parameters.map { parameter ->
|
||||
computeProjection(parameter, attr)
|
||||
},
|
||||
|
||||
+1
-2
@@ -150,7 +150,7 @@ class JavaTypeEnhancement(private val javaResolverSettings: JavaResolverSettings
|
||||
).compositeAnnotationsOrSingle()
|
||||
|
||||
val enhancedType = KotlinTypeFactory.simpleType(
|
||||
newAnnotations,
|
||||
newAnnotations.toDefaultAttributes(),
|
||||
typeConstructor,
|
||||
enhancedArguments.zip(arguments) { enhanced, original -> enhanced ?: original },
|
||||
enhancedNullability ?: isMarkedNullable
|
||||
@@ -252,7 +252,6 @@ internal class NotNullTypeParameterImpl(override val delegate: SimpleType) : Not
|
||||
return NotNullTypeParameterImpl(result)
|
||||
}
|
||||
|
||||
override fun replaceAnnotations(newAnnotations: Annotations) = NotNullTypeParameterImpl(delegate.replaceAnnotations(newAnnotations))
|
||||
override fun replaceAttributes(newAttributes: TypeAttributes) = NotNullTypeParameterImpl(delegate.replaceAttributes(newAttributes))
|
||||
override fun makeNullableAsSpecified(newNullability: Boolean) =
|
||||
if (newNullability) delegate.makeNullableAsSpecified(true) else this
|
||||
|
||||
+8
-3
@@ -48,7 +48,9 @@ import org.jetbrains.kotlin.resolve.sam.SamConversionResolverImpl
|
||||
import org.jetbrains.kotlin.serialization.deserialization.*
|
||||
import org.jetbrains.kotlin.storage.LockBasedStorageManager
|
||||
import org.jetbrains.kotlin.storage.StorageManager
|
||||
import org.jetbrains.kotlin.types.DefaultTypeAttributeTranslator
|
||||
import org.jetbrains.kotlin.types.checker.NewKotlinTypeChecker
|
||||
import org.jetbrains.kotlin.types.extensions.TypeAttributeTranslatorsForInjection
|
||||
|
||||
// This class is needed only for easier injection: exact types of needed components are specified in the constructor here.
|
||||
// Otherwise injector generator is not smart enough to deduce, for example, which package fragment provider DeserializationComponents needs
|
||||
@@ -63,7 +65,8 @@ class DeserializationComponentsForJava(
|
||||
errorReporter: ErrorReporter,
|
||||
lookupTracker: LookupTracker,
|
||||
contractDeserializer: ContractDeserializer,
|
||||
kotlinTypeChecker: NewKotlinTypeChecker
|
||||
kotlinTypeChecker: NewKotlinTypeChecker,
|
||||
typeAttributeTranslators: TypeAttributeTranslatorsForInjection
|
||||
) {
|
||||
val components: DeserializationComponents
|
||||
|
||||
@@ -77,7 +80,8 @@ class DeserializationComponentsForJava(
|
||||
additionalClassPartsProvider = jvmBuiltIns?.customizer ?: AdditionalClassPartsProvider.None,
|
||||
platformDependentDeclarationFilter = jvmBuiltIns?.customizer ?: PlatformDependentDeclarationFilter.NoPlatformDependent,
|
||||
extensionRegistryLite = JvmProtoBufUtil.EXTENSION_REGISTRY,
|
||||
kotlinTypeChecker = kotlinTypeChecker, samConversionResolver = SamConversionResolverImpl(storageManager, emptyList())
|
||||
kotlinTypeChecker = kotlinTypeChecker, samConversionResolver = SamConversionResolverImpl(storageManager, emptyList()),
|
||||
typeAttributeTranslators = typeAttributeTranslators.translators
|
||||
)
|
||||
}
|
||||
|
||||
@@ -188,6 +192,7 @@ fun makeDeserializationComponentsForJava(
|
||||
return DeserializationComponentsForJava(
|
||||
storageManager, module, DeserializationConfiguration.Default, javaClassDataFinder,
|
||||
binaryClassAnnotationAndConstantLoader, lazyJavaPackageFragmentProvider, notFoundClasses,
|
||||
errorReporter, LookupTracker.DO_NOTHING, ContractDeserializer.DEFAULT, NewKotlinTypeChecker.Default
|
||||
errorReporter, LookupTracker.DO_NOTHING, ContractDeserializer.DEFAULT, NewKotlinTypeChecker.Default,
|
||||
TypeAttributeTranslatorsForInjection(listOf(DefaultTypeAttributeTranslator))
|
||||
)
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ dependencies {
|
||||
api(project(":core:util.runtime"))
|
||||
api(kotlinStdlib())
|
||||
api(project(":kotlin-annotations-jvm"))
|
||||
api(project(":compiler:util"))
|
||||
compileOnly(intellijCoreDep()) { includeJars("intellij-core") }
|
||||
}
|
||||
|
||||
|
||||
@@ -665,7 +665,10 @@ public abstract class KotlinBuiltIns {
|
||||
@NotNull
|
||||
public SimpleType getArrayType(@NotNull Variance projectionType, @NotNull KotlinType argument, @NotNull Annotations annotations) {
|
||||
List<TypeProjectionImpl> types = Collections.singletonList(new TypeProjectionImpl(projectionType, argument));
|
||||
return KotlinTypeFactory.simpleNotNullType(annotations, getArray(), types);
|
||||
return KotlinTypeFactory.simpleNotNullType(
|
||||
TypeAttributesKt.toDefaultAttributes(annotations),
|
||||
getArray(),
|
||||
types);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -677,7 +680,7 @@ public abstract class KotlinBuiltIns {
|
||||
public SimpleType getEnumType(@NotNull SimpleType argument) {
|
||||
Variance projectionType = Variance.INVARIANT;
|
||||
List<TypeProjectionImpl> types = Collections.singletonList(new TypeProjectionImpl(projectionType, argument));
|
||||
return KotlinTypeFactory.simpleNotNullType(Annotations.Companion.getEMPTY(), getEnum(), types);
|
||||
return KotlinTypeFactory.simpleNotNullType(TypeAttributes.Companion.getEmpty(), getEnum(), types);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -53,7 +53,7 @@ class ReflectionTypes(module: ModuleDescriptor, private val notFoundClasses: Not
|
||||
val kMutableProperty2: ClassDescriptor by ClassLookup(3)
|
||||
|
||||
fun getKClassType(annotations: Annotations, type: KotlinType, variance: Variance): KotlinType =
|
||||
KotlinTypeFactory.simpleNotNullType(annotations, kClass, listOf(TypeProjectionImpl(variance, type)))
|
||||
KotlinTypeFactory.simpleNotNullType(annotations.toDefaultAttributes(), kClass, listOf(TypeProjectionImpl(variance, type)))
|
||||
|
||||
fun getKFunctionType(
|
||||
annotations: Annotations,
|
||||
@@ -69,7 +69,7 @@ class ReflectionTypes(module: ModuleDescriptor, private val notFoundClasses: Not
|
||||
getFunctionTypeArgumentProjections(receiverType, contextReceiverTypes, parameterTypes, parameterNames, returnType, builtIns)
|
||||
val classDescriptor =
|
||||
if (isSuspend) getKSuspendFunction(arguments.size - 1 /* return type */) else getKFunction(arguments.size - 1 /* return type */)
|
||||
return KotlinTypeFactory.simpleNotNullType(annotations, classDescriptor, arguments)
|
||||
return KotlinTypeFactory.simpleNotNullType(annotations.toDefaultAttributes(), classDescriptor, arguments)
|
||||
}
|
||||
|
||||
fun getKPropertyType(annotations: Annotations, receiverTypes: List<KotlinType>, returnType: KotlinType, mutable: Boolean): SimpleType {
|
||||
@@ -90,7 +90,7 @@ class ReflectionTypes(module: ModuleDescriptor, private val notFoundClasses: Not
|
||||
}
|
||||
|
||||
val arguments = (receiverTypes + returnType).map(::TypeProjectionImpl)
|
||||
return KotlinTypeFactory.simpleNotNullType(annotations, classDescriptor, arguments)
|
||||
return KotlinTypeFactory.simpleNotNullType(annotations.toDefaultAttributes(), classDescriptor, arguments)
|
||||
}
|
||||
|
||||
companion object {
|
||||
@@ -184,7 +184,7 @@ class ReflectionTypes(module: ModuleDescriptor, private val notFoundClasses: Not
|
||||
|
||||
fun createKPropertyStarType(module: ModuleDescriptor): KotlinType? {
|
||||
val kPropertyClass = module.findClassAcrossModuleDependencies(StandardNames.FqNames.kProperty) ?: return null
|
||||
return KotlinTypeFactory.simpleNotNullType(Annotations.EMPTY, kPropertyClass,
|
||||
return KotlinTypeFactory.simpleNotNullType(TypeAttributes.Empty, kPropertyClass,
|
||||
listOf(StarProjectionImpl(kPropertyClass.typeConstructor.parameters.single())))
|
||||
}
|
||||
|
||||
|
||||
@@ -257,7 +257,7 @@ fun createFunctionType(
|
||||
if (contextReceiverTypes.isNotEmpty()) typeAnnotations =
|
||||
typeAnnotations.withContextReceiversFunctionAnnotation(builtIns, contextReceiverTypes.size)
|
||||
|
||||
return KotlinTypeFactory.simpleNotNullType(typeAnnotations, classDescriptor, arguments)
|
||||
return KotlinTypeFactory.simpleNotNullType(typeAnnotations.toDefaultAttributes(), classDescriptor, arguments)
|
||||
}
|
||||
|
||||
fun Annotations.hasExtensionFunctionAnnotation() = hasAnnotation(StandardNames.FqNames.extensionFunctionType)
|
||||
|
||||
+1
-1
@@ -114,7 +114,7 @@ class FunctionClassDescriptor(
|
||||
TypeProjectionImpl(it.defaultType)
|
||||
}
|
||||
|
||||
KotlinTypeFactory.simpleNotNullType(Annotations.EMPTY, descriptor, arguments)
|
||||
KotlinTypeFactory.simpleNotNullType(TypeAttributes.Empty, descriptor, arguments)
|
||||
}.toList()
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ fun transformSuspendFunctionToRuntimeFunctionType(suspendFunType: KotlinType): S
|
||||
suspendFunType.getContextReceiverTypesFromFunctionType(),
|
||||
suspendFunType.getValueParameterTypesFromFunctionType().map(TypeProjection::getType) +
|
||||
KotlinTypeFactory.simpleType(
|
||||
Annotations.EMPTY,
|
||||
TypeAttributes.Empty,
|
||||
// Continuation interface is not a part of built-ins anymore, it has been moved to stdlib.
|
||||
// While it must be somewhere in the dependencies, but here we don't have a reference to the module,
|
||||
// and it's rather complicated to inject it by now, so we just use a fake class descriptor.
|
||||
|
||||
+1
-1
@@ -71,7 +71,7 @@ public abstract class AbstractTypeParameterDescriptor extends DeclarationDescrip
|
||||
@Override
|
||||
public SimpleType invoke() {
|
||||
return KotlinTypeFactory.simpleTypeWithNonTrivialMemberScope(
|
||||
Annotations.Companion.getEMPTY(),
|
||||
TypeAttributes.Companion.getEmpty(),
|
||||
getTypeConstructor(), Collections.<TypeProjection>emptyList(), false,
|
||||
new LazyScopeAdapter(
|
||||
new Function0<MemberScope>() {
|
||||
|
||||
+1
-1
@@ -143,7 +143,7 @@ public class LazySubstitutingClassDescriptor extends ModuleAwareClassDescriptor
|
||||
public SimpleType getDefaultType() {
|
||||
List<TypeProjection> typeProjections = TypeUtils.getDefaultTypeProjections(getTypeConstructor().getParameters());
|
||||
return KotlinTypeFactory.simpleTypeWithNonTrivialMemberScope(
|
||||
getAnnotations(),
|
||||
DefaultTypeAttributeTranslator.INSTANCE.toAttributes(getAnnotations(), null, null),
|
||||
getTypeConstructor(),
|
||||
typeProjections,
|
||||
false,
|
||||
|
||||
+4
-3
@@ -77,6 +77,10 @@ class CapturedType(
|
||||
override val isMarkedNullable: Boolean = false,
|
||||
override val attributes: TypeAttributes = TypeAttributes.Empty
|
||||
) : SimpleType(), SubtypingRepresentatives, CapturedTypeMarker {
|
||||
|
||||
override val annotations: Annotations
|
||||
get() = attributes.toDefaultAnnotations()
|
||||
|
||||
override val arguments: List<TypeProjection>
|
||||
get() = listOf()
|
||||
|
||||
@@ -103,9 +107,6 @@ class CapturedType(
|
||||
return CapturedType(typeProjection, constructor, newNullability, attributes)
|
||||
}
|
||||
|
||||
override fun replaceAnnotations(newAnnotations: Annotations): CapturedType =
|
||||
CapturedType(typeProjection, constructor, isMarkedNullable, newAnnotations.toDefaultAttributes())
|
||||
|
||||
override fun replaceAttributes(newAttributes: TypeAttributes): SimpleType =
|
||||
CapturedType(typeProjection, constructor, isMarkedNullable, newAttributes)
|
||||
|
||||
|
||||
@@ -21,10 +21,7 @@ import org.jetbrains.kotlin.builtins.StandardNames
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.descriptors.findClassAcrossModuleDependencies
|
||||
import org.jetbrains.kotlin.types.ErrorUtils
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.KotlinTypeFactory
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
import org.jetbrains.kotlin.types.*
|
||||
|
||||
interface CompileTimeConstant<out T> {
|
||||
val isError: Boolean
|
||||
@@ -200,7 +197,7 @@ class IntegerValueTypeConstant(
|
||||
}
|
||||
|
||||
val unknownIntegerType = KotlinTypeFactory.simpleTypeWithNonTrivialMemberScope(
|
||||
Annotations.EMPTY, typeConstructor, emptyList(), false,
|
||||
TypeAttributes.Empty, typeConstructor, emptyList(), false,
|
||||
ErrorUtils.createErrorScope("Scope for number value type ($typeConstructor)", true)
|
||||
)
|
||||
|
||||
|
||||
+2
-2
@@ -60,7 +60,7 @@ class IntegerLiteralTypeConstructor : TypeConstructor {
|
||||
Mode.INTERSECTION_TYPE -> left.possibleTypes union right.possibleTypes
|
||||
}
|
||||
val constructor = IntegerLiteralTypeConstructor(left.value, left.module, possibleTypes)
|
||||
return KotlinTypeFactory.integerLiteralType(Annotations.EMPTY, constructor, false)
|
||||
return KotlinTypeFactory.integerLiteralType(TypeAttributes.Empty, constructor, false)
|
||||
}
|
||||
|
||||
private fun fold(left: IntegerLiteralTypeConstructor, right: SimpleType): SimpleType? =
|
||||
@@ -127,7 +127,7 @@ class IntegerLiteralTypeConstructor : TypeConstructor {
|
||||
this.possibleTypes = possibleTypes
|
||||
}
|
||||
|
||||
private val type = KotlinTypeFactory.integerLiteralType(Annotations.EMPTY, this, false)
|
||||
private val type = KotlinTypeFactory.integerLiteralType(TypeAttributes.Empty, this, false)
|
||||
|
||||
private fun isContainsOnlyUnsignedTypes(): Boolean = module.allSignedLiteralTypes.all { it !in possibleTypes }
|
||||
|
||||
|
||||
@@ -180,7 +180,7 @@ class KClassValue(value: Value) : ConstantValue<KClassValue.Value>(value) {
|
||||
constructor(classId: ClassId, arrayDimensions: Int) : this(ClassLiteralValue(classId, arrayDimensions))
|
||||
|
||||
override fun getType(module: ModuleDescriptor): KotlinType =
|
||||
KotlinTypeFactory.simpleNotNullType(Annotations.EMPTY, module.builtIns.kClass, listOf(TypeProjectionImpl(getArgumentType(module))))
|
||||
KotlinTypeFactory.simpleNotNullType(TypeAttributes.Empty, module.builtIns.kClass, listOf(TypeProjectionImpl(getArgumentType(module))))
|
||||
|
||||
fun getArgumentType(module: ModuleDescriptor): KotlinType {
|
||||
when (value) {
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
class AnnotationsTypeAttribute(val annotations: Annotations) : TypeAttribute<AnnotationsTypeAttribute>() {
|
||||
constructor(annotations: List<AnnotationDescriptor>) : this(Annotations.create(annotations))
|
||||
|
||||
override fun union(other: AnnotationsTypeAttribute?): AnnotationsTypeAttribute? = null
|
||||
|
||||
override fun intersect(other: AnnotationsTypeAttribute?): AnnotationsTypeAttribute? = null
|
||||
|
||||
override fun add(other: AnnotationsTypeAttribute?): AnnotationsTypeAttribute {
|
||||
if (other == null) return this
|
||||
return AnnotationsTypeAttribute(Annotations.create(annotations + other.annotations))
|
||||
}
|
||||
|
||||
override fun isSubtypeOf(other: AnnotationsTypeAttribute?): Boolean = true
|
||||
|
||||
override val key: KClass<out AnnotationsTypeAttribute>
|
||||
get() = AnnotationsTypeAttribute::class
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (other !is AnnotationsTypeAttribute) return false
|
||||
return annotations == other.annotations
|
||||
}
|
||||
}
|
||||
|
||||
val TypeAttributes.annotationsAttribute: AnnotationsTypeAttribute? by TypeAttributes.attributeAccessor<AnnotationsTypeAttribute>()
|
||||
|
||||
val TypeAttributes.annotations: Annotations get() = annotationsAttribute?.annotations ?: Annotations.EMPTY
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* 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
|
||||
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptorImpl
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
class CustomAnnotationTypeAttribute(val annotations: Annotations) : TypeAttribute<CustomAnnotationTypeAttribute>() {
|
||||
constructor(annotations: List<AnnotationDescriptor>) : this(Annotations.create(annotations))
|
||||
|
||||
override fun union(other: CustomAnnotationTypeAttribute?): CustomAnnotationTypeAttribute? = null
|
||||
|
||||
override fun intersect(other: CustomAnnotationTypeAttribute?): CustomAnnotationTypeAttribute? = null
|
||||
|
||||
override fun add(other: CustomAnnotationTypeAttribute?): CustomAnnotationTypeAttribute {
|
||||
if (other == null) return this
|
||||
return CustomAnnotationTypeAttribute(Annotations.create(annotations + other.annotations))
|
||||
}
|
||||
|
||||
override fun isSubtypeOf(other: CustomAnnotationTypeAttribute?): Boolean = true
|
||||
|
||||
override val key: KClass<out CustomAnnotationTypeAttribute>
|
||||
get() = CustomAnnotationTypeAttribute::class
|
||||
}
|
||||
|
||||
val TypeAttributes.custom: CustomAnnotationTypeAttribute? by TypeAttributes.attributeAccessor<CustomAnnotationTypeAttribute>()
|
||||
|
||||
val TypeAttributes.customAnnotations: Annotations get() = custom?.annotations ?: Annotations.EMPTY
|
||||
@@ -36,8 +36,6 @@ open class ErrorType @JvmOverloads internal constructor(
|
||||
override fun toString(): String =
|
||||
constructor.toString() + if (arguments.isEmpty()) "" else arguments.joinToString(", ", "<", ">", -1, "...", null)
|
||||
|
||||
override fun replaceAnnotations(newAnnotations: Annotations): SimpleType = this
|
||||
|
||||
override fun replaceAttributes(newAttributes: TypeAttributes): SimpleType = this
|
||||
|
||||
override fun makeNullableAsSpecified(newNullability: Boolean): SimpleType =
|
||||
|
||||
@@ -77,7 +77,7 @@ class IntersectionTypeConstructor(typesToIntersect: Collection<KotlinType>) : Ty
|
||||
@OptIn(TypeRefinement::class)
|
||||
fun createType(): SimpleType =
|
||||
KotlinTypeFactory.simpleTypeWithNonTrivialMemberScope(
|
||||
Annotations.EMPTY, this, listOf(), false, this.createScopeForKotlinType()
|
||||
TypeAttributes.Empty, this, listOf(), false, this.createScopeForKotlinType()
|
||||
) { kotlinTypeRefiner ->
|
||||
this.refine(kotlinTypeRefiner).createType()
|
||||
}
|
||||
|
||||
@@ -52,8 +52,6 @@ sealed class KotlinType : Annotated, KotlinTypeMarker {
|
||||
abstract val isMarkedNullable: Boolean
|
||||
abstract val memberScope: MemberScope
|
||||
abstract val attributes: TypeAttributes
|
||||
override val annotations: Annotations
|
||||
get() = attributes.toDefaultAnnotations()
|
||||
|
||||
abstract fun unwrap(): UnwrappedType
|
||||
|
||||
@@ -163,7 +161,6 @@ abstract class WrappedType : KotlinType() {
|
||||
* todo: specify what happens with internal structure when we apply some [TypeSubstitutor]
|
||||
*/
|
||||
sealed class UnwrappedType : KotlinType() {
|
||||
abstract fun replaceAnnotations(newAnnotations: Annotations): UnwrappedType
|
||||
abstract fun replaceAttributes(newAttributes: TypeAttributes): UnwrappedType
|
||||
abstract fun makeNullableAsSpecified(newNullability: Boolean): UnwrappedType
|
||||
|
||||
@@ -179,7 +176,6 @@ sealed class UnwrappedType : KotlinType() {
|
||||
* Or more precisely, all instances are subclasses of [SimpleType] or [WrappedType] (which contains [SimpleType] inside).
|
||||
*/
|
||||
abstract class SimpleType : UnwrappedType(), SimpleTypeMarker, TypeArgumentListMarker {
|
||||
abstract override fun replaceAnnotations(newAnnotations: Annotations): SimpleType
|
||||
abstract override fun replaceAttributes(newAttributes: TypeAttributes): SimpleType
|
||||
abstract override fun makeNullableAsSpecified(newNullability: Boolean): SimpleType
|
||||
|
||||
|
||||
@@ -65,31 +65,6 @@ object KotlinTypeFactory {
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@JvmOverloads
|
||||
@OptIn(TypeRefinement::class)
|
||||
fun simpleType(
|
||||
annotations: Annotations,
|
||||
constructor: TypeConstructor,
|
||||
arguments: List<TypeProjection>,
|
||||
nullable: Boolean,
|
||||
kotlinTypeRefiner: KotlinTypeRefiner? = null
|
||||
): SimpleType {
|
||||
if (annotations.isEmpty() && arguments.isEmpty() && !nullable && constructor.declarationDescriptor != null) {
|
||||
return constructor.declarationDescriptor!!.defaultType
|
||||
}
|
||||
|
||||
return simpleTypeWithNonTrivialMemberScope(
|
||||
annotations, constructor, arguments, nullable,
|
||||
computeMemberScope(constructor, arguments, kotlinTypeRefiner)
|
||||
) f@{ refiner ->
|
||||
val expandedTypeOrRefinedConstructor = refineConstructor(constructor, refiner, arguments) ?: return@f null
|
||||
expandedTypeOrRefinedConstructor.expandedType?.let { return@f it }
|
||||
|
||||
simpleType(annotations, expandedTypeOrRefinedConstructor.refinedConstructor!!, arguments, nullable, refiner)
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@JvmOverloads
|
||||
@OptIn(TypeRefinement::class)
|
||||
@@ -118,7 +93,7 @@ object KotlinTypeFactory {
|
||||
@JvmStatic
|
||||
fun TypeAliasDescriptor.computeExpandedType(arguments: List<TypeProjection>): SimpleType {
|
||||
return TypeAliasExpander(TypeAliasExpansionReportStrategy.DO_NOTHING, false).expand(
|
||||
TypeAliasExpansion.create(null, this, arguments), Annotations.EMPTY
|
||||
TypeAliasExpansion.create(null, this, arguments), TypeAttributes.Empty
|
||||
)
|
||||
}
|
||||
|
||||
@@ -141,33 +116,6 @@ object KotlinTypeFactory {
|
||||
|
||||
private class ExpandedTypeOrRefinedConstructor(val expandedType: SimpleType?, val refinedConstructor: TypeConstructor?)
|
||||
|
||||
@JvmStatic
|
||||
@OptIn(TypeRefinement::class)
|
||||
fun simpleTypeWithNonTrivialMemberScope(
|
||||
annotations: Annotations,
|
||||
constructor: TypeConstructor,
|
||||
arguments: List<TypeProjection>,
|
||||
nullable: Boolean,
|
||||
memberScope: MemberScope
|
||||
): SimpleType =
|
||||
SimpleTypeImpl(constructor, arguments, nullable, memberScope) { kotlinTypeRefiner ->
|
||||
val expandedTypeOrRefinedConstructor = refineConstructor(constructor, kotlinTypeRefiner, arguments) ?: return@SimpleTypeImpl null
|
||||
expandedTypeOrRefinedConstructor.expandedType?.let { return@SimpleTypeImpl it }
|
||||
|
||||
simpleTypeWithNonTrivialMemberScope(
|
||||
annotations,
|
||||
expandedTypeOrRefinedConstructor.refinedConstructor!!,
|
||||
arguments,
|
||||
nullable,
|
||||
memberScope
|
||||
)
|
||||
}.let {
|
||||
if (annotations.isEmpty())
|
||||
it
|
||||
else
|
||||
SimpleTypeWithAttributes(it, annotations.toDefaultAttributes())
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@OptIn(TypeRefinement::class)
|
||||
fun simpleTypeWithNonTrivialMemberScope(
|
||||
@@ -195,23 +143,6 @@ object KotlinTypeFactory {
|
||||
SimpleTypeWithAttributes(it, attributes)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun simpleTypeWithNonTrivialMemberScope(
|
||||
annotations: Annotations,
|
||||
constructor: TypeConstructor,
|
||||
arguments: List<TypeProjection>,
|
||||
nullable: Boolean,
|
||||
memberScope: MemberScope,
|
||||
refinedTypeFactory: RefinedTypeFactory
|
||||
): SimpleType =
|
||||
SimpleTypeImpl(constructor, arguments, nullable, memberScope, refinedTypeFactory)
|
||||
.let {
|
||||
if (annotations.isEmpty())
|
||||
it
|
||||
else
|
||||
SimpleTypeWithAttributes(it, annotations.toDefaultAttributes())
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun simpleTypeWithNonTrivialMemberScope(
|
||||
attributes: TypeAttributes,
|
||||
@@ -229,13 +160,6 @@ object KotlinTypeFactory {
|
||||
SimpleTypeWithAttributes(it, attributes)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun simpleNotNullType(
|
||||
annotations: Annotations,
|
||||
descriptor: ClassDescriptor,
|
||||
arguments: List<TypeProjection>
|
||||
): SimpleType = simpleType(annotations, descriptor.typeConstructor, arguments, nullable = false)
|
||||
|
||||
@JvmStatic
|
||||
fun simpleNotNullType(
|
||||
attributes: TypeAttributes,
|
||||
@@ -246,7 +170,7 @@ object KotlinTypeFactory {
|
||||
@JvmStatic
|
||||
fun simpleType(
|
||||
baseType: SimpleType,
|
||||
annotations: Annotations = baseType.annotations,
|
||||
annotations: TypeAttributes = baseType.attributes,
|
||||
constructor: TypeConstructor = baseType.constructor,
|
||||
arguments: List<TypeProjection> = baseType.arguments,
|
||||
nullable: Boolean = baseType.isMarkedNullable
|
||||
@@ -260,11 +184,11 @@ object KotlinTypeFactory {
|
||||
|
||||
@JvmStatic
|
||||
fun integerLiteralType(
|
||||
annotations: Annotations,
|
||||
attributes: TypeAttributes,
|
||||
constructor: IntegerLiteralTypeConstructor,
|
||||
nullable: Boolean
|
||||
): SimpleType = simpleTypeWithNonTrivialMemberScope(
|
||||
annotations,
|
||||
attributes,
|
||||
constructor,
|
||||
emptyList(),
|
||||
nullable,
|
||||
@@ -290,12 +214,6 @@ private class SimpleTypeImpl(
|
||||
this
|
||||
else SimpleTypeWithAttributes(this, newAttributes)
|
||||
|
||||
override fun replaceAnnotations(newAnnotations: Annotations) =
|
||||
if (newAnnotations.isEmpty())
|
||||
this
|
||||
else
|
||||
SimpleTypeWithAttributes(this, attributes.replaceAnnotations(newAnnotations))
|
||||
|
||||
override fun makeNullableAsSpecified(newNullability: Boolean) = when {
|
||||
newNullability == isMarkedNullable -> this
|
||||
newNullability -> NullableSimpleType(this)
|
||||
@@ -322,9 +240,6 @@ class SupposititiousSimpleType(private val realType: SimpleType, val overwritten
|
||||
else SupposititiousSimpleType(newType, overwrittenClass)
|
||||
}
|
||||
|
||||
override fun replaceAnnotations(newAnnotations: Annotations): SimpleType =
|
||||
maybeWrap(realType.replaceAnnotations(newAnnotations))
|
||||
|
||||
override fun replaceAttributes(newAttributes: TypeAttributes): SimpleType =
|
||||
maybeWrap(realType.replaceAttributes(newAttributes))
|
||||
|
||||
@@ -350,15 +265,9 @@ abstract class DelegatingSimpleTypeImpl(override val delegate: SimpleType) : Del
|
||||
else
|
||||
this
|
||||
|
||||
override fun replaceAnnotations(newAnnotations: Annotations) =
|
||||
if (newAnnotations !== annotations)
|
||||
SimpleTypeWithAttributes(this, attributes.replaceAnnotations(newAnnotations))
|
||||
else
|
||||
this
|
||||
|
||||
override fun makeNullableAsSpecified(newNullability: Boolean): SimpleType {
|
||||
if (newNullability == isMarkedNullable) return this
|
||||
return delegate.makeNullableAsSpecified(newNullability).replaceAnnotations(annotations)
|
||||
return delegate.makeNullableAsSpecified(newNullability).replaceAttributes(attributes)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -366,6 +275,8 @@ private class SimpleTypeWithAttributes(
|
||||
delegate: SimpleType,
|
||||
override val attributes: TypeAttributes
|
||||
) : DelegatingSimpleTypeImpl(delegate) {
|
||||
override val annotations: Annotations
|
||||
get() = attributes.toDefaultAnnotations()
|
||||
@TypeRefinement
|
||||
override fun replaceDelegate(delegate: SimpleType) = SimpleTypeWithAttributes(delegate, attributes)
|
||||
}
|
||||
|
||||
@@ -48,9 +48,6 @@ abstract class DelegatingSimpleType : SimpleType() {
|
||||
class AbbreviatedType(override val delegate: SimpleType, val abbreviation: SimpleType) : DelegatingSimpleType() {
|
||||
val expandedType: SimpleType get() = delegate
|
||||
|
||||
override fun replaceAnnotations(newAnnotations: Annotations) =
|
||||
AbbreviatedType(delegate.replaceAnnotations(newAnnotations), abbreviation)
|
||||
|
||||
override fun replaceAttributes(newAttributes: TypeAttributes): SimpleType =
|
||||
AbbreviatedType(delegate.replaceAttributes(newAttributes), abbreviation)
|
||||
|
||||
@@ -172,9 +169,6 @@ class DefinitelyNotNullType private constructor(
|
||||
override fun substitutionResult(replacement: KotlinType): KotlinType =
|
||||
replacement.unwrap().makeDefinitelyNotNullOrNotNull(useCorrectedNullabilityForTypeParameters)
|
||||
|
||||
override fun replaceAnnotations(newAnnotations: Annotations): DefinitelyNotNullType =
|
||||
DefinitelyNotNullType(delegate.replaceAnnotations(newAnnotations), useCorrectedNullabilityForTypeParameters)
|
||||
|
||||
override fun replaceAttributes(newAttributes: TypeAttributes): SimpleType =
|
||||
DefinitelyNotNullType(delegate.replaceAttributes(newAttributes), useCorrectedNullabilityForTypeParameters)
|
||||
|
||||
|
||||
@@ -64,8 +64,6 @@ abstract class AbstractStubType(val originalTypeVariable: TypeConstructor, overr
|
||||
override val attributes: TypeAttributes
|
||||
get() = TypeAttributes.Empty
|
||||
|
||||
override fun replaceAnnotations(newAnnotations: Annotations): SimpleType = this
|
||||
|
||||
override fun replaceAttributes(newAttributes: TypeAttributes): SimpleType = this
|
||||
|
||||
override fun makeNullableAsSpecified(newNullability: Boolean): SimpleType {
|
||||
|
||||
@@ -10,7 +10,6 @@ import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.descriptors.annotations.composeAnnotations
|
||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
|
||||
import org.jetbrains.kotlin.types.typeUtil.containsTypeAliasParameters
|
||||
import org.jetbrains.kotlin.types.typeUtil.requiresTypeAliasExpansion
|
||||
|
||||
@@ -19,21 +18,21 @@ class TypeAliasExpander(
|
||||
private val shouldCheckBounds: Boolean
|
||||
) {
|
||||
|
||||
fun expand(typeAliasExpansion: TypeAliasExpansion, annotations: Annotations) =
|
||||
fun expand(typeAliasExpansion: TypeAliasExpansion, attributes: TypeAttributes) =
|
||||
expandRecursively(
|
||||
typeAliasExpansion, annotations,
|
||||
typeAliasExpansion, attributes,
|
||||
isNullable = false, recursionDepth = 0, withAbbreviatedType = true
|
||||
)
|
||||
|
||||
fun expandWithoutAbbreviation(typeAliasExpansion: TypeAliasExpansion, annotations: Annotations) =
|
||||
fun expandWithoutAbbreviation(typeAliasExpansion: TypeAliasExpansion, attributes: TypeAttributes) =
|
||||
expandRecursively(
|
||||
typeAliasExpansion, annotations,
|
||||
typeAliasExpansion, attributes,
|
||||
isNullable = false, recursionDepth = 0, withAbbreviatedType = false
|
||||
)
|
||||
|
||||
private fun expandRecursively(
|
||||
typeAliasExpansion: TypeAliasExpansion,
|
||||
annotations: Annotations,
|
||||
attributes: TypeAttributes,
|
||||
isNullable: Boolean,
|
||||
recursionDepth: Int,
|
||||
withAbbreviatedType: Boolean
|
||||
@@ -51,19 +50,19 @@ class TypeAliasExpander(
|
||||
"Type alias expansion: result for ${typeAliasExpansion.descriptor} is ${expandedProjection.projectionKind}, should be invariant"
|
||||
}
|
||||
|
||||
checkRepeatedAnnotations(expandedType.annotations, annotations)
|
||||
checkRepeatedAnnotations(expandedType.annotations, attributes.annotations)
|
||||
val expandedTypeWithExtraAnnotations =
|
||||
expandedType.combineAnnotations(annotations).let { TypeUtils.makeNullableIfNeeded(it, isNullable) }
|
||||
expandedType.combineAttributes(attributes).let { TypeUtils.makeNullableIfNeeded(it, isNullable) }
|
||||
|
||||
return if (withAbbreviatedType)
|
||||
expandedTypeWithExtraAnnotations.withAbbreviation(typeAliasExpansion.createAbbreviation(annotations, isNullable))
|
||||
expandedTypeWithExtraAnnotations.withAbbreviation(typeAliasExpansion.createAbbreviation(attributes, isNullable))
|
||||
else
|
||||
expandedTypeWithExtraAnnotations
|
||||
}
|
||||
|
||||
private fun TypeAliasExpansion.createAbbreviation(annotations: Annotations, isNullable: Boolean) =
|
||||
private fun TypeAliasExpansion.createAbbreviation(attributes: TypeAttributes, isNullable: Boolean) =
|
||||
KotlinTypeFactory.simpleTypeWithNonTrivialMemberScope(
|
||||
annotations,
|
||||
attributes,
|
||||
descriptor.typeConstructor,
|
||||
arguments,
|
||||
isNullable,
|
||||
@@ -125,23 +124,23 @@ class TypeAliasExpander(
|
||||
|
||||
val substitutedType =
|
||||
if (argumentType is DynamicType)
|
||||
argumentType.combineAnnotations(underlyingType.annotations)
|
||||
argumentType.combineAttributes(underlyingType.attributes)
|
||||
else
|
||||
argumentType.asSimpleType().combineNullabilityAndAnnotations(underlyingType)
|
||||
|
||||
return TypeProjectionImpl(resultingVariance, substitutedType)
|
||||
}
|
||||
|
||||
private fun DynamicType.combineAnnotations(newAnnotations: Annotations): DynamicType =
|
||||
replaceAnnotations(createCombinedAnnotations(newAnnotations))
|
||||
private fun DynamicType.combineAttributes(newAttributes: TypeAttributes): DynamicType =
|
||||
replaceAttributes(createdCombinedAttributes(newAttributes))
|
||||
|
||||
private fun SimpleType.combineAnnotations(newAnnotations: Annotations): SimpleType =
|
||||
if (isError) this else replace(newAnnotations = createCombinedAnnotations(newAnnotations))
|
||||
private fun SimpleType.combineAttributes(newAttributes: TypeAttributes): SimpleType =
|
||||
if (isError) this else replaceAttributes(newAttributes = createdCombinedAttributes(newAttributes))
|
||||
|
||||
private fun KotlinType.createCombinedAnnotations(newAnnotations: Annotations): Annotations {
|
||||
if (isError) return annotations
|
||||
private fun KotlinType.createdCombinedAttributes(newAttributes: TypeAttributes): TypeAttributes {
|
||||
if (isError) return attributes
|
||||
|
||||
return composeAnnotations(newAnnotations, annotations)
|
||||
return newAttributes.add(attributes)
|
||||
}
|
||||
|
||||
private fun checkRepeatedAnnotations(existingAnnotations: Annotations, newAnnotations: Annotations) {
|
||||
@@ -158,7 +157,7 @@ class TypeAliasExpander(
|
||||
TypeUtils.makeNullableIfNeeded(this, fromType.isMarkedNullable)
|
||||
|
||||
private fun SimpleType.combineNullabilityAndAnnotations(fromType: KotlinType) =
|
||||
combineNullability(fromType).combineAnnotations(fromType.annotations)
|
||||
combineNullability(fromType).combineAttributes(fromType.attributes)
|
||||
|
||||
private fun expandNonArgumentTypeProjection(
|
||||
originalProjection: TypeProjection,
|
||||
@@ -201,7 +200,7 @@ class TypeAliasExpander(
|
||||
TypeAliasExpansion.create(typeAliasExpansion, typeDescriptor, expandedArguments)
|
||||
|
||||
val nestedExpandedType = expandRecursively(
|
||||
nestedExpansion, type.annotations,
|
||||
nestedExpansion, type.attributes,
|
||||
isNullable = type.isMarkedNullable,
|
||||
recursionDepth = recursionDepth + 1,
|
||||
withAbbreviatedType = false
|
||||
|
||||
@@ -5,19 +5,29 @@
|
||||
|
||||
package org.jetbrains.kotlin.types
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
|
||||
interface TypeAttributeTranslator {
|
||||
fun toAttributes(annotations: Annotations): TypeAttributes
|
||||
fun toAttributes(
|
||||
annotations: Annotations,
|
||||
typeConstructor: TypeConstructor? = null,
|
||||
containingDeclaration: DeclarationDescriptor? = null
|
||||
): TypeAttributes
|
||||
|
||||
fun toAnnotations(attributes: TypeAttributes): Annotations
|
||||
}
|
||||
|
||||
object DefaultTypeAttributeTranslator : TypeAttributeTranslator {
|
||||
override fun toAnnotations(attributes: TypeAttributes): Annotations {
|
||||
return attributes.customAnnotations
|
||||
override fun toAttributes(
|
||||
annotations: Annotations,
|
||||
typeConstructor: TypeConstructor?,
|
||||
containingDeclaration: DeclarationDescriptor?
|
||||
): TypeAttributes {
|
||||
return TypeAttributes.create(listOf(AnnotationsTypeAttribute(annotations)))
|
||||
}
|
||||
|
||||
override fun toAttributes(annotations: Annotations): TypeAttributes {
|
||||
return TypeAttributes.create(listOf(CustomAnnotationTypeAttribute(annotations)))
|
||||
override fun toAnnotations(attributes: TypeAttributes): Annotations {
|
||||
return attributes.annotations
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,9 +41,7 @@ class TypeAttributes private constructor(attributes: List<TypeAttribute<*>>) : A
|
||||
return generateNullableAccessor<TypeAttribute<*>, T>(T::class) as ReadOnlyProperty<TypeAttributes, T?>
|
||||
}
|
||||
|
||||
val Empty: TypeAttributes = TypeAttributes(emptyList())
|
||||
|
||||
private fun TypeAttribute<*>.predefined(): Pair<TypeAttribute<*>, TypeAttributes> = this to TypeAttributes(this)
|
||||
val Empty: TypeAttributes = TypeAttributes(listOf(AnnotationsTypeAttribute(Annotations.EMPTY)))
|
||||
|
||||
fun create(attributes: List<TypeAttribute<*>>): TypeAttributes {
|
||||
return if (attributes.isEmpty()) {
|
||||
@@ -119,6 +117,6 @@ fun TypeAttributes.toDefaultAnnotations(): Annotations =
|
||||
fun Annotations.toDefaultAttributes(): TypeAttributes = DefaultTypeAttributeTranslator.toAttributes(this)
|
||||
|
||||
fun TypeAttributes.replaceAnnotations(newAnnotations: Annotations): TypeAttributes {
|
||||
val withoutCustom = (custom?.let { this.remove(it) } ?: this)
|
||||
val withoutCustom = (annotationsAttribute?.let { this.remove(it) } ?: this)
|
||||
return withoutCustom.add(newAnnotations.toDefaultAttributes())
|
||||
}
|
||||
|
||||
@@ -160,12 +160,14 @@ fun SimpleType.replace(
|
||||
): SimpleType {
|
||||
if (newArguments.isEmpty() && newAnnotations === annotations) return this
|
||||
|
||||
val newAttributes = attributes.replaceAnnotations(newAnnotations)
|
||||
|
||||
if (newArguments.isEmpty()) {
|
||||
return replaceAnnotations(newAnnotations)
|
||||
return replaceAttributes(newAttributes)
|
||||
}
|
||||
|
||||
return KotlinTypeFactory.simpleType(
|
||||
newAnnotations,
|
||||
newAttributes,
|
||||
constructor,
|
||||
newArguments,
|
||||
isMarkedNullable
|
||||
|
||||
@@ -46,12 +46,6 @@ public class TypeUtils {
|
||||
throw new IllegalStateException(name);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public SimpleType replaceAnnotations(@NotNull Annotations newAnnotations) {
|
||||
throw new IllegalStateException(name);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public SimpleType replaceAttributes(@NotNull TypeAttributes newAttributes) {
|
||||
@@ -227,7 +221,7 @@ public class TypeUtils {
|
||||
) {
|
||||
List<TypeProjection> arguments = getDefaultTypeProjections(typeConstructor.getParameters());
|
||||
return KotlinTypeFactory.simpleTypeWithNonTrivialMemberScope(
|
||||
Annotations.Companion.getEMPTY(),
|
||||
TypeAttributes.Companion.getEmpty(),
|
||||
typeConstructor,
|
||||
arguments,
|
||||
false,
|
||||
|
||||
@@ -118,7 +118,7 @@ fun TypeProjection.substitute(doSubstitute: (KotlinType) -> KotlinType): TypePro
|
||||
|
||||
fun KotlinType.replaceAnnotations(newAnnotations: Annotations): KotlinType {
|
||||
if (annotations.isEmpty() && newAnnotations.isEmpty()) return this
|
||||
return unwrap().replaceAnnotations(newAnnotations)
|
||||
return unwrap().replaceAttributes(attributes.replaceAnnotations(newAnnotations))
|
||||
}
|
||||
|
||||
fun KotlinTypeChecker.equalTypesOrNulls(type1: KotlinType?, type2: KotlinType?): Boolean {
|
||||
|
||||
@@ -34,9 +34,6 @@ class SimpleTypeWithEnhancement(
|
||||
|
||||
override val origin get() = delegate
|
||||
|
||||
override fun replaceAnnotations(newAnnotations: Annotations): SimpleType =
|
||||
origin.replaceAnnotations(newAnnotations).wrapEnhancement(enhancement) as SimpleType
|
||||
|
||||
override fun replaceAttributes(newAttributes: TypeAttributes): SimpleType =
|
||||
origin.replaceAttributes(newAttributes).wrapEnhancement(enhancement) as SimpleType
|
||||
|
||||
@@ -64,9 +61,6 @@ class FlexibleTypeWithEnhancement(
|
||||
) : FlexibleType(origin.lowerBound, origin.upperBound),
|
||||
TypeWithEnhancement {
|
||||
|
||||
override fun replaceAnnotations(newAnnotations: Annotations): UnwrappedType =
|
||||
origin.replaceAnnotations(newAnnotations).wrapEnhancement(enhancement)
|
||||
|
||||
override fun replaceAttributes(newAttributes: TypeAttributes): UnwrappedType =
|
||||
origin.replaceAttributes(newAttributes).wrapEnhancement(enhancement)
|
||||
|
||||
|
||||
@@ -641,17 +641,15 @@ interface ClassicTypeSystemContext : TypeSystemInferenceExtensionContext, TypeSy
|
||||
|
||||
override fun unionTypeAttributes(types: List<KotlinTypeMarker>): List<AnnotationMarker> {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
types as List<KotlinType>
|
||||
return types.map { it.unwrap().attributes }.reduce { x, y -> x.union(y) }.toList()
|
||||
return (types as List<KotlinType>).map { it.unwrap().attributes }.reduce { x, y -> x.union(y) }.toList()
|
||||
}
|
||||
|
||||
override fun KotlinTypeMarker.replaceTypeAttributes(newAttributes: List<AnnotationMarker>): KotlinTypeMarker {
|
||||
require(this is KotlinType)
|
||||
val typeAttributes = newAttributes.filterIsInstance<TypeAttribute<*>>()
|
||||
require(typeAttributes.size == newAttributes.size)
|
||||
if (newAttributes.isEmpty()) return this
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return this.unwrap().replaceAttributes(
|
||||
TypeAttributes.create(typeAttributes)
|
||||
TypeAttributes.create(newAttributes as List<TypeAttribute<*>>)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -675,6 +673,11 @@ interface ClassicTypeSystemContext : TypeSystemInferenceExtensionContext, TypeSy
|
||||
return this.attributes.toList()
|
||||
}
|
||||
|
||||
override fun KotlinTypeMarker.getCustomAttributes(): List<AnnotationMarker> {
|
||||
require(this is KotlinType, this::errorMessage)
|
||||
return this.attributes.filterNot { it is AnnotationsTypeAttribute }
|
||||
}
|
||||
|
||||
override fun captureFromExpression(type: KotlinTypeMarker): KotlinTypeMarker? {
|
||||
return captureFromExpressionInternal(type as UnwrappedType)
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ abstract class KotlinTypePreparator : AbstractTypePreparator() {
|
||||
val newConstructor =
|
||||
IntersectionTypeConstructor(constructor.supertypes.map { TypeUtils.makeNullableAsSpecified(it, type.isMarkedNullable) })
|
||||
return KotlinTypeFactory.simpleTypeWithNonTrivialMemberScope(
|
||||
type.annotations,
|
||||
type.attributes,
|
||||
newConstructor,
|
||||
listOf(),
|
||||
false,
|
||||
|
||||
@@ -144,7 +144,7 @@ private fun captureFromArguments(type: UnwrappedType, status: CaptureStatus): Un
|
||||
}
|
||||
|
||||
private fun UnwrappedType.replaceArguments(arguments: List<TypeProjection>) =
|
||||
KotlinTypeFactory.simpleType(annotations, constructor, arguments, isMarkedNullable)
|
||||
KotlinTypeFactory.simpleType(attributes, constructor, arguments, isMarkedNullable)
|
||||
|
||||
private fun captureArguments(type: UnwrappedType, status: CaptureStatus): List<TypeProjection>? {
|
||||
if (type.arguments.size != type.constructor.parameters.size) return null
|
||||
@@ -207,14 +207,14 @@ class NewCapturedType(
|
||||
captureStatus: CaptureStatus, lowerType: UnwrappedType?, projection: TypeProjection, typeParameter: TypeParameterDescriptor
|
||||
) : this(captureStatus, NewCapturedTypeConstructor(projection, typeParameter = typeParameter), lowerType)
|
||||
|
||||
override val annotations: Annotations
|
||||
get() = attributes.toDefaultAnnotations()
|
||||
|
||||
override val arguments: List<TypeProjection> get() = listOf()
|
||||
|
||||
override val memberScope: MemberScope // todo what about foo().bar() where foo() return captured type?
|
||||
get() = ErrorUtils.createErrorScope("No member resolution should be done on captured type!", true)
|
||||
|
||||
override fun replaceAnnotations(newAnnotations: Annotations) =
|
||||
NewCapturedType(captureStatus, constructor, lowerType, newAnnotations.toDefaultAttributes(), isMarkedNullable)
|
||||
|
||||
override fun replaceAttributes(newAttributes: TypeAttributes): SimpleType =
|
||||
NewCapturedType(captureStatus, constructor, lowerType, newAttributes, isMarkedNullable)
|
||||
|
||||
|
||||
@@ -52,9 +52,6 @@ class DynamicType(
|
||||
|
||||
override val isMarkedNullable: Boolean get() = false
|
||||
|
||||
override fun replaceAnnotations(newAnnotations: Annotations): DynamicType =
|
||||
DynamicType(delegate.builtIns, attributes.replaceAnnotations(newAnnotations))
|
||||
|
||||
override fun replaceAttributes(newAttributes: TypeAttributes): DynamicType =
|
||||
DynamicType(delegate.builtIns, newAttributes)
|
||||
|
||||
|
||||
+11
-2
@@ -6,20 +6,29 @@
|
||||
package org.jetbrains.kotlin.types.extensions
|
||||
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.extensions.ProjectExtensionDescriptor
|
||||
import org.jetbrains.kotlin.types.*
|
||||
|
||||
interface TypeAttributeTranslatorExtension : TypeAttributeTranslator
|
||||
|
||||
class TypeAttributeTranslatorsForInjection(project: Project) {
|
||||
val translators: List<TypeAttributeTranslator> = TypeAttributeTranslators(project).translators
|
||||
}
|
||||
|
||||
class TypeAttributeTranslators private constructor(val translators: List<TypeAttributeTranslator>) {
|
||||
|
||||
constructor(project: Project) : this(getInstances(project) + DefaultTypeAttributeTranslator)
|
||||
|
||||
|
||||
fun toAttributes(annotations: Annotations): TypeAttributes {
|
||||
fun toAttributes(
|
||||
annotations: Annotations,
|
||||
typeConstructor: TypeConstructor,
|
||||
containingDeclaration: DeclarationDescriptor? = null
|
||||
): TypeAttributes {
|
||||
val translated = translators.map { translator ->
|
||||
translator.toAttributes(annotations)
|
||||
translator.toAttributes(annotations, typeConstructor, containingDeclaration)
|
||||
}.flatten()
|
||||
return TypeAttributes.create(translated)
|
||||
}
|
||||
|
||||
@@ -125,9 +125,6 @@ class FlexibleTypeImpl(lowerBound: SimpleType, upperBound: SimpleType) : Flexibl
|
||||
}.inheritEnhancement(unwrapped)
|
||||
}
|
||||
|
||||
override fun replaceAnnotations(newAnnotations: Annotations): UnwrappedType =
|
||||
KotlinTypeFactory.flexibleType(lowerBound.replaceAnnotations(newAnnotations), upperBound.replaceAnnotations(newAnnotations))
|
||||
|
||||
override fun replaceAttributes(newAttributes: TypeAttributes): UnwrappedType =
|
||||
KotlinTypeFactory.flexibleType(lowerBound.replaceAttributes(newAttributes), upperBound.replaceAttributes(newAttributes))
|
||||
|
||||
|
||||
+3
-3
@@ -34,7 +34,7 @@ import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
||||
import org.jetbrains.kotlin.serialization.deserialization.builtins.BuiltInSerializerProtocol
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedPackageMemberScope
|
||||
import org.jetbrains.kotlin.storage.StorageManager
|
||||
import org.jetbrains.kotlin.types.TypeAttributeTranslator
|
||||
import org.jetbrains.kotlin.types.extensions.TypeAttributeTranslatorsForInjection
|
||||
import org.jetbrains.kotlin.types.checker.NewKotlinTypeChecker
|
||||
import java.io.InputStream
|
||||
|
||||
@@ -47,7 +47,7 @@ class MetadataPackageFragmentProvider(
|
||||
contractDeserializer: ContractDeserializer,
|
||||
kotlinTypeChecker: NewKotlinTypeChecker,
|
||||
samConversionResolver: SamConversionResolver,
|
||||
typeAttributeTranslators: List<TypeAttributeTranslator>
|
||||
typeAttributeTranslators: TypeAttributeTranslatorsForInjection
|
||||
) : AbstractDeserializedPackageFragmentProvider(storageManager, finder, moduleDescriptor) {
|
||||
init {
|
||||
components = DeserializationComponents(
|
||||
@@ -68,7 +68,7 @@ class MetadataPackageFragmentProvider(
|
||||
BuiltInSerializerProtocol.extensionRegistry,
|
||||
kotlinTypeChecker,
|
||||
samConversionResolver,
|
||||
typeAttributeTranslators = typeAttributeTranslators
|
||||
typeAttributeTranslators = typeAttributeTranslators.translators
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
+10
-4
@@ -67,9 +67,13 @@ class TypeDeserializer(
|
||||
return simpleType(proto, expandTypeAliases = true)
|
||||
}
|
||||
|
||||
private fun List<TypeAttributeTranslator>.toAttributes(annotations: Annotations): TypeAttributes {
|
||||
private fun List<TypeAttributeTranslator>.toAttributes(
|
||||
annotations: Annotations,
|
||||
constructor: TypeConstructor,
|
||||
containingDeclaration: DeclarationDescriptor
|
||||
): TypeAttributes {
|
||||
val translated = this.map { translator ->
|
||||
translator.toAttributes(annotations)
|
||||
translator.toAttributes(annotations, constructor, containingDeclaration)
|
||||
}.flatten()
|
||||
return TypeAttributes.create(translated)
|
||||
}
|
||||
@@ -92,7 +96,7 @@ class TypeDeserializer(
|
||||
c.components.annotationAndConstantLoader.loadTypeAnnotations(proto, c.nameResolver)
|
||||
}
|
||||
|
||||
val attributes = c.components.typeAttributeTranslators.toAttributes(annotations)
|
||||
val attributes = c.components.typeAttributeTranslators.toAttributes(annotations, constructor, c.containingDeclaration)
|
||||
|
||||
fun ProtoBuf.Type.collectAllArguments(): List<ProtoBuf.Type.Argument> =
|
||||
argumentList + outerType(c.typeTable)?.collectAllArguments().orEmpty()
|
||||
@@ -107,7 +111,9 @@ class TypeDeserializer(
|
||||
expandTypeAliases && declarationDescriptor is TypeAliasDescriptor -> {
|
||||
val expandedType = with(KotlinTypeFactory) { declarationDescriptor.computeExpandedType(arguments) }
|
||||
val expandedAttributes = c.components.typeAttributeTranslators.toAttributes(
|
||||
Annotations.create(annotations + expandedType.annotations)
|
||||
Annotations.create(annotations + expandedType.annotations),
|
||||
constructor,
|
||||
c.containingDeclaration
|
||||
)
|
||||
expandedType
|
||||
.makeNullableAsSpecified(expandedType.isNullable() || proto.nullable)
|
||||
|
||||
@@ -56,18 +56,18 @@ fun KClassifier.createType(
|
||||
|
||||
// TODO: throw exception if argument does not satisfy bounds
|
||||
|
||||
val typeAnnotations =
|
||||
if (annotations.isEmpty()) Annotations.EMPTY
|
||||
else Annotations.EMPTY // TODO: support type annotations
|
||||
val typeAttributes =
|
||||
if (annotations.isEmpty()) TypeAttributes.Empty
|
||||
else TypeAttributes.Empty // TODO: support type annotations
|
||||
|
||||
return KTypeImpl(createKotlinType(typeAnnotations, typeConstructor, arguments, nullable))
|
||||
return KTypeImpl(createKotlinType(typeAttributes, typeConstructor, arguments, nullable))
|
||||
}
|
||||
|
||||
private fun createKotlinType(
|
||||
typeAnnotations: Annotations, typeConstructor: TypeConstructor, arguments: List<KTypeProjection>, nullable: Boolean
|
||||
attributes: TypeAttributes, typeConstructor: TypeConstructor, arguments: List<KTypeProjection>, nullable: Boolean
|
||||
): SimpleType {
|
||||
val parameters = typeConstructor.parameters
|
||||
return KotlinTypeFactory.simpleType(typeAnnotations, typeConstructor, arguments.mapIndexed { index, typeProjection ->
|
||||
return KotlinTypeFactory.simpleType(attributes, typeConstructor, arguments.mapIndexed { index, typeProjection ->
|
||||
val type = (typeProjection.type as KTypeImpl?)?.type
|
||||
when (typeProjection.variance) {
|
||||
KVariance.INVARIANT -> TypeProjectionImpl(Variance.INVARIANT, type!!)
|
||||
|
||||
+2
-5
@@ -30,10 +30,7 @@ import org.jetbrains.kotlin.resolve.DescriptorFactory
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameUnsafe
|
||||
import org.jetbrains.kotlin.resolve.source.PsiSourceElement
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.KotlinTypeFactory
|
||||
import org.jetbrains.kotlin.types.SimpleType
|
||||
import org.jetbrains.kotlin.types.StarProjectionImpl
|
||||
import org.jetbrains.kotlin.types.*
|
||||
|
||||
private class XmlSourceElement(override val psi: PsiElement) : PsiSourceElement
|
||||
|
||||
@@ -70,7 +67,7 @@ internal fun genPropertyForWidget(
|
||||
}
|
||||
else {
|
||||
KotlinTypeFactory.simpleNotNullType(
|
||||
Annotations.EMPTY, classDescriptor, defaultType.constructor.parameters.map(::StarProjectionImpl))
|
||||
TypeAttributes.Empty, classDescriptor, defaultType.constructor.parameters.map(::StarProjectionImpl))
|
||||
}
|
||||
} ?: context.view
|
||||
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@ internal fun ClassDescriptor.createSerializerTypeFor(argument: SimpleType, baseS
|
||||
val types = listOf(TypeProjectionImpl(projectionType, argument))
|
||||
val descriptor = module.findClassAcrossModuleDependencies(ClassId.topLevel(baseSerializerInterface))
|
||||
?: throw IllegalArgumentException("Can't locate $baseSerializerInterface. Is kotlinx-serialization library present in compile classpath?")
|
||||
return KotlinTypeFactory.simpleNotNullType(Annotations.EMPTY, descriptor, types)
|
||||
return KotlinTypeFactory.simpleNotNullType(TypeAttributes.Empty, descriptor, types)
|
||||
}
|
||||
|
||||
internal fun extractKSerializerArgumentFromImplementation(implementationClass: ClassDescriptor): KotlinType? {
|
||||
|
||||
+8
-8
@@ -58,7 +58,7 @@ object KSerializerDescriptorResolver {
|
||||
if (!classDescriptor.needSerializerFactory()) return
|
||||
val serializerFactoryClass =
|
||||
classDescriptor.module.getClassFromInternalSerializationPackage("SerializerFactory")
|
||||
supertypes.add(KotlinTypeFactory.simpleNotNullType(Annotations.EMPTY, serializerFactoryClass, listOf()))
|
||||
supertypes.add(KotlinTypeFactory.simpleNotNullType(TypeAttributes.Empty, serializerFactoryClass, listOf()))
|
||||
}
|
||||
|
||||
fun addSerializerSupertypes(classDescriptor: ClassDescriptor, supertypes: MutableList<KotlinType>) {
|
||||
@@ -393,7 +393,7 @@ object KSerializerDescriptorResolver {
|
||||
assert(serializableDescriptor.declaredTypeParameters.size == typeParameters.size)
|
||||
val args = List(serializableDescriptor.declaredTypeParameters.size) { index ->
|
||||
val pType = KotlinTypeFactory.simpleNotNullType(
|
||||
Annotations.EMPTY,
|
||||
TypeAttributes.Empty,
|
||||
serializerClass,
|
||||
listOf(TypeProjectionImpl(typeParameters[index].defaultType))
|
||||
)
|
||||
@@ -430,7 +430,7 @@ object KSerializerDescriptorResolver {
|
||||
)
|
||||
|
||||
val pType =
|
||||
KotlinTypeFactory.simpleNotNullType(Annotations.EMPTY, serializerClass, listOf(TypeProjectionImpl(targ.defaultType)))
|
||||
KotlinTypeFactory.simpleNotNullType(TypeAttributes.Empty, serializerClass, listOf(TypeProjectionImpl(targ.defaultType)))
|
||||
|
||||
args.add(
|
||||
ValueParameterDescriptorImpl(
|
||||
@@ -467,7 +467,7 @@ object KSerializerDescriptorResolver {
|
||||
|
||||
val kSerializerStarType =
|
||||
KotlinTypeFactory.simpleNotNullType(
|
||||
Annotations.EMPTY,
|
||||
TypeAttributes.Empty,
|
||||
serializerClass,
|
||||
listOf(StarProjectionImpl(serializerClass.typeConstructor.parameters.first()))
|
||||
)
|
||||
@@ -517,9 +517,9 @@ object KSerializerDescriptorResolver {
|
||||
val (typeArgs, args) = createKSerializerParamsForEachGenericArgument(f, serializableClass)
|
||||
|
||||
val newSerializableType =
|
||||
KotlinTypeFactory.simpleNotNullType(Annotations.EMPTY, serializableClass, typeArgs.map { TypeProjectionImpl(it.defaultType) })
|
||||
KotlinTypeFactory.simpleNotNullType(TypeAttributes.Empty, serializableClass, typeArgs.map { TypeProjectionImpl(it.defaultType) })
|
||||
val serialReturnType =
|
||||
KotlinTypeFactory.simpleNotNullType(Annotations.EMPTY, serializerClass, listOf(TypeProjectionImpl(newSerializableType)))
|
||||
KotlinTypeFactory.simpleNotNullType(TypeAttributes.Empty, serializerClass, listOf(TypeProjectionImpl(newSerializableType)))
|
||||
|
||||
f.initialize(null, thisClass.thisAsReceiverParameter, emptyList(), typeArgs, args, serialReturnType, Modality.FINAL, DescriptorVisibilities.PUBLIC)
|
||||
return f
|
||||
@@ -550,7 +550,7 @@ object KSerializerDescriptorResolver {
|
||||
|
||||
// object
|
||||
val objectType =
|
||||
KotlinTypeFactory.simpleNotNullType(Annotations.EMPTY, thisClass, typeArgs.map { TypeProjectionImpl(it.defaultType) })
|
||||
KotlinTypeFactory.simpleNotNullType(TypeAttributes.Empty, thisClass, typeArgs.map { TypeProjectionImpl(it.defaultType) })
|
||||
args.add(
|
||||
ValueParameterDescriptorImpl(
|
||||
containingDeclaration = f,
|
||||
@@ -646,7 +646,7 @@ object KSerializerDescriptorResolver {
|
||||
val param = serializerDescriptor.declaredTypeParameters[index]
|
||||
val pType =
|
||||
KotlinTypeFactory.simpleNotNullType(
|
||||
Annotations.EMPTY,
|
||||
TypeAttributes.Empty,
|
||||
serializerClass,
|
||||
listOf(TypeProjectionImpl(param.defaultType))
|
||||
)
|
||||
|
||||
+2
-1
@@ -18,6 +18,7 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.module
|
||||
import org.jetbrains.kotlin.resolve.lazy.descriptors.LazyAnnotationDescriptor
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.KotlinTypeFactory
|
||||
import org.jetbrains.kotlin.types.TypeAttributes
|
||||
|
||||
internal fun ClassConstructorDescriptor.isSerializationCtor(): Boolean {
|
||||
/*kind == CallableMemberDescriptor.Kind.SYNTHESIZED does not work because DeserializedClassConstructorDescriptor loses its kind*/
|
||||
@@ -117,7 +118,7 @@ internal fun ClassDescriptor.getClassFromInternalSerializationPackage(classSimpl
|
||||
module.getClassFromInternalSerializationPackage(classSimpleName)
|
||||
|
||||
fun ClassDescriptor.toSimpleType(nullable: Boolean = false) =
|
||||
KotlinTypeFactory.simpleType(Annotations.EMPTY, this.typeConstructor, emptyList(), nullable)
|
||||
KotlinTypeFactory.simpleType(TypeAttributes.Empty, this.typeConstructor, emptyList(), nullable)
|
||||
|
||||
internal fun Annotated.annotationsWithArguments(): List<Triple<ClassDescriptor, List<ValueArgument>, List<ValueParameterDescriptor>>> =
|
||||
annotations.asSequence()
|
||||
|
||||
+1
-1
@@ -69,7 +69,7 @@ private fun KotlinType.approximateNonDynamicFlexibleTypes(
|
||||
return AbbreviatedType(it.expandedType, it.abbreviation.approximateNonDynamicFlexibleTypes(preferNotNull))
|
||||
}
|
||||
return KotlinTypeFactory.simpleTypeWithNonTrivialMemberScope(
|
||||
annotations,
|
||||
attributes,
|
||||
constructor,
|
||||
arguments.map { it.substitute { type -> type.approximateFlexibleTypes(preferNotNull = true) } },
|
||||
isMarkedNullable,
|
||||
|
||||
Reference in New Issue
Block a user