diff --git a/compiler/testData/diagnostics/testsWithStdLib/addAllProjection.kt b/compiler/testData/diagnostics/testsWithStdLib/addAllProjection.kt index f3824331f50..73dfa29926d 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/addAllProjection.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/addAllProjection.kt @@ -1,12 +1,14 @@ -fun test(mc: MutableCollection) { - mc.addAll(mc) +// !WITH_NEW_INFERENCE - mc.addAll(arrayListOf()) +fun test(mc: MutableCollection) { + mc.addAll(mc) + + mc.addAll(arrayListOf()) mc.addAll(arrayListOf()) - mc.addAll(listOf("")) - mc.addAll(listOf("")) - mc.addAll(listOf("")) + mc.addAll(listOf("")) + mc.addAll(listOf("")) + mc.addAll(listOf("")) mc.addAll(emptyList()) mc.addAll(emptyList()) diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationApplicability/suppressOnFunctionReference.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationApplicability/suppressOnFunctionReference.kt index af68bbfb0a9..8f2a2593ab0 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationApplicability/suppressOnFunctionReference.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationApplicability/suppressOnFunctionReference.kt @@ -1,3 +1,4 @@ +// !WITH_NEW_INFERENCE // See KT-15839 -val x = "1".let(@Suppress("DEPRECATION") Integer::parseInt) \ No newline at end of file +val x = "1".let(@Suppress("DEPRECATION") Integer::parseInt) \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/javaAnnotationWithVarargArgument.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/javaAnnotationWithVarargArgument.kt index d6e21a735e3..00348297f80 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/javaAnnotationWithVarargArgument.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/javaAnnotationWithVarargArgument.kt @@ -1,9 +1,11 @@ +// !WITH_NEW_INFERENCE + // FILE: A.java public @interface A { String[] value(); } // FILE: b.kt -@A(*; IGNORE)!>arrayOf(1, "b")) +@A(*arrayOf(1, "b")) fun test() { } diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/kotlinAnnotationWithVarargArgument.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/kotlinAnnotationWithVarargArgument.kt index 79cf6184495..87eb60ef350 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/kotlinAnnotationWithVarargArgument.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/kotlinAnnotationWithVarargArgument.kt @@ -1,5 +1,7 @@ +// !WITH_NEW_INFERENCE + annotation class B(vararg val args: String) -@B(*; IGNORE)!>arrayOf(1, "b")) +@B(*arrayOf(1, "b")) fun test() { } diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassArrayInAnnotationsInVariance.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassArrayInAnnotationsInVariance.kt index 9443c6f0727..bc57ae7ff64 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassArrayInAnnotationsInVariance.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassArrayInAnnotationsInVariance.kt @@ -1,3 +1,5 @@ +// !WITH_NEW_INFERENCE + import kotlin.reflect.KClass open class A @@ -12,7 +14,7 @@ class MyClass1 @Ann1(arrayOf(Any::class)) class MyClass1a -@Ann1(arrayOf(B1::class)) +@Ann1(arrayOf(B1::class)) class MyClass2 annotation class Ann2(val arg: Array>) @@ -23,5 +25,5 @@ class MyClass3 @Ann2(arrayOf(B1::class)) class MyClass4 -@Ann2(arrayOf(B2::class)) +@Ann2(arrayOf(B2::class)) class MyClass5 diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassArrayInAnnotationsOutVariance.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassArrayInAnnotationsOutVariance.kt index 4976275b38f..121cfda3fe7 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassArrayInAnnotationsOutVariance.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassArrayInAnnotationsOutVariance.kt @@ -1,3 +1,5 @@ +// !WITH_NEW_INFERENCE + import kotlin.reflect.KClass open class A @@ -9,7 +11,7 @@ annotation class Ann1(val arg: Array>) @Ann1(arrayOf(A::class)) class MyClass1 -@Ann1(arrayOf(Any::class)) +@Ann1(arrayOf(Any::class)) class MyClass1a @Ann1(arrayOf(B1::class)) @@ -17,11 +19,11 @@ class MyClass2 annotation class Ann2(val arg: Array>) -@Ann2(arrayOf(A::class)) +@Ann2(arrayOf(A::class)) class MyClass3 @Ann2(arrayOf(B1::class)) class MyClass4 -@Ann2(arrayOf(B2::class)) +@Ann2(arrayOf(B2::class)) class MyClass5 diff --git a/compiler/testData/diagnostics/testsWithStdLib/assert/cast.kt b/compiler/testData/diagnostics/testsWithStdLib/assert/cast.kt index 358f56deb41..55e2e594208 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/assert/cast.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/assert/cast.kt @@ -1,3 +1,4 @@ +// !WITH_NEW_INFERENCE // !IGNORE_DATA_FLOW_IN_ASSERT // SKIP_TXT // WITH_RUNTIME @@ -10,11 +11,11 @@ class B: A { fun test1(a: A) { assert((a as B).bool()) - a.bool() + a.bool() } fun test2() { val a: A? = null; assert((a as B).bool()) - a?.bool() + a?.bool() } diff --git a/compiler/testData/diagnostics/testsWithStdLib/assert/safeCall.kt b/compiler/testData/diagnostics/testsWithStdLib/assert/safeCall.kt index 02acefd5785..e66f96c8efd 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/assert/safeCall.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/assert/safeCall.kt @@ -1,37 +1,38 @@ +// !WITH_NEW_INFERENCE // !IGNORE_DATA_FLOW_IN_ASSERT // SKIP_TXT // WITH_RUNTIME fun test1(s: String?) { assert(s!!.isEmpty()) - s?.length + s?.length } fun test2(s: String?) { assert(s!!.isEmpty()) - s!!.length + s!!.length } fun test3(s: String?) { assert(s!!.isEmpty()) - s.length + s.length } fun test4() { val s: String? = null; assert(s!!.isEmpty()) - s?.length + s?.length } fun test5() { val s: String? = null; assert(s!!.isEmpty()) - s!!.length + s!!.length } fun test6() { val s: String? = null; assert(s!!.isEmpty()) - s.length + s.length } diff --git a/compiler/testData/diagnostics/testsWithStdLib/cast/AsInsideIn.kt b/compiler/testData/diagnostics/testsWithStdLib/cast/AsInsideIn.kt index 980b487be50..503938a0425 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/cast/AsInsideIn.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/cast/AsInsideIn.kt @@ -1,9 +1,10 @@ -// See also KT-10386 +// !WITH_NEW_INFERENCE +// See also KT-10386 interface A class B : A fun foo1(list: List, arg: B?): Boolean { // Type mismatch - return arg in list // resolved to extension + return arg in list // resolved to extension } fun foo2(list: List, arg: B?): Boolean { // FAKE: no cast needed diff --git a/compiler/testData/diagnostics/testsWithStdLib/commonCollections.kt b/compiler/testData/diagnostics/testsWithStdLib/commonCollections.kt index 4ab7cce5490..4741203490a 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/commonCollections.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/commonCollections.kt @@ -1,8 +1,10 @@ +// !WITH_NEW_INFERENCE + import java.util.* fun foo() { val al = ArrayList() al.size - al.contains(1) + al.contains(1) al.contains("") al.remove("") @@ -10,7 +12,7 @@ fun foo() { val hs = HashSet() hs.size - hs.contains(1) + hs.contains(1) hs.contains("") hs.remove("") @@ -18,10 +20,10 @@ fun foo() { val hm = HashMap() hm.size - hm.containsKey(1) + hm.containsKey(1) hm.containsKey("") - hm[1] + hm[1] hm[""] hm.remove("") diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/deeplyNested.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/deeplyNested.kt index 6c81850b82b..d16f7b0f3d8 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/deeplyNested.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/deeplyNested.kt @@ -99,6 +99,6 @@ fun branchedAndNestedWithNativeOperators(x: Any?, y: Any?) { ) x.length y.length - y.inc() + y.inc() } diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/intersectingInfo.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/intersectingInfo.kt index 6b3c2c59051..e9ca68cd1d5 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/intersectingInfo.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/intersectingInfo.kt @@ -31,12 +31,12 @@ fun intersectingInfo(x: Any?, y: Any?) { if ((isString(x) && y is String) || (!notIsString(x) && !notIsInt(y))) { x.length y.length - y.inc() + y.inc() } else { x.length y.length - y.inc() + y.inc() } } @@ -49,13 +49,13 @@ fun intersectingInfo2(x: Any?, y: Any?) { (!notIsString(x) && isString(y) && y is Int) || (x is String && !notIsInt(y) && x is Int)) { x.length - x.inc() + x.inc() y.length - y.inc() + y.inc() } x.length - x.inc() + x.inc() y.length - y.inc() + y.inc() } diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/intersectionTypes.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/intersectionTypes.kt index 36f170753a9..36e561b161c 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/intersectionTypes.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/intersectionTypes.kt @@ -28,7 +28,7 @@ fun testDeMorgan(x: Any?) { } else { x.length - x.inc() + x.inc() } } @@ -36,7 +36,7 @@ fun testDeMorgan2(x: Any?) { // x !is String || x !is Int if (notIsString(x) || notIsInt(x)) { x.length - x.inc() + x.inc() } else { x.length diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/operatorsTests/andOperator.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/operatorsTests/andOperator.kt index 8a96d626ef7..1cc38efdac6 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/operatorsTests/andOperator.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/operatorsTests/andOperator.kt @@ -42,17 +42,17 @@ fun truetrue(x: Any?) { x.inc() } x.length - x.inc() + x.inc() } fun truefalse(x: Any?) { if (trueWhenString(x) && falseWhenInt(x)) { x.length - x.inc() + x.inc() } else { x.length - x.inc() + x.inc() } } @@ -63,19 +63,19 @@ fun falsetrue(x: Any?) { } else { x.length - x.inc() + x.inc() } } fun falsefalse(x: Any?) { if (falseWhenString(x) && falseWhenInt(x)) { x.length - x.inc() + x.inc() } else { // Note that we can't argue that we have any of smartcasts here, // because we don't know which one of both arguments was 'false' to bring us here x.length - x.inc() + x.inc() } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/operatorsTests/orOperator.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/operatorsTests/orOperator.kt index 6b10acbf573..c9b7b2d305c 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/operatorsTests/orOperator.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/operatorsTests/orOperator.kt @@ -36,18 +36,18 @@ fun falseWhenInt(x: Any?): Boolean { fun truetrue(x: Any?) { if (trueWhenString(x) || trueWhenInt(x)) { x.length - x.inc() + x.inc() } else { x.length - x.inc() + x.inc() } } fun truefalse(x: Any?) { if (trueWhenString(x) || falseWhenInt(x)) { x.length - x.inc() + x.inc() } else { x.length @@ -58,18 +58,18 @@ fun truefalse(x: Any?) { fun falsetrue(x: Any?) { if (falseWhenString(x) || trueWhenInt(x)) { x.length - x.inc() + x.inc() } else { x.length - x.inc() + x.inc() } } fun falsefalse(x: Any?) { if (falseWhenString(x) || falseWhenInt(x)) { x.length - x.inc() + x.inc() } else { x.length diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/applyInsideCoroutine.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/applyInsideCoroutine.kt index 5f8f5ea97ae..996031914ae 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/applyInsideCoroutine.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/applyInsideCoroutine.kt @@ -1,5 +1,6 @@ // !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_ANONYMOUS_PARAMETER -UNUSED_VARIABLE // !WITH_NEW_INFERENCE +// !WITH_NEW_INFERENCE // NI_EXPECTED_FILE class Controller { @@ -8,26 +9,26 @@ class Controller { fun generate(g: suspend Controller.() -> Unit): S = TODO() -val test1 = generate { +val test1 = generate { apply { - yield(4) + yield(4) } } -val test2 = generate { - yield(B) +val test2 = generate { + yield(B) apply { - yield(C) + yield(C) } } -val test3 = generate { +val test3 = generate { this.let { - yield(B) + yield(B) } apply { - yield(C) + yield(C) } } diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/applyInsideCoroutine.ni.txt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/applyInsideCoroutine.ni.txt index f1e995ea666..4f73c8e8154 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/applyInsideCoroutine.ni.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/applyInsideCoroutine.ni.txt @@ -1,8 +1,8 @@ package -public val test1: kotlin.Int -public val test2: A -public val test3: A +public val test1: kotlin.Nothing +public val test2: kotlin.Nothing +public val test3: kotlin.Nothing public fun generate(/*0*/ g: suspend Controller.() -> kotlin.Unit): S public interface A { diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/extensionWithNonValuableConstraints.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/extensionWithNonValuableConstraints.kt index 335dd3094da..e47071c2558 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/extensionWithNonValuableConstraints.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/extensionWithNonValuableConstraints.kt @@ -1,5 +1,7 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER // !USE_EXPERIMENTAL: kotlin.Experimental +// !WITH_NEW_INFERENCE +// NI_EXPECTED_FILE @file:UseExperimental(ExperimentalTypeInference::class) @@ -27,7 +29,7 @@ val test1 = generate { baseExtension() } -val test2 = generate { +val test2 = generate { baseExtension() } @@ -36,21 +38,21 @@ val test3 = generate { outNullableAnyExtension() } -val test4 = generate { +val test4 = generate { outNullableAnyExtension() } -val test5 = generate { +val test5 = generate { yield(42) outAnyExtension() } -val test6 = generate { +val test6 = generate { yield("bar") invNullableAnyExtension() } -val test7 = generate { +val test7 = generate { yield("baz") genericExtension() } diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/extensionWithNonValuableConstraints.ni.txt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/extensionWithNonValuableConstraints.ni.txt new file mode 100644 index 00000000000..fa5753107dd --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/extensionWithNonValuableConstraints.ni.txt @@ -0,0 +1,30 @@ +package + +public val test1: kotlin.String +public val test2: kotlin.Any? +public val test3: kotlin.Int +public val test4: kotlin.Any? +public val test5: kotlin.Int +public val test6: kotlin.String +public val test7: kotlin.String +public val test8: kotlin.Any? +public fun generate(/*0*/ @kotlin.BuilderInference g: suspend Controller.() -> kotlin.Unit): S +public fun Base.baseExtension(): kotlin.Unit +public fun Controller.genericExtension(): kotlin.Unit +public fun Controller.invNullableAnyExtension(): kotlin.Unit +public fun Controller.outAnyExtension(): kotlin.Unit +public fun Controller.outNullableAnyExtension(): kotlin.Unit +@kotlin.BuilderInference public fun Controller.safeExtension(): kotlin.Unit + +public interface Base { + 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 Controller : Base { + 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 open suspend fun yield(/*0*/ t: T): kotlin.Unit +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/extensionsWithNonValuableConstraintsGenericBase.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/extensionsWithNonValuableConstraintsGenericBase.kt index 76e38931f32..c92b6c2b283 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/extensionsWithNonValuableConstraintsGenericBase.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/extensionsWithNonValuableConstraintsGenericBase.kt @@ -1,5 +1,7 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER // !USE_EXPERIMENTAL: kotlin.Experimental +// !WITH_NEW_INFERENCE +// NI_EXPECTED_FILE @file:UseExperimental(ExperimentalTypeInference::class) @@ -26,11 +28,11 @@ val test1 = generate { yield("foo") } -val test2 = generate { +val test2 = generate { starBase() } -val test3 = generate { +val test3 = generate { yield("bar") stringBase() } @@ -45,6 +47,6 @@ val test5 = generateSpecific { stringBase() } -val test6 = generateSpecific { +val test6 = generateSpecific { stringBase() } \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/extensionsWithNonValuableConstraintsGenericBase.ni.txt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/extensionsWithNonValuableConstraintsGenericBase.ni.txt new file mode 100644 index 00000000000..b5f7fb08b84 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/extensionsWithNonValuableConstraintsGenericBase.ni.txt @@ -0,0 +1,32 @@ +package + +public val test1: kotlin.String +public val test2: kotlin.Any? +public val test3: kotlin.String +public val test4: kotlin.Int +public val test5: kotlin.Int +public val test6: kotlin.Any? +public fun generate(/*0*/ @kotlin.BuilderInference g: suspend Controller.() -> kotlin.Unit): S +public fun generateSpecific(/*0*/ @kotlin.BuilderInference g: suspend SpecificController.() -> kotlin.Unit): S +public fun Base<*>.starBase(): kotlin.Unit +public fun Base.stringBase(): kotlin.Unit + +public interface Base { + 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 Controller : Base { + 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 open suspend fun yield(/*0*/ t: T): kotlin.Unit +} + +public interface SpecificController : Base { + 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 open suspend fun yield(/*0*/ t: T): kotlin.Unit +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/inferCoroutineTypeInOldVersion.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/inferCoroutineTypeInOldVersion.kt index 64db29d733e..679e4d6136e 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/inferCoroutineTypeInOldVersion.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/inferCoroutineTypeInOldVersion.kt @@ -1,5 +1,7 @@ // !LANGUAGE: -ExperimentalBuilderInference // !DIAGNOSTICS: -UNUSED_PARAMETER +// !WITH_NEW_INFERENCE +// NI_EXPECTED_FILE class Builder { suspend fun add(t: T) {} @@ -16,11 +18,11 @@ val member = build { add(42) } -val memberWithoutAnn = wrongBuild { - add(42) +val memberWithoutAnn = wrongBuild { + add(42) } -val extension = build { +val extension = build { extensionAdd("foo") } diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/inferCoroutineTypeInOldVersion.ni.txt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/inferCoroutineTypeInOldVersion.ni.txt new file mode 100644 index 00000000000..aeffde73da1 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/inferCoroutineTypeInOldVersion.ni.txt @@ -0,0 +1,18 @@ +package + +public val extension: kotlin.collections.List +public val member: kotlin.collections.List +public val memberWithoutAnn: kotlin.collections.List +public val safeExtension: kotlin.collections.List +public fun build(/*0*/ g: suspend Builder.() -> kotlin.Unit): kotlin.collections.List +public fun wrongBuild(/*0*/ g: Builder.() -> kotlin.Unit): kotlin.collections.List +public fun Builder.extensionAdd(/*0*/ s: S): kotlin.Unit +public suspend fun Builder.safeExtensionAdd(/*0*/ s: S): kotlin.Unit + +public final class Builder { + public constructor Builder() + public final suspend fun add(/*0*/ t: T): kotlin.Unit + 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 +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt15516.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt15516.kt index a979b1fe982..c43d3c9c806 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt15516.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt15516.kt @@ -13,7 +13,7 @@ class Problem(){ fun createStateMachine(): StateMachine = stateMachine { val letter = getInputStub() - if (letter is Any) + if (letter is Any) println("yes") } } diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/recursiveGenerators2.ni.txt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/recursiveGenerators2.ni.txt index 337638e04d4..22b34c1f8db 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/recursiveGenerators2.ni.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/recursiveGenerators2.ni.txt @@ -1,8 +1,8 @@ package -public val test1: kotlin.collections.List> -public fun generate(/*0*/ g: suspend GenericController.() -> kotlin.Unit): kotlin.collections.List -public suspend fun GenericController>.yieldGenerate(/*0*/ g: suspend GenericController.() -> kotlin.Unit): kotlin.Unit +public val test1: kotlin.collections.List> +public fun generate(/*0*/ @kotlin.BuilderInference g: suspend GenericController.() -> kotlin.Unit): kotlin.collections.List +@kotlin.BuilderInference public suspend fun GenericController>.yieldGenerate(/*0*/ g: suspend GenericController.() -> kotlin.Unit): kotlin.Unit public final class GenericController { public constructor GenericController() diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/resolveUsualCallWithBuilderInference.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/resolveUsualCallWithBuilderInference.kt index ad8321fa4d6..cba0127a4db 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/resolveUsualCallWithBuilderInference.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/resolveUsualCallWithBuilderInference.kt @@ -1,6 +1,7 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER - +// !WITH_NEW_INFERENCE // FILE: annotation.kt +// NI_EXPECTED_FILE package kotlin @@ -24,11 +25,11 @@ val member = build { add(42) } -val memberWithoutAnn = wrongBuild { - add(42) +val memberWithoutAnn = wrongBuild { + add(42) } -val extension = build { +val extension = build { extensionAdd("foo") } diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/resolveUsualCallWithBuilderInference.ni.txt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/resolveUsualCallWithBuilderInference.ni.txt new file mode 100644 index 00000000000..aefcbf7128c --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/resolveUsualCallWithBuilderInference.ni.txt @@ -0,0 +1,28 @@ +package + +public val extension: kotlin.collections.List +public val member: kotlin.collections.List +public val memberWithoutAnn: kotlin.collections.List +public val safeExtension: kotlin.collections.List +public fun build(/*0*/ @kotlin.BuilderInference g: Builder.() -> kotlin.Unit): kotlin.collections.List +public fun wrongBuild(/*0*/ g: Builder.() -> kotlin.Unit): kotlin.collections.List +public fun Builder.extensionAdd(/*0*/ s: S): kotlin.Unit +@kotlin.BuilderInference public fun Builder.safeExtensionAdd(/*0*/ s: S): kotlin.Unit + +public final class Builder { + public constructor Builder() + public final fun add(/*0*/ t: T): kotlin.Unit + 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 +} + +package kotlin { + + public final annotation class BuilderInference : kotlin.Annotation { + public constructor BuilderInference() + 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 + } +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/suspendCallsWithErrors.ni.txt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/suspendCallsWithErrors.ni.txt index 39d9fb735ab..d5cae1aa27b 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/suspendCallsWithErrors.ni.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/suspendCallsWithErrors.ni.txt @@ -1,8 +1,8 @@ package -public val test1: [ERROR : Error type for ParseError-argument VALUE_ARGUMENT] +public val test1: kotlin.Any? public val test2: kotlin.Int -public fun generate(/*0*/ g: suspend Controller.() -> kotlin.Unit): S +public fun generate(/*0*/ @kotlin.BuilderInference g: suspend Controller.() -> kotlin.Unit): S public final class A { public constructor A() diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/suspendCallsWrongUpperBound.ni.txt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/suspendCallsWrongUpperBound.ni.txt index 08125502bb3..a832994fa5f 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/suspendCallsWrongUpperBound.ni.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/suspendCallsWrongUpperBound.ni.txt @@ -1,6 +1,6 @@ package -public val test: kotlin.String +public val test: kotlin.Number public fun generate(/*0*/ g: suspend Controller.() -> kotlin.Unit): S public final class Controller { diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/useInferenceInformationFromExtension.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/useInferenceInformationFromExtension.kt index 9d93e272c11..8a28614e29a 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/useInferenceInformationFromExtension.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/useInferenceInformationFromExtension.kt @@ -1,4 +1,6 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER +// !WITH_NEW_INFERENCE +// NI_EXPECTED_FILE // FILE: annotation.kt @@ -23,7 +25,7 @@ val normal = generate { yield(42) } -val extension = generate { +val extension = generate { extensionYield("foo") } diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/useInferenceInformationFromExtension.ni.txt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/useInferenceInformationFromExtension.ni.txt new file mode 100644 index 00000000000..9a2789c7e6e --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/useInferenceInformationFromExtension.ni.txt @@ -0,0 +1,26 @@ +package + +public val extension: kotlin.collections.List +public val normal: kotlin.collections.List +public val safeExtension: kotlin.collections.List +public fun generate(/*0*/ @kotlin.BuilderInference g: suspend GenericController.() -> kotlin.Unit): kotlin.collections.List +public suspend fun GenericController.extensionYield(/*0*/ s: S): kotlin.Unit +@kotlin.BuilderInference public suspend fun GenericController.safeExtensionYield(/*0*/ s: S): kotlin.Unit + +public final class GenericController { + public constructor GenericController() + 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 suspend fun yield(/*0*/ t: T): kotlin.Unit +} + +package kotlin { + + public final annotation class BuilderInference : kotlin.Annotation { + public constructor BuilderInference() + 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 + } +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/withUninferredParameter.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/withUninferredParameter.kt index 7e538d4aec1..fdfd536e02a 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/withUninferredParameter.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/withUninferredParameter.kt @@ -8,8 +8,8 @@ class GenericController { fun generate(g: suspend GenericController.(S) -> Unit): S = TODO() -val test1 = generate { - yield(4) +val test1 = generate { + yield(4) } val test2 = generate { diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/withUninferredParameter.ni.txt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/withUninferredParameter.ni.txt index e728cad5e82..878c3d6ac6c 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/withUninferredParameter.ni.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/withUninferredParameter.ni.txt @@ -1,6 +1,6 @@ package -public val test1: kotlin.Int +public val test1: kotlin.Nothing public val test2: kotlin.Int public val test3: kotlin.Int public fun generate(/*0*/ g: suspend GenericController.(S) -> kotlin.Unit): S diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/kt18292.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/kt18292.kt index 465f7f1115e..91bcfe965c3 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/kt18292.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/kt18292.kt @@ -1,6 +1,7 @@ // SKIP_TXT // WITH_RUNTIME // COMMON_COROUTINES_TEST +// !WITH_NEW_INFERENCE import COROUTINES_PACKAGE.* diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/lambdaExpectedType.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/lambdaExpectedType.kt index 6b8e0edd9d6..a058c970516 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/lambdaExpectedType.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/lambdaExpectedType.kt @@ -1,3 +1,4 @@ +// !WITH_NEW_INFERENCE // !CHECK_TYPE // !DIAGNOSTICS: -UNUSED_PARAMETER -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -UNUSED_VARIABLE @@ -27,25 +28,25 @@ fun foo() { i = genericBuilder { 1 } genericBuilder { 1 } genericBuilder { 1 } - genericBuilder { "" } + genericBuilder { "" } val y = { 1 } - genericBuilder(y) + genericBuilder(y) - unitBuilder {} - unitBuilder { 1 } - unitBuilder({}) - unitBuilder({ 1 }) + unitBuilder {} + unitBuilder { 1 } + unitBuilder({}) + unitBuilder({ 1 }) - manyArgumentsBuilder({}, { "" }) { 1 } + manyArgumentsBuilder({}, { "" }) { 1 } - val s: String = manyArgumentsBuilder({}, { "" }) { 1 } + val s: String = manyArgumentsBuilder({}, { "" }) { 1 } - manyArgumentsBuilder({}, { "" }, { 1 }) - manyArgumentsBuilder({}, { 1 }, { 2 }) + manyArgumentsBuilder({}, { "" }, { 1 }) + manyArgumentsBuilder({}, { 1 }, { 2 }) - severalParamsInLambda { x, y -> + severalParamsInLambda { x, y -> x checkType { _() } y checkType { _() } - } + } } diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/release/languageVersionIsNotEqualToApiVersion.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/release/languageVersionIsNotEqualToApiVersion.kt index 20a995a6fc4..8a8e50e78be 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/release/languageVersionIsNotEqualToApiVersion.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/release/languageVersionIsNotEqualToApiVersion.kt @@ -1,6 +1,7 @@ // !API_VERSION: 1.2 // !DIAGNOSTICS: -PRE_RELEASE_CLASS, -UNUSED_PARAMETER // !LANGUAGE: +ReleaseCoroutines +// !WITH_NEW_INFERENCE // SKIP_TXT suspend fun dummy() {} @@ -34,4 +35,4 @@ fun test2() { suspend fun test3(): Unit = kotlin.coroutines.experimental.suspendCoroutine { _ -> Unit } -suspend fun test4(): Unit = kotlin.coroutines.suspendCoroutine { _ -> Unit } +suspend fun test4(): Unit = kotlin.coroutines.suspendCoroutine { _ -> Unit } diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/suspendCoroutineOrReturn.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/suspendCoroutineOrReturn.kt index 0302141f897..17d3cb1ef20 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/suspendCoroutineOrReturn.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/suspendCoroutineOrReturn.kt @@ -1,3 +1,4 @@ +// !WITH_NEW_INFERENCE // !DIAGNOSTICS: -UNUSED_PARAMETER // !CHECK_TYPE // SKIP_TXT @@ -18,7 +19,7 @@ class Controller { suspend fun yieldString(value: String) = suspendCoroutineUninterceptedOrReturn { it.resume(1) it checkType { _>() } - it.resume("") + it.resume("") // We can return anything here, 'suspendCoroutineUninterceptedOrReturn' is not very type-safe // Also we can call resume and then return the value too, but it's still just our problem diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/suspendCoroutineOrReturn_1_2.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/suspendCoroutineOrReturn_1_2.kt index 259cb3da207..3ca0e0a7f13 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/suspendCoroutineOrReturn_1_2.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/suspendCoroutineOrReturn_1_2.kt @@ -1,6 +1,7 @@ // !LANGUAGE: -ReleaseCoroutines // !DIAGNOSTICS: -UNUSED_PARAMETER -EXPERIMENTAL_FEATURE_WARNING // !CHECK_TYPE +// !WITH_NEW_INFERENCE // SKIP_TXT import kotlin.coroutines.* @@ -19,7 +20,7 @@ class Controller { suspend fun yieldString(value: String) = suspendCoroutineUninterceptedOrReturn { it.resume(1) it checkType { _>() } - it.resume("") + it.resume("") // We can return anything here, 'suspendCoroutineUninterceptedOrReturn' is not very type-safe // Also we can call resume and then return the value too, but it's still just our problem diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/suspendExternalFunctions.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/suspendExternalFunctions.kt index 29a2b3f4ee5..6b2e2c5c47c 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/suspendExternalFunctions.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/suspendExternalFunctions.kt @@ -1,5 +1,6 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER // !CHECK_TYPE +// !WITH_NEW_INFERENCE suspend fun noParams() { } @@ -35,7 +36,7 @@ fun test() { severalParams("", 89) checkType { _() } // TODO: should we allow somehow to call with passing continuation explicitly? - severalParams("", 89, 6.9) checkType { _() } + severalParams("", 89, 6.9) checkType { _() } "".stringReceiver(1) Any().anyReceiver(1) diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/suspendFunctions.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/suspendFunctions.kt index bcd8ad1955d..bd8751f3f84 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/suspendFunctions.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/suspendFunctions.kt @@ -1,6 +1,7 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER // !CHECK_TYPE // COMMON_COROUTINES_TEST +// !WITH_NEW_INFERENCE import COROUTINES_PACKAGE.* class Controller { diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/tryCatchLambda.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/tryCatchLambda.kt index 7810750a94f..cdbc394658d 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/tryCatchLambda.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/tryCatchLambda.kt @@ -1,4 +1,6 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -UNUSED_VARIABLE +// !WITH_NEW_INFERENCE + suspend fun await(f: V): V = f fun genericBuilder(c: suspend () -> T): T = null!! @@ -6,10 +8,10 @@ fun genericBuilder(c: suspend () -> T): T = null!! fun foo() { var result = "" genericBuilder { - try { + try { await("") } catch(e: Exception) { - result = "fail" - } + result = "fail" + } } } diff --git a/compiler/testData/diagnostics/testsWithStdLib/elvisOnJavaList.kt b/compiler/testData/diagnostics/testsWithStdLib/elvisOnJavaList.kt index 2c14316fda1..61ffc483cc5 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/elvisOnJavaList.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/elvisOnJavaList.kt @@ -1,3 +1,5 @@ +// !WITH_NEW_INFERENCE + // FILE: P.java import java.util.ArrayList; @@ -13,5 +15,5 @@ public class P { fun foo(c: P): MutableList { // Error should be here: see KT-8168 Typechecker fails for platform collection type - return c.getList() ?: listOf() + return c.getList() ?: listOf() } \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/implicitCastToAny.kt b/compiler/testData/diagnostics/testsWithStdLib/implicitCastToAny.kt index 2770e74780c..4354adc0bc2 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/implicitCastToAny.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/implicitCastToAny.kt @@ -1,23 +1,25 @@ +// !WITH_NEW_INFERENCE + var longWords = 0 val smallWords = hashSetOf() fun test1(word: String) = run { if (word.length > 4) { - longWords++ + longWords++ } else { - smallWords.add(word) + smallWords.add(word) } } fun test2(word: String) = run { if (word.length > 4) { - if (word.startsWith("a")) longWords++ + if (word.startsWith("a")) longWords++ } else { - smallWords.add(word) + smallWords.add(word) } } diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/exactAnnotation.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/exactAnnotation.kt index 96cb7aaeec5..9d67807de36 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/exactAnnotation.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/exactAnnotation.kt @@ -1,4 +1,5 @@ //!DIAGNOSTICS: -UNUSED_VARIABLE +// !WITH_NEW_INFERENCE @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") fun List<@kotlin.internal.Exact T>.firstTyped(): U = throw Exception() @@ -7,5 +8,5 @@ fun test1(l: List) { val i: Int = l.firstTyped() - val s: String = l.firstTyped() + val s: String = l.firstTyped() } \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/noInferAndLowPriority.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/noInferAndLowPriority.kt index 31775c3c04e..81f5d829ff4 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/noInferAndLowPriority.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/noInferAndLowPriority.kt @@ -1,4 +1,5 @@ //!DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE +// !WITH_NEW_INFERENCE @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") @kotlin.jvm.JvmName("containsAny") @@ -10,6 +11,6 @@ public fun Iterable.contains1(element: @kotlin.internal.NoInfer T): Boole fun test() { - val a: Boolean = listOf(1).contains1("") + val a: Boolean = listOf(1).contains1("") val b: Boolean = listOf(1).contains1(1) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/noInferAnnotation.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/noInferAnnotation.kt index 56ec2680c6c..e7580563767 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/noInferAnnotation.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/noInferAnnotation.kt @@ -1,4 +1,5 @@ //!DIAGNOSTICS: -UNUSED_PARAMETER +// !WITH_NEW_INFERENCE @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") fun test1(t1: T, t2: @kotlin.internal.NoInfer T): T = t1 @@ -10,23 +11,23 @@ fun @kotlin.internal.NoInfer T.test2(t1: T): T = t1 fun test3(t1: @kotlin.internal.NoInfer T): T = t1 fun usage() { - test1(1, "312") - 1.test2("") - test3("") + test1(1, "312") + 1.test2("") + test3("") } @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") fun List.contains1(e: @kotlin.internal.NoInfer T): Boolean = true fun test(i: Int?, a: Any, l: List) { - l.contains1(a) - l.contains1("") - l.contains1(i) + l.contains1(a) + l.contains1("") + l.contains1(i) } @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") fun assertEquals1(e1: T, e2: @kotlin.internal.NoInfer T): Boolean = true fun test(s: String) { - assertEquals1(s, 11) + assertEquals1(s, 11) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAndLowPriority.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAndLowPriority.kt index 5ffb9e30d1a..c020f073a25 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAndLowPriority.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAndLowPriority.kt @@ -1,4 +1,5 @@ //!DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE +// !WITH_NEW_INFERENCE @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") @kotlin.jvm.JvmName("containsAny") @@ -17,9 +18,9 @@ public fun Map.get1(key: Any?): Int = null!! public fun <@kotlin.internal.OnlyInputTypes K, V> Map.get1(key: K): V? = null!! fun test(map: Map) { - val a: Int = listOf(1).contains1("") + val a: Int = listOf(1).contains1("") val b: Boolean = listOf(1).contains1(1) - val c: String? = map.get1("") + val c: String? = map.get1("") val d: String? = map.get1(1) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/resolveWithOnlyInputTypesAnnotation.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/resolveWithOnlyInputTypesAnnotation.kt index 65dac90353e..e2c6f5d99e7 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/resolveWithOnlyInputTypesAnnotation.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/resolveWithOnlyInputTypesAnnotation.kt @@ -1,4 +1,5 @@ //!DIAGNOSTICS: -UNUSED_PARAMETER +// !WITH_NEW_INFERENCE @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") fun <@kotlin.internal.OnlyInputTypes T> assertEquals1(t1: T, t2: T) {} @@ -10,7 +11,7 @@ class D fun test1(a: A, b: B, c: C) { assertEquals1(a, b) - assertEquals1(b, c) + assertEquals1(b, c) assertEquals1(3, 3) assertEquals1(1 or 2, 2 or 1) diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/kt11266.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/kt11266.kt index c4cb696f7d6..ba3299f2b20 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/kt11266.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/kt11266.kt @@ -1,2 +1,4 @@ +// !WITH_NEW_INFERENCE +// NI_EXPECTED_FILE fun foo(first: Array, second: Array) = Pair(first.toCollection(), second.toCollection()) \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/kt11266.ni.txt b/compiler/testData/diagnostics/testsWithStdLib/inference/kt11266.ni.txt new file mode 100644 index 00000000000..71d97fe0ee3 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/kt11266.ni.txt @@ -0,0 +1,3 @@ +package + +public fun foo(/*0*/ first: kotlin.Array, /*1*/ second: kotlin.Array): kotlin.Pair, kotlin.collections.MutableCollection> diff --git a/compiler/testData/diagnostics/testsWithStdLib/java/concurrentHashMapContains.kt b/compiler/testData/diagnostics/testsWithStdLib/java/concurrentHashMapContains.kt index 69214b467ba..548ff81ca33 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/java/concurrentHashMapContains.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/java/concurrentHashMapContains.kt @@ -1,3 +1,4 @@ +// !WITH_NEW_INFERENCE // FULL_JDK class A : java.util.concurrent.ConcurrentHashMap() { @@ -27,8 +28,8 @@ fun main() { "" in (hm as Map) "" !in (hm as Map) - 1 in (hm as Map) - 1 !in (hm as Map) + 1 in (hm as Map) + 1 !in (hm as Map) val a = A() "" in a @@ -43,8 +44,8 @@ fun main() { "" in (a as Map) "" !in (a as Map) - 1 in (a as Map) - 1 !in (a as Map) + 1 in (a as Map) + 1 !in (a as Map) val b = B() "" in b @@ -57,8 +58,8 @@ fun main() { "" in (b as Map) "" !in (b as Map) - 1 in (b as Map) - 1 !in (b as Map) + 1 in (b as Map) + 1 !in (b as Map) // Actually, we could've allow calls here because the owner explicitly declared as operator, but semantics is still weird val c = C() @@ -72,7 +73,7 @@ fun main() { "" in (c as Map) "" !in (c as Map) - 1 in (c as Map) - 1 !in (c as Map) + 1 in (c as Map) + 1 !in (c as Map) } diff --git a/compiler/testData/diagnostics/testsWithStdLib/java/concurrentHashMapContainsError.kt b/compiler/testData/diagnostics/testsWithStdLib/java/concurrentHashMapContainsError.kt index 21e60701ba6..042d8af1725 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/java/concurrentHashMapContainsError.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/java/concurrentHashMapContainsError.kt @@ -1,4 +1,5 @@ // !LANGUAGE: +ProhibitConcurrentHashMapContains +// !WITH_NEW_INFERENCE // FULL_JDK class A : java.util.concurrent.ConcurrentHashMap() { @@ -28,8 +29,8 @@ fun main() { "" in (hm as Map) "" !in (hm as Map) - 1 in (hm as Map) - 1 !in (hm as Map) + 1 in (hm as Map) + 1 !in (hm as Map) val a = A() "" in a @@ -44,8 +45,8 @@ fun main() { "" in (a as Map) "" !in (a as Map) - 1 in (a as Map) - 1 !in (a as Map) + 1 in (a as Map) + 1 !in (a as Map) val b = B() "" in b @@ -58,8 +59,8 @@ fun main() { "" in (b as Map) "" !in (b as Map) - 1 in (b as Map) - 1 !in (b as Map) + 1 in (b as Map) + 1 !in (b as Map) // Actually, we could've allow calls here because the owner explicitly declared as operator, but semantics is still weird val c = C() @@ -73,7 +74,7 @@ fun main() { "" in (c as Map) "" !in (c as Map) - 1 in (c as Map) - 1 !in (c as Map) + 1 in (c as Map) + 1 !in (c as Map) } diff --git a/compiler/testData/diagnostics/testsWithStdLib/kt7585/delegate.kt b/compiler/testData/diagnostics/testsWithStdLib/kt7585/delegate.kt index c5bb85d36d6..557e9ba6a6b 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/kt7585/delegate.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/kt7585/delegate.kt @@ -1,3 +1,5 @@ +// !WITH_NEW_INFERENCE +// NI_EXPECTED_FILE // JAVAC_EXPECTED_FILE // FILE: Base.java diff --git a/compiler/testData/diagnostics/testsWithStdLib/kt7585/delegate.ni.txt b/compiler/testData/diagnostics/testsWithStdLib/kt7585/delegate.ni.txt new file mode 100644 index 00000000000..6989b64f912 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/kt7585/delegate.ni.txt @@ -0,0 +1,82 @@ +package + +public interface Base { + 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 Derived : Base, Other { + public constructor Derived() + public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String +} + +public final class DerivedWrapper : Wrapper> { + public constructor DerivedWrapper(/*0*/ v: Derived<*>) + public final override /*1*/ /*fake_override*/ val v: Derived<*> + 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 Exotic : Base, Other { + public/*package*/ constructor Exotic(/*0*/ x: kotlin.Int) + public/*package*/ final var x: kotlin.Int + public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String +} + +public final class ExoticWrapper : Wrapper { + public constructor ExoticWrapper(/*0*/ v: Exotic) + public final override /*1*/ /*fake_override*/ val v: Exotic + 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 My { + public constructor My(/*0*/ x: kotlin.Int) + public final val wrapper: Wrapper! + public final val x: kotlin.Int + 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 object MyBase { + private constructor MyBase() + public final fun derived(): Derived + public final fun derivedWrapper(): DerivedWrapper + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final fun exotic(/*0*/ x: kotlin.Int): Exotic + public final fun exoticWrapper(/*0*/ x: kotlin.Int): ExoticWrapper + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public interface Other { + 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/*package*/ open class Properties { + public/*package*/ constructor Properties() + 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 + + // Static members + public/*package*/ open fun calcVal(/*0*/ initializer: (() -> T!)!): Val! +} + +public open class Wrapper { + public constructor Wrapper(/*0*/ v: T) + public final val v: T + 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 +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/arrayList.kt b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/arrayList.kt index 10dc52d1f23..cf4acb7060f 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/arrayList.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/arrayList.kt @@ -1,4 +1,5 @@ // !DIAGNOSTICS: -UNUSED_VARIABLE +// !WITH_NEW_INFERENCE import java.util.* fun bar(): String? = null @@ -13,10 +14,10 @@ fun foo() { x[0] = bar() x[0] = "" - val b1: MutableList = x + val b1: MutableList = x val b2: MutableList = x val b3: List = x val b4: Collection = x - val b6: MutableCollection = x + val b6: MutableCollection = x } \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/arrayListNullable.kt b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/arrayListNullable.kt index fad8fa935c2..b014f174616 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/arrayListNullable.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/arrayListNullable.kt @@ -1,4 +1,5 @@ // !DIAGNOSTICS: -UNUSED_VARIABLE +// !WITH_NEW_INFERENCE import java.util.* fun bar(): String? = null @@ -14,7 +15,7 @@ fun foo() { x[0] = "" val b1: MutableList = x - val b2: MutableList = x + val b2: MutableList = x val b3: List = x val b4: Collection = x diff --git a/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/customClassMutableCollection.kt b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/customClassMutableCollection.kt index a02b987d6d4..d201e11415d 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/customClassMutableCollection.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/customClassMutableCollection.kt @@ -1,4 +1,5 @@ // !DIAGNOSTICS: -UNUSED_VARIABLE +// !WITH_NEW_INFERENCE // JAVAC_EXPECTED_FILE import java.util.*; @@ -28,5 +29,5 @@ fun foo() { x.add("") val b1: Collection = x - val b2: MutableCollection = x + val b2: MutableCollection = x } diff --git a/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/customClassMutableList.kt b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/customClassMutableList.kt index 2db8b8487dc..d832be28d31 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/customClassMutableList.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/customClassMutableList.kt @@ -1,4 +1,5 @@ // !DIAGNOSTICS: -UNUSED_VARIABLE +// !WITH_NEW_INFERENCE // JAVAC_EXPECTED_FILE import java.util.*; @@ -31,10 +32,10 @@ fun foo() { x[0] = bar() x[0] = "" - val b1: MutableList = x + val b1: MutableList = x val b2: MutableList = x val b3: List = x val b4: Collection = x - val b6: MutableCollection = x + val b6: MutableCollection = x } diff --git a/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/maps.kt b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/maps.kt index 8cb8a523cf8..113f1266686 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/maps.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/maps.kt @@ -1,4 +1,5 @@ // !DIAGNOSTICS: -UNUSED_VARIABLE +// !WITH_NEW_INFERENCE import java.util.* import java.util.concurrent.* @@ -12,19 +13,19 @@ fun hashMapTest() { x.put(bar(), 1) x.put("", 1) - x[null] = 1 - x[bar()] = 1 - x[""] = nullableInt + x[null] = 1 + x[bar()] = 1 + x[""] = nullableInt x[""] = 1 - val b1: MutableMap = x + val b1: MutableMap = x val b2: MutableMap = x - val b3: Map = x - val b4: Map = x + val b3: Map = x + val b4: Map = x val b5: Map = x - val b6: Int = x[""] - val b7: Int = x.get("") + val b6: Int = x[""] + val b7: Int = x.get("") val b8: Int? = x.get("") } @@ -36,19 +37,19 @@ fun treeMapTest() { x.put(bar(), 1) x.put("", 1) - x[null] = 1 - x[bar()] = 1 - x[""] = nullableInt + x[null] = 1 + x[bar()] = 1 + x[""] = nullableInt x[""] = 1 - val b1: MutableMap = x + val b1: MutableMap = x val b2: MutableMap = x - val b3: Map = x - val b4: Map = x + val b3: Map = x + val b4: Map = x val b5: Map = x - val b6: Int = x[""] - val b7: Int = x.get("") + val b6: Int = x[""] + val b7: Int = x.get("") val b8: Int? = x.get("") } @@ -60,19 +61,19 @@ fun concurrentHashMapTest() { x.put(bar(), 1) x.put("", 1) - x[null] = 1 - x[bar()] = 1 - x[""] = nullableInt + x[null] = 1 + x[bar()] = 1 + x[""] = nullableInt x[""] = 1 - val b1: MutableMap = x + val b1: MutableMap = x val b2: MutableMap = x - val b3: Map = x - val b4: Map = x + val b3: Map = x + val b4: Map = x val b5: Map = x - val b6: Int = x[""] - val b7: Int = x.get("") + val b6: Int = x[""] + val b7: Int = x.get("") val b8: Int? = x.get("") } diff --git a/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/mapsWithNullableKey.kt b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/mapsWithNullableKey.kt index cbf06958749..e12993e2cf3 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/mapsWithNullableKey.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/mapsWithNullableKey.kt @@ -1,4 +1,5 @@ // !DIAGNOSTICS: -UNUSED_VARIABLE +// !WITH_NEW_INFERENCE import java.util.* fun bar(): String? = null @@ -13,18 +14,18 @@ fun hashMapTest() { x[null] = 1 x[bar()] = 1 - x[""] = nullableInt + x[""] = nullableInt x[""] = 1 - val b1: MutableMap = x + val b1: MutableMap = x val b2: MutableMap = x val b3: Map = x val b4: Map = x - val b5: Map = x + val b5: Map = x - val b6: Int = x[""] - val b7: Int = x[null] - val b8: Int = x.get("") + val b6: Int = x[""] + val b7: Int = x[null] + val b8: Int = x.get("") val b9: Int? = x.get("") } @@ -38,17 +39,17 @@ fun treeMapTest() { x[null] = 1 x[bar()] = 1 - x[""] = nullableInt + x[""] = nullableInt x[""] = 1 - val b1: MutableMap = x + val b1: MutableMap = x val b2: MutableMap = x val b3: Map = x val b4: Map = x - val b5: Map = x + val b5: Map = x - val b6: Int = x[""] - val b7: Int = x.get("") + val b6: Int = x[""] + val b7: Int = x.get("") val b8: Int? = x.get("") } diff --git a/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/mapsWithNullableValues.kt b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/mapsWithNullableValues.kt index 2727dcaee70..665c16827df 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/mapsWithNullableValues.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/mapsWithNullableValues.kt @@ -1,4 +1,5 @@ // !DIAGNOSTICS: -UNUSED_VARIABLE +// !WITH_NEW_INFERENCE import java.util.* fun bar(): String? = null @@ -11,19 +12,19 @@ fun hashMapTest() { x.put(bar(), 1) x.put("", 1) - x[null] = 1 - x[bar()] = 1 + x[null] = 1 + x[bar()] = 1 x[""] = nullableInt x[""] = 1 - val b1: MutableMap = x + val b1: MutableMap = x val b2: MutableMap = x - val b3: Map = x + val b3: Map = x val b4: Map = x - val b5: Map = x + val b5: Map = x - val b6: Int = x[""] - val b7: Int = x.get("") + val b6: Int = x[""] + val b7: Int = x.get("") val b8: Int? = x.get("") } @@ -35,19 +36,19 @@ fun treeMapTest() { x.put(bar(), 1) x.put("", 1) - x[null] = 1 - x[bar()] = 1 + x[null] = 1 + x[bar()] = 1 x[""] = nullableInt x[""] = 1 - val b1: MutableMap = x + val b1: MutableMap = x val b2: MutableMap = x - val b3: Map = x + val b3: Map = x val b4: Map = x - val b5: Map = x + val b5: Map = x - val b6: Int = x[""] - val b7: Int = x.get("") + val b6: Int = x[""] + val b7: Int = x.get("") val b8: Int? = x.get("") } diff --git a/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/sets.kt b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/sets.kt index 7e37f0d0b55..17d67f04599 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/sets.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/sets.kt @@ -1,4 +1,5 @@ // !DIAGNOSTICS: -UNUSED_VARIABLE +// !WITH_NEW_INFERENCE import java.util.* fun bar(): String? = null @@ -9,12 +10,12 @@ fun fooHashSet() { x.add(bar()) x.add("") - val b1: MutableSet = x + val b1: MutableSet = x val b2: MutableSet = x val b3: Set = x val b4: Collection = x - val b6: MutableCollection = x + val b6: MutableCollection = x } fun fooTreeSet() { @@ -23,12 +24,12 @@ fun fooTreeSet() { x.add(bar()) x.add("") - val b1: MutableSet = x + val b1: MutableSet = x val b2: MutableSet = x val b3: Set = x val b4: Collection = x - val b6: MutableCollection = x + val b6: MutableCollection = x } fun fooLinkedHashSet() { @@ -37,10 +38,10 @@ fun fooLinkedHashSet() { x.add(bar()) x.add("") - val b1: MutableSet = x + val b1: MutableSet = x val b2: MutableSet = x val b3: Set = x val b4: Collection = x - val b6: MutableCollection = x + val b6: MutableCollection = x } diff --git a/compiler/testData/diagnostics/testsWithStdLib/reified/arrayConstruction.kt b/compiler/testData/diagnostics/testsWithStdLib/reified/arrayConstruction.kt index 6c46aac5dc2..0390aedf06c 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/reified/arrayConstruction.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/reified/arrayConstruction.kt @@ -1,15 +1,16 @@ +// !WITH_NEW_INFERENCE fun fail1(): Array = Array(1) { null!! } fun ok1(block: () -> Array): Array = block() inline fun ok2(): Array = Array(1) { null!! } -fun fail2(): Array = ok1 { Array<T>(1) { null!! } } +fun fail2(): Array = ok1 { Array<T>(1) { null!! } } fun ok3(block: () -> Array): Array = ok1 { block() } inline fun ok4(): Array = ok1 { Array(1) { null!! } } -fun fail3(block: () -> T): Pair, Array> = Pair(arrayOf( - block()), arrayOf() +fun fail3(block: () -> T): Pair, Array> = Pair(arrayOf( + block()), arrayOf() ) inline fun ok5(block: () -> T): Pair, Array> = Pair( arrayOf(block()), arrayOf() diff --git a/compiler/testData/diagnostics/testsWithStdLib/reified/reifiedNothingSubstitution.kt b/compiler/testData/diagnostics/testsWithStdLib/reified/reifiedNothingSubstitution.kt index 66926adcc88..be4b0fbc813 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/reified/reifiedNothingSubstitution.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/reified/reifiedNothingSubstitution.kt @@ -1,15 +1,16 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER -UNREACHABLE_CODE -UNUSED_VARIABLE -DEPRECATION +// !WITH_NEW_INFERENCE inline fun foo(block: () -> T): String = block().toString() inline fun javaClass(): Class = T::class.java fun box() { - val a = arrayOf(null!!) + val a = arrayOf(null!!) val b = Array<Nothing?>(5) { null!! } - val c = foo() { null!! } + val c = foo() { null!! } val d = foo { null!! } - val e = foo { "1" as Nothing } + val e = foo { "1" as Nothing } val e1 = foo { "1" as Nothing? } val f = javaClass<Nothing>() diff --git a/compiler/testData/diagnostics/testsWithStdLib/resolve/kt4711.kt b/compiler/testData/diagnostics/testsWithStdLib/resolve/kt4711.kt index 8ce97e5bad8..adc0cbdf402 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/resolve/kt4711.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/resolve/kt4711.kt @@ -1,3 +1,4 @@ +// !WITH_NEW_INFERENCE //KT-4711 Error type with no error reported from type inference fun main() { @@ -6,15 +7,15 @@ fun main() { val startTimeNanos = System.nanoTime() // the problem sits on the next line: - val pi = 4.0.toDouble() * delta * (1..n).reduce( + val pi = 4.0.toDouble() * delta * (1..n).reduce( {t, i -> val x = (i - 0.5) * delta - t + 1.0 / (1.0 + x * x) + t + 1.0 / (1.0 + x * x) }) // !!! pi has error type here val elapseTime = (System.nanoTime() - startTimeNanos) / 1e9 - println("pi_sequential_reduce $pi $n $elapseTime") + println("pi_sequential_reduce $pi $n $elapseTime") } diff --git a/compiler/testData/diagnostics/testsWithStdLib/resolve/samAgainstFunctionalType.kt b/compiler/testData/diagnostics/testsWithStdLib/resolve/samAgainstFunctionalType.kt index 8b2f3adab2f..ecf9528902f 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/resolve/samAgainstFunctionalType.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/resolve/samAgainstFunctionalType.kt @@ -1,3 +1,4 @@ +// !WITH_NEW_INFERENCE // !CHECK_TYPE // FILE: StaticOverrides.java @@ -23,7 +24,7 @@ public class StaticOverrides { // FILE: test.kt fun test() { - StaticOverrides.A.foo {} checkType { _() } + StaticOverrides.A.foo {} checkType { _() } StaticOverrides.B.foo {} checkType { _() } - StaticOverrides.C.foo {} checkType { _() } + StaticOverrides.C.foo {} checkType { _() } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/resolve/samOverloadsWithGenerics.kt b/compiler/testData/diagnostics/testsWithStdLib/resolve/samOverloadsWithGenerics.kt index d86d1794c73..1eede6d5efe 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/resolve/samOverloadsWithGenerics.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/resolve/samOverloadsWithGenerics.kt @@ -1,5 +1,6 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER // !CHECK_TYPE +// !WITH_NEW_INFERENCE // FILE: Foo.java import kotlin.Unit; @@ -19,6 +20,6 @@ class Foo { // FILE: 1.kt fun test() { - Foo().foo {} checkType { _() } + Foo().foo {} checkType { _() } Foo().bar {} checkType { _() } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/resolve/samOverloadsWithGenericsWithoutRefinedSams.kt b/compiler/testData/diagnostics/testsWithStdLib/resolve/samOverloadsWithGenericsWithoutRefinedSams.kt index cd4629374b3..cdbae7fb461 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/resolve/samOverloadsWithGenericsWithoutRefinedSams.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/resolve/samOverloadsWithGenericsWithoutRefinedSams.kt @@ -1,6 +1,7 @@ // !LANGUAGE: -RefinedSamAdaptersPriority // !DIAGNOSTICS: -UNUSED_PARAMETER // !CHECK_TYPE +// !WITH_NEW_INFERENCE // FILE: Foo.java import kotlin.Unit; @@ -20,6 +21,6 @@ class Foo { // FILE: 1.kt fun test() { - Foo().foo {} checkType { _() } - Foo().bar {} checkType { _() } + Foo().foo {} checkType { _() } + Foo().bar {} checkType { _() } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/resolve/samOverloadsWithKtFunctionWithoutRefinedSams.kt b/compiler/testData/diagnostics/testsWithStdLib/resolve/samOverloadsWithKtFunctionWithoutRefinedSams.kt index e6f9fb6d2e9..3e756fcdd78 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/resolve/samOverloadsWithKtFunctionWithoutRefinedSams.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/resolve/samOverloadsWithKtFunctionWithoutRefinedSams.kt @@ -1,6 +1,7 @@ // !LANGUAGE: -RefinedSamAdaptersPriority // !DIAGNOSTICS: -UNUSED_PARAMETER // !CHECK_TYPE +// !WITH_NEW_INFERENCE // FILE: Foo.java import kotlin.Unit; @@ -17,5 +18,5 @@ public class Foo { // FILE: 1.kt fun bar() { - Foo().test {} checkType { _() } + Foo().test {} checkType { _() } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/smartcasts/forEachSafe.kt b/compiler/testData/diagnostics/testsWithStdLib/smartcasts/forEachSafe.kt index b61581af7b1..ecd067eed3b 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/smartcasts/forEachSafe.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/smartcasts/forEachSafe.kt @@ -1,9 +1,10 @@ +// !WITH_NEW_INFERENCE // KT-7186: False "Type mismatch" error fun indexOfMax(a: IntArray): Int? { var maxI: Int? = null a.forEachIndexed { i, value -> - if (maxI == null || value >= a[maxI]) { + if (maxI == null || value >= a[maxI]) { maxI = i } } diff --git a/compiler/testData/diagnostics/testsWithStdLib/targetedBuiltIns/blackListed.kt b/compiler/testData/diagnostics/testsWithStdLib/targetedBuiltIns/blackListed.kt index 5738db9fc65..8d24e7355f1 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/targetedBuiltIns/blackListed.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/targetedBuiltIns/blackListed.kt @@ -1,8 +1,9 @@ +// !WITH_NEW_INFERENCE // FULL_JDK abstract class A : MutableList { override fun sort(/*0*/ p0: java.util.Comparator) { - super.sort(p0) + super.sort(p0) } } diff --git a/compiler/testData/diagnostics/testsWithStdLib/targetedBuiltIns/unsupportedFeature.kt b/compiler/testData/diagnostics/testsWithStdLib/targetedBuiltIns/unsupportedFeature.kt index 21443a83e00..3b81ee3d9ce 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/targetedBuiltIns/unsupportedFeature.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/targetedBuiltIns/unsupportedFeature.kt @@ -1,5 +1,6 @@ // !CHECK_TYPE // !LANGUAGE: -AdditionalBuiltInsMembers +// !WITH_NEW_INFERENCE // SKIP_TXT // FULL_JDK @@ -27,7 +28,7 @@ interface A2 : List { override fun stream(): java.util.stream.Stream = null!! } -class B : Throwable("", null, false, false) +class B : Throwable("", null, false, false) class B1 : RuntimeException() { override fun fillInStackTrace(): Throwable { // 'override' keyword must be prohibited, as it was in 1.0.x diff --git a/compiler/testData/diagnostics/testsWithStdLib/when/noTypeArgumentsInConstructor.kt b/compiler/testData/diagnostics/testsWithStdLib/when/noTypeArgumentsInConstructor.kt index b61e8987e4a..12bae0c69a8 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/when/noTypeArgumentsInConstructor.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/when/noTypeArgumentsInConstructor.kt @@ -1,3 +1,5 @@ +// !WITH_NEW_INFERENCE + import java.util.* fun nullable(x: T): T? = x @@ -26,7 +28,7 @@ val test4: Collection = } val test5: Collection = - listOf(1, 2, 3).flatMapTo(LinkedHashSet()) { // TODO + listOf(1, 2, 3).flatMapTo(LinkedHashSet()) { // TODO if (true) listOf(it) else listOf(it) }