From f9129332b7fcb0399da5a1b372390b3fa75bc9bc Mon Sep 17 00:00:00 2001 From: Mikhail Zarechenskiy Date: Mon, 17 Feb 2020 04:49:44 +0300 Subject: [PATCH] [NI] Minor optimisation: don't call extra `contains` checks --- .../tower/KotlinToResolvedCallTransformer.kt | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/KotlinToResolvedCallTransformer.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/KotlinToResolvedCallTransformer.kt index d484f2dcde2..bd1de7dc5eb 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/KotlinToResolvedCallTransformer.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/KotlinToResolvedCallTransformer.kt @@ -773,17 +773,23 @@ class NewResolvedCallImpl( } is FunctionDescriptor -> candidateDescriptor.substituteInferredVariablesAndApproximate(substitutor) is PropertyDescriptor -> { - val shouldForceApproximationAndSubstitution = candidateDescriptor.returnType?.let { type -> - type.contains { it is NewCapturedType } || - type.contains { it.constructor is IntegerLiteralTypeConstructor } || - type.contains { it is DefinitelyNotNullType } || - type.contains { it is StubType } - } ?: false - - if (candidateDescriptor.typeParameters.isNotEmpty() || shouldForceApproximationAndSubstitution) + if (candidateDescriptor.typeParameters.isNotEmpty()) candidateDescriptor.substituteInferredVariablesAndApproximate(substitutor) - else - candidateDescriptor + else { + val shouldForceApproximationAndSubstitution = candidateDescriptor.returnType?.let { type -> + type.contains { + it is NewCapturedType || + it.constructor is IntegerLiteralTypeConstructor || + it is DefinitelyNotNullType || + it is StubType + } + } ?: false + + if (shouldForceApproximationAndSubstitution) + candidateDescriptor.substituteInferredVariablesAndApproximate(substitutor) + else + candidateDescriptor + } } else -> candidateDescriptor }