Fixes and refactors

This commit is contained in:
Irene Dea
2021-10-21 13:22:51 -07:00
committed by Dmitriy Novozhilov
parent 2e2e70fede
commit 19bfc43bee
70 changed files with 263 additions and 327 deletions
@@ -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
@@ -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)
@@ -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
)
}