From ad12cc296b7ba64e48584a914eb2f66cfbdb4804 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Thu, 22 Oct 2020 12:53:42 +0300 Subject: [PATCH] [FIR] Expand type before adding equality constraint --- .../testData/resolve/diagnostics/upperBoundViolated.txt | 4 ++-- .../testData/resolveWithStdlib/concurrentMapOfAliases.txt | 6 +++--- .../calls/CreateFreshTypeVariableSubstitutorStage.kt | 3 ++- compiler/testData/diagnostics/tests/EnumEntryAsType.fir.kt | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/upperBoundViolated.txt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/upperBoundViolated.txt index d86d58149e4..f0c353ed66f 100644 --- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/upperBoundViolated.txt +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/upperBoundViolated.txt @@ -26,8 +26,8 @@ FILE: upperBoundViolated.kt lval b5: R|B| = R|/B.B|<>() R|/fest|() R|/fest|() - R|/fest|() - R|/fest|() + R|/fest|() + R|/fest||>() } public open class S : R|kotlin/Any| { public constructor(): R|S| { diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/concurrentMapOfAliases.txt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/concurrentMapOfAliases.txt index 7b052d75048..5b463950d0a 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/concurrentMapOfAliases.txt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/concurrentMapOfAliases.txt @@ -5,11 +5,11 @@ FILE: concurrentMapOfAliases.kt super() } - private final val foo: R|java/util/concurrent/ConcurrentHashMap!, ft!>| = Q|java/util/concurrent|.R|java/util/concurrent/ConcurrentHashMap.ConcurrentHashMap|!|, R|ft!|>() - private get(): R|java/util/concurrent/ConcurrentHashMap!, ft!>| + private final val foo: R|java/util/concurrent/ConcurrentHashMap!, ft!>| = Q|java/util/concurrent|.R|java/util/concurrent/ConcurrentHashMap.ConcurrentHashMap|!|, R|ft!|>() + private get(): R|java/util/concurrent/ConcurrentHashMap!, ft!>| private final fun bar(): R|kotlin/Unit| { - this@R|/A|.R|/A.foo|.R|FakeOverride|(String(dd))?.{ (this@R|/A|, $subj$).R|/A.baz|() } + this@R|/A|.R|/A.foo|.R|FakeOverride|(String(dd))?.{ (this@R|/A|, $subj$).R|/A.baz|() } } private final fun R|MyAlias|.baz(): R|kotlin/Unit| { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CreateFreshTypeVariableSubstitutorStage.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CreateFreshTypeVariableSubstitutorStage.kt index 214930124d0..ae6f9936a89 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CreateFreshTypeVariableSubstitutorStage.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CreateFreshTypeVariableSubstitutorStage.kt @@ -9,6 +9,7 @@ import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.declarations.FirTypeParameterRef import org.jetbrains.kotlin.fir.declarations.FirTypeParameterRefsOwner import org.jetbrains.kotlin.fir.renderWithType +import org.jetbrains.kotlin.fir.resolve.fullyExpandedType import org.jetbrains.kotlin.fir.resolve.inference.TypeParameterBasedTypeVariable import org.jetbrains.kotlin.fir.resolve.inference.inferenceComponents import org.jetbrains.kotlin.fir.resolve.inference.model.ConeDeclaredUpperBoundConstraintPosition @@ -68,7 +69,7 @@ internal object CreateFreshTypeVariableSubstitutorStage : ResolutionStage() { typeArgument.typeRef.coneType, typeParameter, context.session.inferenceComponents.ctx - ), + ).fullyExpandedType(context.session), SimpleConstraintSystemConstraintPosition // TODO ) is FirStarProjection -> csBuilder.addEqualityConstraint( diff --git a/compiler/testData/diagnostics/tests/EnumEntryAsType.fir.kt b/compiler/testData/diagnostics/tests/EnumEntryAsType.fir.kt index 5d206d7ecd1..88ac6c4adcd 100644 --- a/compiler/testData/diagnostics/tests/EnumEntryAsType.fir.kt +++ b/compiler/testData/diagnostics/tests/EnumEntryAsType.fir.kt @@ -48,7 +48,7 @@ fun bar(a: Any): T = a as T fun foo() { foo<Color.RED>() - foo<RedAlias>() + foo() bar<Color.RED>(Color.RED) }