diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/KotlinCallCompleter.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/KotlinCallCompleter.kt index cddf654e3b4..cdc5af79c7e 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/KotlinCallCompleter.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/KotlinCallCompleter.kt @@ -200,7 +200,8 @@ class KotlinCallCompleter( val constructor = typeVariable.constructor val variableWithConstraints = csBuilder.currentStorage().notFixedTypeVariables[constructor] ?: return false - return variableWithConstraints.constraints.all { + val constraints = variableWithConstraints.constraints + return constraints.isNotEmpty() && constraints.all { !trivialConstraintTypeInferenceOracle.isTrivialConstraint(it) && !it.type.isIntegerValueType() && it.kind.isLower() && csBuilder.isProperType(it.type) } diff --git a/compiler/testData/diagnostics/tests/callableReference/generic/nestedCallWithOverload.kt b/compiler/testData/diagnostics/tests/callableReference/generic/nestedCallWithOverload.kt index a7f6ea032ac..776bf38aabd 100644 --- a/compiler/testData/diagnostics/tests/callableReference/generic/nestedCallWithOverload.kt +++ b/compiler/testData/diagnostics/tests/callableReference/generic/nestedCallWithOverload.kt @@ -7,16 +7,16 @@ fun id(x: T): T = x fun baz(x: T, y: T): T = TODO() fun test() { - val x1: (Int) -> Unit = id(id(::foo)) - val x2: (Int) -> Unit = baz(id(::foo), ::foo) - val x3: (Int) -> Unit = baz(id(::foo), id(id(::foo))) - val x4: (String) -> Unit = baz(id(::foo), id(id(::foo))) - val x5: (Double) -> Unit = baz(id(::foo), id(id(::foo))) + val x1: (Int) -> Unit = id(id(::foo)) + val x2: (Int) -> Unit = baz(id(::foo), ::foo) + val x3: (Int) -> Unit = baz(id(::foo), id(id(::foo))) + val x4: (String) -> Unit = baz(id(::foo), id(id(::foo))) + val x5: (Double) -> Unit = baz(id(::foo), id(id(::foo))) - id<(Int) -> Unit>(id(id(::foo))) - id(id<(Int) -> Unit>(::foo)) - baz<(Int) -> Unit>(id(::foo), id(id(::foo))) - baz(id(::foo), id(id<(Int) -> Unit>(::foo))) - baz(id(::foo), id<(Int) -> Unit>(id(::foo))) + id<(Int) -> Unit>(id(id(::foo))) + id(id<(Int) -> Unit>(::foo)) + baz<(Int) -> Unit>(id(::foo), id(id(::foo))) + baz(id(::foo), id(id<(Int) -> Unit>(::foo))) + baz(id(::foo), id<(Int) -> Unit>(id(::foo))) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/controlFlowAnalysis/elvisNotProcessed.kt b/compiler/testData/diagnostics/tests/controlFlowAnalysis/elvisNotProcessed.kt index 97f02366f36..660cbbe2082 100644 --- a/compiler/testData/diagnostics/tests/controlFlowAnalysis/elvisNotProcessed.kt +++ b/compiler/testData/diagnostics/tests/controlFlowAnalysis/elvisNotProcessed.kt @@ -34,6 +34,6 @@ val bbb = null ?: ( l() ?: null) val bbbb = ( l() ?: null) ?: ( l() ?: null) fun f(x : Long?): Long { - var a = x ?: (fun() {} ?: fun() {}) - return a + var a = x ?: (fun() {} ?: fun() {}) + return a } diff --git a/compiler/testData/diagnostics/tests/controlFlowAnalysis/nonLocalReturnUnreachable.kt b/compiler/testData/diagnostics/tests/controlFlowAnalysis/nonLocalReturnUnreachable.kt index 14fbc01d280..7708127c2a5 100644 --- a/compiler/testData/diagnostics/tests/controlFlowAnalysis/nonLocalReturnUnreachable.kt +++ b/compiler/testData/diagnostics/tests/controlFlowAnalysis/nonLocalReturnUnreachable.kt @@ -1,3 +1,4 @@ +// !WITH_NEW_INFERENCE // See also KT-5198 / KT-10186 inline fun doCall(f: () -> Unit) = f() @@ -13,7 +14,7 @@ fun doSomething() {} fun test2() { fun f(x: Any?) = x - f(null?.let { return }) + f(null?.let { return }) // false unreachable here doSomething() diff --git a/compiler/testData/diagnostics/tests/controlFlowAnalysis/throwInLambda.kt b/compiler/testData/diagnostics/tests/controlFlowAnalysis/throwInLambda.kt index 66acefa676d..08216a5ae4b 100644 --- a/compiler/testData/diagnostics/tests/controlFlowAnalysis/throwInLambda.kt +++ b/compiler/testData/diagnostics/tests/controlFlowAnalysis/throwInLambda.kt @@ -8,6 +8,6 @@ fun foo(): String { } fun bar(): String { val x = fn() ?: return "" - val y = x?.let { throw Exception() } ?: "unreachable" - return y + val y = x?.let { throw Exception() } ?: "unreachable" + return y } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ExclExcl.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ExclExcl.kt index 217749462c2..4499a4f5fe8 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ExclExcl.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ExclExcl.kt @@ -4,7 +4,7 @@ fun bar(x: Int) = x + 1 fun f1(x: Int?) { bar(x) if (x != null) bar(x!!) - if (x == null) bar(x!!) + if (x == null) bar(x!!) } fun f2(x: Int?) { diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/inference/genericMethods.kt b/compiler/testData/diagnostics/tests/delegatedProperty/inference/genericMethods.kt index 7c37eaa8ce6..c0e232104eb 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/inference/genericMethods.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/inference/genericMethods.kt @@ -1,9 +1,10 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER +// !WITH_NEW_INFERENCE // NI_EXPECTED_FILE import kotlin.reflect.KProperty var a: Int by A() -var a1 by A() +var a1 by A() var b: Int by B() diff --git a/compiler/testData/diagnostics/tests/generics/tpAsReified/InFunction.kt b/compiler/testData/diagnostics/tests/generics/tpAsReified/InFunction.kt index 475d4360ae9..e8290732d73 100644 --- a/compiler/testData/diagnostics/tests/generics/tpAsReified/InFunction.kt +++ b/compiler/testData/diagnostics/tests/generics/tpAsReified/InFunction.kt @@ -14,5 +14,5 @@ fun main() { val b: Int = f() f() - val с: A = id(f()) + val с: A = id(f()) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/coercionToUnit/indirectCoercionWithExpectedType.kt b/compiler/testData/diagnostics/tests/inference/coercionToUnit/indirectCoercionWithExpectedType.kt index c66b34becf2..34e7ffb3f27 100644 --- a/compiler/testData/diagnostics/tests/inference/coercionToUnit/indirectCoercionWithExpectedType.kt +++ b/compiler/testData/diagnostics/tests/inference/coercionToUnit/indirectCoercionWithExpectedType.kt @@ -19,13 +19,13 @@ fun c(): Unit = run { // Attention! // In OI expected type 'Unit' isn't applied here because of implementation quirks (note that OI still applies Unit in case 'e') // In NI, it is applied and call is correctly inferred, which is consistent with the previous case - materialize() + materialize() } } fun d(): Unit = run outer@{ run inner@{ - return@inner materialize() + return@inner materialize() } } diff --git a/compiler/testData/diagnostics/tests/inference/coercionToUnit/nonPropagationOfCoercionToUnitInsideNestedLambda.kt b/compiler/testData/diagnostics/tests/inference/coercionToUnit/nonPropagationOfCoercionToUnitInsideNestedLambda.kt index 05f01522125..9a06b729ab7 100644 --- a/compiler/testData/diagnostics/tests/inference/coercionToUnit/nonPropagationOfCoercionToUnitInsideNestedLambda.kt +++ b/compiler/testData/diagnostics/tests/inference/coercionToUnit/nonPropagationOfCoercionToUnitInsideNestedLambda.kt @@ -24,7 +24,7 @@ fun foo(): String? { run { if (true) { - Obj() + Obj() } else if (true) return null // Error, coercion to Unit doesn't propagate inside nested lambdas } diff --git a/compiler/testData/diagnostics/tests/inference/constraints/returnLambdaFromLambda.kt b/compiler/testData/diagnostics/tests/inference/constraints/returnLambdaFromLambda.kt index ad3b409b6fd..c6880126246 100644 --- a/compiler/testData/diagnostics/tests/inference/constraints/returnLambdaFromLambda.kt +++ b/compiler/testData/diagnostics/tests/inference/constraints/returnLambdaFromLambda.kt @@ -9,13 +9,13 @@ fun testLambda() { { it -> x + it } } - val twoLambda: (Int) -> Int = myRun { + val twoLambda: (Int) -> Int = myRun { val x: Int = 1 - run { + run { val y: Int = 2 { x + y } - } - } + } + } } diff --git a/compiler/testData/diagnostics/tests/inference/expectedTypeFromCast.kt b/compiler/testData/diagnostics/tests/inference/expectedTypeFromCast.kt index 763197f2be3..a1b370c3d9f 100644 --- a/compiler/testData/diagnostics/tests/inference/expectedTypeFromCast.kt +++ b/compiler/testData/diagnostics/tests/inference/expectedTypeFromCast.kt @@ -7,7 +7,7 @@ fun id(value: V) = value val asString = foo() as String -val viaId = id(foo()) as String +val viaId = id(foo()) as String val insideId = id(foo() as String) diff --git a/compiler/testData/diagnostics/tests/inference/reportAboutUnresolvedReferenceAsUnresolved.kt b/compiler/testData/diagnostics/tests/inference/reportAboutUnresolvedReferenceAsUnresolved.kt index 981ce628885..27540748926 100644 --- a/compiler/testData/diagnostics/tests/inference/reportAboutUnresolvedReferenceAsUnresolved.kt +++ b/compiler/testData/diagnostics/tests/inference/reportAboutUnresolvedReferenceAsUnresolved.kt @@ -3,5 +3,5 @@ fun T.map(f: (T) -> U) = f(this) fun consume(s: String) {} fun test() { - consume(1.map(::foo)) + consume(1.map(::foo)) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/j+k/flexibleNothing.kt b/compiler/testData/diagnostics/tests/j+k/flexibleNothing.kt index f5596d04f2e..83c4cc1047e 100644 --- a/compiler/testData/diagnostics/tests/j+k/flexibleNothing.kt +++ b/compiler/testData/diagnostics/tests/j+k/flexibleNothing.kt @@ -1,3 +1,5 @@ +// !WITH_NEW_INFERENCE + // FILE: TestClass.java import org.jetbrains.annotations.Nullable; public class TestClass { @@ -10,7 +12,7 @@ public class TestClass { fun run() { val testClass = TestClass() // inferred as `set()`, return type is Nothing! - testClass.set("test", null) + testClass.set("test", null) // Should not be unreachable run() diff --git a/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2164.kt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2164.kt index 89b5caa154a..0b4f9a7dc02 100644 --- a/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2164.kt +++ b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt2164.kt @@ -23,8 +23,8 @@ fun main() { foo(x) } else { foo(x) - foo(x!!) - foo(x) + foo(x!!) + foo(x) } foo(x) diff --git a/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/unnecessaryNotNullAssertion.kt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/unnecessaryNotNullAssertion.kt index ba32926959c..a1e9a09a30d 100644 --- a/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/unnecessaryNotNullAssertion.kt +++ b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/unnecessaryNotNullAssertion.kt @@ -7,18 +7,18 @@ fun nullable(): T? = null fun dependOn(x: T) = x fun test() { - takeNotNull(notNull()!!) - takeNotNull(nullable()!!) + takeNotNull(notNull()!!) + takeNotNull(nullable()!!) - var x: String? = null - takeNotNull(dependOn(x)!!) - takeNotNull(dependOn(dependOn(x))!!) - takeNotNull(dependOn(dependOn(x)!!)) - takeNotNull(dependOn(dependOn(x!!))) + var x: String? = null + takeNotNull(dependOn(x)!!) + takeNotNull(dependOn(dependOn(x))!!) + takeNotNull(dependOn(dependOn(x)!!)) + takeNotNull(dependOn(dependOn(x!!))) - if (x != null) { + if (x != null) { takeNotNull(dependOn(x)!!) takeNotNull(dependOn(dependOn(x))!!) takeNotNull(dependOn(dependOn(x)!!)) - } + } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/nullableTypes/uselessElvis.kt b/compiler/testData/diagnostics/tests/nullableTypes/uselessElvis.kt index d9c9b402054..2f57ac79a41 100644 --- a/compiler/testData/diagnostics/tests/nullableTypes/uselessElvis.kt +++ b/compiler/testData/diagnostics/tests/nullableTypes/uselessElvis.kt @@ -22,21 +22,21 @@ fun nullable(): T? = null fun dependOn(x: T) = x fun test() { - takeNotNull(notNull() ?: "") - takeNotNull(nullable() ?: "") + takeNotNull(notNull() ?: "") + takeNotNull(nullable() ?: "") - val x: String? = null - takeNotNull(dependOn(x) ?: "") - takeNotNull(dependOn(dependOn(x)) ?: "") - takeNotNull(dependOn(dependOn(x as String)) ?: "") + val x: String? = null + takeNotNull(dependOn(x) ?: "") + takeNotNull(dependOn(dependOn(x)) ?: "") + takeNotNull(dependOn(dependOn(x as String)) ?: "") - if (x != null) { + if (x != null) { takeNotNull(dependOn(x) ?: "") takeNotNull(dependOn(dependOn(x)) ?: "") takeNotNull(dependOn(dependOn(x) as? String) ?: "") - } + } - takeNotNull(bar()!!) + takeNotNull(bar()!!) } inline fun reifiedNull(): T? = null diff --git a/compiler/testData/diagnostics/tests/overload/defaultParameters.kt b/compiler/testData/diagnostics/tests/overload/defaultParameters.kt index da7c407b241..a3ef5a4614c 100644 --- a/compiler/testData/diagnostics/tests/overload/defaultParameters.kt +++ b/compiler/testData/diagnostics/tests/overload/defaultParameters.kt @@ -55,5 +55,5 @@ fun test() { withGenericDefaults("") - wrong(null!!) + wrong(null!!) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/platformTypes/methodCall/visitor.kt b/compiler/testData/diagnostics/tests/platformTypes/methodCall/visitor.kt index 4f31958b479..152cf3b0b44 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/methodCall/visitor.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/methodCall/visitor.kt @@ -1,3 +1,4 @@ +// !WITH_NEW_INFERENCE // FILE: p/Visitor.java package p; @@ -21,5 +22,5 @@ public class Element { import p.* fun test(v: Visitor, e: Element) { - e.accept(v, null) + e.accept(v, null) } diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/noWarningOnDoubleElvis.kt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/noWarningOnDoubleElvis.kt index 9bcde272cec..e9891546877 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/noWarningOnDoubleElvis.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/noWarningOnDoubleElvis.kt @@ -1,7 +1,7 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER fun test() { - take(nullable() ?: nullable() ?: "foo") + take(nullable() ?: nullable() ?: "foo") } fun nullable(): T? = TODO() diff --git a/compiler/testData/diagnostics/tests/regressions/correctResultSubstitutorForErrorCandidate.kt b/compiler/testData/diagnostics/tests/regressions/correctResultSubstitutorForErrorCandidate.kt index 2860b1eac1f..3aae6947854 100644 --- a/compiler/testData/diagnostics/tests/regressions/correctResultSubstitutorForErrorCandidate.kt +++ b/compiler/testData/diagnostics/tests/regressions/correctResultSubstitutorForErrorCandidate.kt @@ -2,7 +2,7 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER fun test(a: Int, b: Boolean) { - bar(a.foo(b)) + bar(a.foo(b)) } fun T.foo(l: (T) -> R): R = TODO() diff --git a/compiler/testData/diagnostics/tests/regressions/kt353.kt b/compiler/testData/diagnostics/tests/regressions/kt353.kt index 798ced14f08..3a1fa33a319 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt353.kt +++ b/compiler/testData/diagnostics/tests/regressions/kt353.kt @@ -18,7 +18,7 @@ fun foo(a: A) { val b : () -> Unit = { if (true) { - a.gen() // unit can be inferred + a.gen() // unit can be inferred } else { Unit diff --git a/compiler/testData/diagnostics/tests/resolve/resolveWithFunctionLiteralWithId.kt b/compiler/testData/diagnostics/tests/resolve/resolveWithFunctionLiteralWithId.kt index 6d2f361aedc..93a230cabef 100644 --- a/compiler/testData/diagnostics/tests/resolve/resolveWithFunctionLiteralWithId.kt +++ b/compiler/testData/diagnostics/tests/resolve/resolveWithFunctionLiteralWithId.kt @@ -18,15 +18,15 @@ fun foo(i: Int, f: (Int)->Int) = f(i) fun id(t: T) = t fun test() { - foo(1, id { x1 -> - foo(2, id { x2 -> - foo(3, id { x3 -> - foo(4, id { x4 -> - foo(5, id { x5 -> - x1 + x2 + x3 + x4 + x5 + A.iii - }) - }) - }) - }) - }) + foo(1, id { x1 -> + foo(2, id { x2 -> + foo(3, id { x3 -> + foo(4, id { x4 -> + foo(5, id { x5 -> + x1 + x2 + x3 + x4 + x5 + A.iii + }) + }) + }) + }) + }) } diff --git a/compiler/testData/diagnostics/tests/resolve/resolveWithSpecifiedFunctionLiteralWithId.kt b/compiler/testData/diagnostics/tests/resolve/resolveWithSpecifiedFunctionLiteralWithId.kt index 67b4400b312..626182c5195 100644 --- a/compiler/testData/diagnostics/tests/resolve/resolveWithSpecifiedFunctionLiteralWithId.kt +++ b/compiler/testData/diagnostics/tests/resolve/resolveWithSpecifiedFunctionLiteralWithId.kt @@ -22,11 +22,11 @@ fun foo(i: Int, f: (Int) -> Int) = f(i) fun id(t: T) = t fun test() { - foo(1, id(fun(x1: Int) = - foo(2, id(fun(x2: Int) = - foo(3, id(fun(x3: Int) = - foo(4, id(fun(x4: Int) = - foo(5, id(fun(x5: Int) = + foo(1, id(fun(x1: Int) = + foo(2, id(fun(x2: Int) = + foo(3, id(fun(x3: Int) = + foo(4, id(fun(x4: Int) = + foo(5, id(fun(x5: Int) = x1 + x2 + x3 + x4 + x5 + A.iii )) )) diff --git a/compiler/testData/diagnostics/tests/smartCasts/lambdaAndArgument.kt b/compiler/testData/diagnostics/tests/smartCasts/lambdaAndArgument.kt index a13f12728c2..5792a3f89a0 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/lambdaAndArgument.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/lambdaAndArgument.kt @@ -10,5 +10,5 @@ fun use() { // Write is AFTER x.hashCode() // x is nullable at the second argument - foo(bar { x = null }, x!!) + foo(bar { x = null }, x!!) } diff --git a/compiler/testData/diagnostics/tests/smartCasts/lambdaAndArgumentFun.kt b/compiler/testData/diagnostics/tests/smartCasts/lambdaAndArgumentFun.kt index cc33f16a425..0cbe4c4629b 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/lambdaAndArgumentFun.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/lambdaAndArgumentFun.kt @@ -10,5 +10,5 @@ fun use() { // Write to x is AFTER x.hashCode() // No smart cast should be here! - foo(bar { x = null }, x.hashCode()) + foo(bar { x = null }, x.hashCode()) } diff --git a/compiler/testData/diagnostics/tests/typeParameters/implicitNothingAsTypeParameter.kt b/compiler/testData/diagnostics/tests/typeParameters/implicitNothingAsTypeParameter.kt index b7218ef65ff..9a2f6049ec0 100644 --- a/compiler/testData/diagnostics/tests/typeParameters/implicitNothingAsTypeParameter.kt +++ b/compiler/testData/diagnostics/tests/typeParameters/implicitNothingAsTypeParameter.kt @@ -1,4 +1,5 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER -UNCHECKED_CAST +// !WITH_NEW_INFERENCE // SKIP_TXT // Issue: KT-20849 @@ -11,13 +12,13 @@ fun case_1() { } fun case_2() { - test_1 { null!! } - test_2 { null!! } + test_1 { null!! } + test_2 { null!! } } fun case_3() { - test_1 { throw Exception() } - test_2 { throw Exception() } + test_1 { throw Exception() } + test_2 { throw Exception() } } fun case_6() { @@ -39,5 +40,5 @@ class Context fun Any.decodeIn(typeFrom: Context): T = something() fun Any?.decodeOut(typeFrom: Context): T { - return this?.decodeIn(typeFrom) ?: error("") + return this?.decodeIn(typeFrom) ?: error("") }