diff --git a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/FuzzyType.kt b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/FuzzyType.kt index 25938f7f186..135a39de1f5 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/FuzzyType.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/FuzzyType.kt @@ -128,19 +128,15 @@ class FuzzyType( constraintSystem.fixVariables() - if (!constraintSystem.getStatus().hasContradiction()) { - // currently ConstraintSystem return successful status in case there are problems with nullability - // that's why we have to check subtyping manually - val substitutor = constraintSystem.getResultingSubstitutor() - val substitutedType = substitutor.substitute(type, Variance.INVARIANT) - val otherSubstitutedType = substitutor.substitute(otherType.type, Variance.INVARIANT) - return if (substitutedType != null && otherSubstitutedType != null && substitutedType.checkInheritance(otherSubstitutedType)) - constraintSystem.getPartialSubstitutor() - else - null - } - else { - return null - } + if (constraintSystem.getStatus().hasContradiction()) return null + + // currently ConstraintSystem return successful status in case there are problems with nullability + // that's why we have to check subtyping manually + val substitutor = constraintSystem.getResultingSubstitutor() + val substitutedType = substitutor.substitute(type, Variance.INVARIANT) ?: return null + if (substitutedType.isError) return null + val otherSubstitutedType = substitutor.substitute(otherType.type, Variance.INVARIANT) ?: return null + if (otherSubstitutedType.isError) return null + return if (substitutedType.checkInheritance(otherSubstitutedType)) constraintSystem.getPartialSubstitutor() else null } } diff --git a/idea/idea-completion/testData/smart/NoAssertFailsWith.kt b/idea/idea-completion/testData/smart/NoAssertFailsWith.kt new file mode 100644 index 00000000000..a758ca4b79a --- /dev/null +++ b/idea/idea-completion/testData/smart/NoAssertFailsWith.kt @@ -0,0 +1,11 @@ +import kotlin.test.* + +interface I + +fun foo(i: I){} + +fun bar() { + foo(ass) +} + +// ABSENT: assertFailsWith diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmSmartCompletionTestGenerated.java b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmSmartCompletionTestGenerated.java index 05be2518e38..baec6954797 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmSmartCompletionTestGenerated.java +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmSmartCompletionTestGenerated.java @@ -323,6 +323,12 @@ public class JvmSmartCompletionTestGenerated extends AbstractJvmSmartCompletionT doTest(fileName); } + @TestMetadata("NoAssertFailsWith.kt") + public void testNoAssertFailsWith() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/smart/NoAssertFailsWith.kt"); + doTest(fileName); + } + @TestMetadata("NoExtensionMethodFromClassObject.kt") public void testNoExtensionMethodFromClassObject() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/smart/NoExtensionMethodFromClassObject.kt");