diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemBuilderImpl.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemBuilderImpl.kt index d62af5fc9fb..b99cbae8ace 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemBuilderImpl.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemBuilderImpl.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2015 JetBrains s.r.o. + * Copyright 2010-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -114,7 +114,7 @@ class ConstraintSystemBuilderImpl(private val mode: Mode = ConstraintSystemBuild type.getNestedTypeParameters().mapNotNull { getMyTypeVariable(it) } override fun addSubtypeConstraint(constrainingType: KotlinType?, subjectType: KotlinType?, constraintPosition: ConstraintPosition) { - addConstraint(SUB_TYPE, constrainingType, subjectType, ConstraintContext(constraintPosition, initial = true)) + addConstraint(SUB_TYPE, constrainingType, subjectType, ConstraintContext(constraintPosition, initial = true, initialReduction = true)) } fun addConstraint( @@ -126,7 +126,8 @@ class ConstraintSystemBuilderImpl(private val mode: Mode = ConstraintSystemBuild val constraintPosition = constraintContext.position // when processing nested constraints, `derivedFrom` information should be reset - val newConstraintContext = ConstraintContext(constraintContext.position, derivedFrom = null, initial = false) + val newConstraintContext = ConstraintContext(constraintContext.position, derivedFrom = null, initial = false, + initialReduction = constraintContext.initialReduction) val typeCheckingProcedure = TypeCheckingProcedure(object : TypeCheckingProcedureCallbacks { private var depth = 0 @@ -194,7 +195,7 @@ class ConstraintSystemBuilderImpl(private val mode: Mode = ConstraintSystemBuild if (isErrorOrSpecialType(subType, constraintPosition) || isErrorOrSpecialType(superType, constraintPosition)) return if (subType == null || superType == null) return - if ((subType.hasExactAnnotation() || superType.hasExactAnnotation()) && (constraintKind != EQUAL)) { + if (constraintContext.initialReduction && (subType.hasExactAnnotation() || superType.hasExactAnnotation()) && (constraintKind != EQUAL)) { return doAddConstraint(EQUAL, subType, superType, constraintContext, typeCheckingProcedure) } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/constraintIncorporation.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/constraintIncorporation.kt index 07b1b8385c7..03dd23eca17 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/constraintIncorporation.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/constraintIncorporation.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2015 JetBrains s.r.o. + * Copyright 2010-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,7 +35,8 @@ data class ConstraintContext( val position: ConstraintPosition, // see TypeBounds.Bound.derivedFrom val derivedFrom: Set? = null, - val initial: Boolean = false) + val initial: Boolean = false, + val initialReduction: Boolean = false) fun ConstraintSystemBuilderImpl.incorporateBound(newBound: Bound) { val typeVariable = newBound.typeVariable diff --git a/compiler/tests-common/org/jetbrains/kotlin/resolve/constraintSystem/AbstractConstraintSystemTest.kt b/compiler/tests-common/org/jetbrains/kotlin/resolve/constraintSystem/AbstractConstraintSystemTest.kt index 938579f4101..01d50e7ae2c 100644 --- a/compiler/tests-common/org/jetbrains/kotlin/resolve/constraintSystem/AbstractConstraintSystemTest.kt +++ b/compiler/tests-common/org/jetbrains/kotlin/resolve/constraintSystem/AbstractConstraintSystemTest.kt @@ -94,7 +94,7 @@ abstract class AbstractConstraintSystemTest : KotlinTestWithEnvironment() { for (constraint in constraints) { val firstType = getType(constraint.firstType) val secondType = getType(constraint.secondType) - val context = ConstraintContext(SPECIAL.position(), initial = true) + val context = ConstraintContext(SPECIAL.position(), initial = true, initialReduction = true) when (constraint.kind) { MyConstraintKind.SUBTYPE -> builder.addSubtypeConstraint(firstType, secondType, context.position) MyConstraintKind.SUPERTYPE -> builder.addSubtypeConstraint(secondType, firstType, context.position) diff --git a/idea/idea-completion/testData/basic/common/substitutedSignature/SubstitutedSignatureSOE.kt b/idea/idea-completion/testData/basic/common/substitutedSignature/SubstitutedSignatureSOE.kt new file mode 100644 index 00000000000..cc3a52b9f62 --- /dev/null +++ b/idea/idea-completion/testData/basic/common/substitutedSignature/SubstitutedSignatureSOE.kt @@ -0,0 +1,14 @@ +import kotlin.internal.Exact + +interface Column + +inline fun > String.enumeration(name: String): Column = TODO() + +fun foo(c: Column<@Exact T>) { } + + +fun test() { + foo("".enu) +} + +// EXIST: enumeration diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java index c43b18c5df5..fff41374671 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java @@ -2393,6 +2393,12 @@ public class JSBasicCompletionTestGenerated extends AbstractJSBasicCompletionTes String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/substitutedSignature/SubstitutedSignature6.kt"); doTest(fileName); } + + @TestMetadata("SubstitutedSignatureSOE.kt") + public void testSubstitutedSignatureSOE() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/substitutedSignature/SubstitutedSignatureSOE.kt"); + doTest(fileName); + } } @TestMetadata("idea/idea-completion/testData/basic/common/super") diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java index 8ce218b11d7..af8577c37a9 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java @@ -2393,6 +2393,12 @@ public class JvmBasicCompletionTestGenerated extends AbstractJvmBasicCompletionT String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/substitutedSignature/SubstitutedSignature6.kt"); doTest(fileName); } + + @TestMetadata("SubstitutedSignatureSOE.kt") + public void testSubstitutedSignatureSOE() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/substitutedSignature/SubstitutedSignatureSOE.kt"); + doTest(fileName); + } } @TestMetadata("idea/idea-completion/testData/basic/common/super")