From 033ff38fef2ae61cdcd2ba8e55e105dcbbb82ae1 Mon Sep 17 00:00:00 2001 From: "Denis.Zharkov" Date: Tue, 8 Aug 2023 10:14:16 +0200 Subject: [PATCH] K2: Adjust diagnostic test data after delegate inference is rewritten In all tests, some red-code diagnostics have changed insignificantly to some other combination or red-code diagnostics ^KT-61060 Related --- .../localVariablesWithTypeParameters_1_3.fir.kt | 2 +- .../localVariablesWithTypeParameters_1_4.fir.kt | 2 +- .../differentDelegatedExpressions.fir.kt | 4 ++-- .../inference/extensionProperty.fir.kt | 4 ++-- .../genericMethodInGenericClass.fir.kt | 2 +- .../noExpectedTypeForSupertypeConstraint.fir.kt | 17 ----------------- .../noExpectedTypeForSupertypeConstraint.kt | 1 + ...oInferenceFromGetValueThroughSetValue.fir.kt | 2 +- .../propertyDefferedType.fir.kt | 2 +- .../provideDelegate/hostAndReceiver2.fir.kt | 13 ------------- .../provideDelegate/hostAndReceiver2.kt | 1 + .../buildListToUpperBoundInLazy.fir.kt | 4 ++-- .../buildListToUpperBoundInLazyForbidden.fir.kt | 4 ++-- 13 files changed, 15 insertions(+), 43 deletions(-) delete mode 100644 compiler/testData/diagnostics/tests/delegatedProperty/inference/noExpectedTypeForSupertypeConstraint.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/delegatedProperty/provideDelegate/hostAndReceiver2.fir.kt diff --git a/compiler/testData/diagnostics/tests/declarationChecks/localVariablesWithTypeParameters_1_3.fir.kt b/compiler/testData/diagnostics/tests/declarationChecks/localVariablesWithTypeParameters_1_3.fir.kt index b114049a1ca..910a8041aff 100644 --- a/compiler/testData/diagnostics/tests/declarationChecks/localVariablesWithTypeParameters_1_3.fir.kt +++ b/compiler/testData/diagnostics/tests/declarationChecks/localVariablesWithTypeParameters_1_3.fir.kt @@ -10,7 +10,7 @@ fun test() { const val a3 = 0 lateinit val a4 = 0 val a5 by Delegate() - val a6 by Delegate<T>() + val a6 by Delegate<T>() } class Delegate { diff --git a/compiler/testData/diagnostics/tests/declarationChecks/localVariablesWithTypeParameters_1_4.fir.kt b/compiler/testData/diagnostics/tests/declarationChecks/localVariablesWithTypeParameters_1_4.fir.kt index e2bf4d1269a..dfeb9546b4f 100644 --- a/compiler/testData/diagnostics/tests/declarationChecks/localVariablesWithTypeParameters_1_4.fir.kt +++ b/compiler/testData/diagnostics/tests/declarationChecks/localVariablesWithTypeParameters_1_4.fir.kt @@ -10,7 +10,7 @@ fun test() { const val a3 = 0 lateinit val a4 = 0 val a5 by Delegate() - val a6 by Delegate<T>() + val a6 by Delegate<T>() } class Delegate { diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/inference/differentDelegatedExpressions.fir.kt b/compiler/testData/diagnostics/tests/delegatedProperty/inference/differentDelegatedExpressions.fir.kt index 082677465c2..0236a86a45b 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/inference/differentDelegatedExpressions.fir.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/inference/differentDelegatedExpressions.fir.kt @@ -9,8 +9,8 @@ class A(outer: Outer) { var g: String by outer.getContainer().getMyProperty() - var b: String by foo(getMyProperty()) - var r: String by foo(outer.getContainer().getMyProperty()) + var b: String by foo(getMyProperty()) + var r: String by foo(outer.getContainer().getMyProperty()) var e: String by + foo(getMyProperty()) var f: String by foo(getMyProperty()) - 1 } diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/inference/extensionProperty.fir.kt b/compiler/testData/diagnostics/tests/delegatedProperty/inference/extensionProperty.fir.kt index 849db3921d2..6d6567c8f9c 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/inference/extensionProperty.fir.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/inference/extensionProperty.fir.kt @@ -3,10 +3,10 @@ package foo import kotlin.reflect.KProperty open class A { - val B.w: Int by MyProperty() + val B.w: Int by MyProperty() } -val B.r: Int by MyProperty() +val B.r: Int by MyProperty() val A.e: Int by MyProperty() diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/inference/genericMethodInGenericClass.fir.kt b/compiler/testData/diagnostics/tests/delegatedProperty/inference/genericMethodInGenericClass.fir.kt index 6c2b0d91eff..d85239e384a 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/inference/genericMethodInGenericClass.fir.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/inference/genericMethodInGenericClass.fir.kt @@ -7,7 +7,7 @@ class A() { operator fun setValue(t: Any?, p: KProperty<*>, x: T) = Unit } -var a1: Int by A() +var a1: Int by A() var a2: Int by A() class B() { diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/inference/noExpectedTypeForSupertypeConstraint.fir.kt b/compiler/testData/diagnostics/tests/delegatedProperty/inference/noExpectedTypeForSupertypeConstraint.fir.kt deleted file mode 100644 index 4fe8fd06191..00000000000 --- a/compiler/testData/diagnostics/tests/delegatedProperty/inference/noExpectedTypeForSupertypeConstraint.fir.kt +++ /dev/null @@ -1,17 +0,0 @@ -// NI_EXPECTED_FILE -import kotlin.reflect.KProperty - -class A { - var a by MyProperty() -} - -class MyProperty { - - operator fun getValue(thisRef: R, desc: KProperty<*>): T { - throw Exception("$thisRef $desc") - } - - operator fun setValue(thisRef: R, desc: KProperty<*>, t: T) { - throw Exception("$thisRef $desc $t") - } -} diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/inference/noExpectedTypeForSupertypeConstraint.kt b/compiler/testData/diagnostics/tests/delegatedProperty/inference/noExpectedTypeForSupertypeConstraint.kt index e170ab23d91..1026a90fcd7 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/inference/noExpectedTypeForSupertypeConstraint.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/inference/noExpectedTypeForSupertypeConstraint.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // NI_EXPECTED_FILE import kotlin.reflect.KProperty diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/noInferenceFromGetValueThroughSetValue.fir.kt b/compiler/testData/diagnostics/tests/delegatedProperty/noInferenceFromGetValueThroughSetValue.fir.kt index 2258aa5c332..eeeadf6dd3b 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/noInferenceFromGetValueThroughSetValue.fir.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/noInferenceFromGetValueThroughSetValue.fir.kt @@ -9,7 +9,7 @@ operator fun M.setValue(thisRef: Any?, property: KProperty<*>, value: fun m(): M = M() // We don't allow to infer type of a delegate expression through a setValue, where the argument (value) is constrained by the return type of a getValue -var a by m() +var a by m() // We infer type of delegate expression through a setValue from the explicit property type var b: String by m() diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/propertyDefferedType.fir.kt b/compiler/testData/diagnostics/tests/delegatedProperty/propertyDefferedType.fir.kt index cd444a26355..fe0ad449e8e 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/propertyDefferedType.fir.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/propertyDefferedType.fir.kt @@ -4,7 +4,7 @@ import kotlin.reflect.KProperty class B { - val c by Delegate(ag) + val c by Delegate(ag) } class Delegate(val init: T) { diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/provideDelegate/hostAndReceiver2.fir.kt b/compiler/testData/diagnostics/tests/delegatedProperty/provideDelegate/hostAndReceiver2.fir.kt deleted file mode 100644 index 4a4fe2bf30e..00000000000 --- a/compiler/testData/diagnostics/tests/delegatedProperty/provideDelegate/hostAndReceiver2.fir.kt +++ /dev/null @@ -1,13 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER - -object T2 { - interface Foo - - fun delegate(): Foo = TODO() - - operator fun Foo.provideDelegate(host: T2, p: Any?): Foo = TODO() - operator fun Foo.getValue(receiver: String, p: Any?): T = TODO() - - val String.test1: String by delegate() - val test2: String by delegate() -} diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/provideDelegate/hostAndReceiver2.kt b/compiler/testData/diagnostics/tests/delegatedProperty/provideDelegate/hostAndReceiver2.kt index 88fd51b3f3b..72808b722b1 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/provideDelegate/hostAndReceiver2.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/provideDelegate/hostAndReceiver2.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER object T2 { diff --git a/compiler/testData/diagnostics/testsWithStdLib/builderInference/buildListToUpperBoundInLazy.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/builderInference/buildListToUpperBoundInLazy.fir.kt index d919a503b59..236d6924d5c 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/builderInference/buildListToUpperBoundInLazy.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/builderInference/buildListToUpperBoundInLazy.fir.kt @@ -28,7 +28,7 @@ internal class TowerDataElementsForName2() { } internal class TowerDataElementsForName3() { - val reversedFilteredLocalScopes by lazy(LazyThreadSafetyMode.NONE) { + val reversedFilteredLocalScopes by lazy(LazyThreadSafetyMode.NONE) { @OptIn(ExperimentalStdlibApi::class) buildList l1@ { for (i in lastIndex downTo 0) { @@ -43,7 +43,7 @@ internal class TowerDataElementsForName3() { } } } - } + } } internal class TowerDataElementsForName4() { diff --git a/compiler/testData/diagnostics/testsWithStdLib/builderInference/buildListToUpperBoundInLazyForbidden.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/builderInference/buildListToUpperBoundInLazyForbidden.fir.kt index 28f32fab533..f027088ea41 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/builderInference/buildListToUpperBoundInLazyForbidden.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/builderInference/buildListToUpperBoundInLazyForbidden.fir.kt @@ -28,7 +28,7 @@ internal class TowerDataElementsForName2() { } internal class TowerDataElementsForName3() { - val reversedFilteredLocalScopes by lazy(LazyThreadSafetyMode.NONE) { + val reversedFilteredLocalScopes by lazy(LazyThreadSafetyMode.NONE) { @OptIn(ExperimentalStdlibApi::class) buildList l1@ { for (i in lastIndex downTo 0) { @@ -43,7 +43,7 @@ internal class TowerDataElementsForName3() { } } } - } + } } internal class TowerDataElementsForName4() {