[NI] Fix determination of completion mode. #KT-30406 Fixed

This commit is contained in:
Dmitriy Novozhilov
2019-03-14 15:31:10 +03:00
parent 1c92c22dee
commit b07aed7a00
6 changed files with 54 additions and 2 deletions
@@ -200,7 +200,7 @@ class KotlinCallCompleter(
val constructor = typeVariable.constructor
val variableWithConstraints = csBuilder.currentStorage().notFixedTypeVariables[constructor] ?: return false
return variableWithConstraints.constraints.any {
return variableWithConstraints.constraints.all {
!trivialConstraintTypeInferenceOracle.isTrivialConstraint(it) && !it.type.isIntegerValueType() &&
it.kind.isLower() && csBuilder.isProperType(it.type)
}
@@ -0,0 +1,16 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_EXPRESSION
// !CHECK_TYPE
// Issue: KT-30406
interface Option<out T> {
val s: String
}
class Some<T>(override val s: String) : Option<T>
class None(override val s: String = "None") : Option<Int>
fun test(a: Int): Option<Any> =
<!DEBUG_INFO_EXPRESSION_TYPE("Option<kotlin.Any>")!>if (a == 239)
<!DEBUG_INFO_EXPRESSION_TYPE("Some<kotlin.Any>")!>Some("239")<!>
else
<!DEBUG_INFO_EXPRESSION_TYPE("None")!>None()<!><!>
@@ -0,0 +1,26 @@
package
public fun test(/*0*/ a: kotlin.Int): Option<kotlin.Any>
public final class None : Option<kotlin.Int> {
public constructor None(/*0*/ s: kotlin.String = ...)
public open override /*1*/ val s: kotlin.String
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public interface Option</*0*/ out T> {
public abstract val s: kotlin.String
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final class Some</*0*/ T> : Option<T> {
public constructor Some</*0*/ T>(/*0*/ s: kotlin.String)
public open override /*1*/ val s: kotlin.String
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -24,7 +24,7 @@ fun foo(): String? {
run {
if (true) {
<!IMPLICIT_CAST_TO_ANY!>Obj()<!>
Obj()
} else
<!INVALID_IF_AS_EXPRESSION!>if<!> (true) return null // Error, coercion to Unit doesn't propagate inside nested lambdas
}
@@ -4160,6 +4160,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
runTest("compiler/testData/diagnostics/tests/controlStructures/kt1075.kt");
}
@TestMetadata("kt30406.kt")
public void testKt30406() throws Exception {
runTest("compiler/testData/diagnostics/tests/controlStructures/kt30406.kt");
}
@TestMetadata("kt4310.kt")
public void testKt4310() throws Exception {
runTest("compiler/testData/diagnostics/tests/controlStructures/kt4310.kt");
@@ -4155,6 +4155,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
runTest("compiler/testData/diagnostics/tests/controlStructures/kt1075.kt");
}
@TestMetadata("kt30406.kt")
public void testKt30406() throws Exception {
runTest("compiler/testData/diagnostics/tests/controlStructures/kt30406.kt");
}
@TestMetadata("kt4310.kt")
public void testKt4310() throws Exception {
runTest("compiler/testData/diagnostics/tests/controlStructures/kt4310.kt");