From bf92280f520396085d168c8bfa87d77efda4d92a Mon Sep 17 00:00:00 2001 From: Mikhail Zarechenskiy Date: Tue, 20 Mar 2018 02:45:28 +0300 Subject: [PATCH] [NI] Update testdata about inference for delegated properties --- .../inference/differentDelegatedExpressions.kt | 8 ++++---- .../delegatedProperty/inference/extensionProperty.kt | 4 ++-- .../inference/genericMethodInGenericClass.kt | 6 +++--- .../inference/noErrorsForImplicitConstraints.kt | 8 ++++---- .../inference/noExpectedTypeForSupertypeConstraint.kt | 2 +- .../noExpectedTypeForSupertypeConstraint.ni.txt | 2 +- .../tests/delegatedProperty/inference/useExpectedType.kt | 9 ++++----- .../noOperatorModifierOnProvideDelegate.kt | 2 +- .../tests/delegatedProperty/provideDelegate/setValue.kt | 2 +- .../unsupportedOperatorProvideDelegate.kt | 2 +- .../diagnostics/tests/delegatedProperty/recursiveType.kt | 6 +++--- .../tests/delegatedProperty/recursiveType.ni.txt | 2 +- .../tests/delegatedProperty/setterThisTypeMismatch.kt | 5 +++-- .../tests/delegatedProperty/thisOfNothingNullableType.kt | 1 + .../tests/delegatedProperty/thisOfNothingType.kt | 1 + .../delegatedProperty/typeMismatchForGetReturnType.kt | 2 +- .../delegatedProperty/typeMismatchForSetParameter.kt | 5 +++-- .../delegatedProperty/typeMismatchForThisGetParameter.kt | 1 + 18 files changed, 36 insertions(+), 32 deletions(-) diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/inference/differentDelegatedExpressions.kt b/compiler/testData/diagnostics/tests/delegatedProperty/inference/differentDelegatedExpressions.kt index 3b587e9a4c0..a4ed5afc2ec 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/inference/differentDelegatedExpressions.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/inference/differentDelegatedExpressions.kt @@ -10,10 +10,10 @@ 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 e: String by + foo(getMyProperty()) - var f: String by foo(getMyProperty()) - 1 + 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 } fun foo(a: Any?) = MyProperty() diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/inference/extensionProperty.kt b/compiler/testData/diagnostics/tests/delegatedProperty/inference/extensionProperty.kt index dda04dffa4d..352b8c0ae37 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/inference/extensionProperty.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/inference/extensionProperty.kt @@ -4,10 +4,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.kt b/compiler/testData/diagnostics/tests/delegatedProperty/inference/genericMethodInGenericClass.kt index 6a4e9ec254f..88d5349cfed 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/inference/genericMethodInGenericClass.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/inference/genericMethodInGenericClass.kt @@ -8,7 +8,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() { @@ -24,5 +24,5 @@ class C() { operator fun setValue(t: Any?, p: KProperty<*>, x: T) = Unit } -var c1: Int by C() -var c2: Int by C() +var c1: Int by C() +var c2: Int by C() diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/inference/noErrorsForImplicitConstraints.kt b/compiler/testData/diagnostics/tests/delegatedProperty/inference/noErrorsForImplicitConstraints.kt index 2a587abd4d2..2eaa7696d00 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/inference/noErrorsForImplicitConstraints.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/inference/noErrorsForImplicitConstraints.kt @@ -4,8 +4,8 @@ package foo import kotlin.reflect.KProperty class A { - var a5: String by MyProperty1() - var b5: String by getMyProperty1() + var a5: String by MyProperty1() + var b5: String by getMyProperty1() } fun getMyProperty1() = MyProperty1() @@ -24,8 +24,8 @@ class MyProperty1 { // ----------------- class B { - var a5: String by MyProperty2() - var b5: String by getMyProperty2() + var a5: String by MyProperty2() + var b5: String by getMyProperty2() } fun getMyProperty2() = MyProperty2() diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/inference/noExpectedTypeForSupertypeConstraint.kt b/compiler/testData/diagnostics/tests/delegatedProperty/inference/noExpectedTypeForSupertypeConstraint.kt index 42d7537bd63..773be6498e8 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/inference/noExpectedTypeForSupertypeConstraint.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/inference/noExpectedTypeForSupertypeConstraint.kt @@ -3,7 +3,7 @@ import kotlin.reflect.KProperty class A { - var a by MyProperty() + var a by MyProperty() } class MyProperty { diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/inference/noExpectedTypeForSupertypeConstraint.ni.txt b/compiler/testData/diagnostics/tests/delegatedProperty/inference/noExpectedTypeForSupertypeConstraint.ni.txt index cfd09a74728..d84065a23cc 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/inference/noExpectedTypeForSupertypeConstraint.ni.txt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/inference/noExpectedTypeForSupertypeConstraint.ni.txt @@ -2,7 +2,7 @@ package public final class A { public constructor A() - public final var a: kotlin.Nothing + public final var a: [ERROR : Type from delegate] 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/tests/delegatedProperty/inference/useExpectedType.kt b/compiler/testData/diagnostics/tests/delegatedProperty/inference/useExpectedType.kt index c38ea969320..2b4955d7f04 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/inference/useExpectedType.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/inference/useExpectedType.kt @@ -1,4 +1,3 @@ -// !WITH_NEW_INFERENCE package foo import kotlin.reflect.KProperty @@ -52,12 +51,12 @@ class MyProperty2 { //-------------------------- class A3 { - var a3: String by MyProperty3() - var b3: String by getMyProperty3() + var a3: String by MyProperty3() + var b3: String by getMyProperty3() } -var c3: String by getMyProperty3() -var d3: String by MyProperty3() +var c3: String by getMyProperty3() +var d3: String by MyProperty3() fun getMyProperty3() = MyProperty3() diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/provideDelegate/noOperatorModifierOnProvideDelegate.kt b/compiler/testData/diagnostics/tests/delegatedProperty/provideDelegate/noOperatorModifierOnProvideDelegate.kt index e1740e837a5..cd106361977 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/provideDelegate/noOperatorModifierOnProvideDelegate.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/provideDelegate/noOperatorModifierOnProvideDelegate.kt @@ -13,6 +13,6 @@ fun String.provideDelegate(a: Any?, p: KProperty<*>) = StringDelegate(this) operator fun String.getValue(a: Any?, p: KProperty<*>) = this val test1: String by "OK" -val test2: Int by "OK" +val test2: Int by "OK" val test3 by "OK" diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/provideDelegate/setValue.kt b/compiler/testData/diagnostics/tests/delegatedProperty/provideDelegate/setValue.kt index 06cb917614c..6b90d11d8f5 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/provideDelegate/setValue.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/provideDelegate/setValue.kt @@ -11,7 +11,7 @@ operator fun String.provideDelegate(receiver: Any?, p: Any) = Delegate() var test1: String by Delegate() var test2: String by Delegate() -var test3: String by "OK" +var test3: String by "OK" var test4: String by "OK".provideDelegate(null, "") var test5: String by "OK".provideDelegate(null, "") \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/provideDelegate/unsupportedOperatorProvideDelegate.kt b/compiler/testData/diagnostics/tests/delegatedProperty/provideDelegate/unsupportedOperatorProvideDelegate.kt index d73903ce1e0..1e2af347ffe 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/provideDelegate/unsupportedOperatorProvideDelegate.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/provideDelegate/unsupportedOperatorProvideDelegate.kt @@ -11,5 +11,5 @@ class WrongDelegate(val x: Int) { operator fun String.getValue(thisRef: Any?, prop: Any) = this val test1: String by "OK" -val test2: Int by "OK" +val test2: Int by "OK" val test3 by "OK" \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/recursiveType.kt b/compiler/testData/diagnostics/tests/delegatedProperty/recursiveType.kt index c03053ddd7e..2b49ed81dd5 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/recursiveType.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/recursiveType.kt @@ -4,12 +4,12 @@ import kotlin.reflect.KProperty -val a by a +val a by a -val b by Delegate(b) +val b by Delegate(b) val c by d -val d by c +val d by c class Delegate(i: Int) { operator fun getValue(t: Any?, p: KProperty<*>): Int { diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/recursiveType.ni.txt b/compiler/testData/diagnostics/tests/delegatedProperty/recursiveType.ni.txt index a1da67a0de6..763ab410665 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/recursiveType.ni.txt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/recursiveType.ni.txt @@ -2,7 +2,7 @@ package public val a: [ERROR : ] public val b: kotlin.Int -public val c: [ERROR : ] +public val c: [ERROR : Type from delegate] public val d: [ERROR : ] public final class Delegate { diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/setterThisTypeMismatch.kt b/compiler/testData/diagnostics/tests/delegatedProperty/setterThisTypeMismatch.kt index e5ac5d81f00..0033d239e84 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/setterThisTypeMismatch.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/setterThisTypeMismatch.kt @@ -1,12 +1,13 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER +// !WITH_NEW_INFERENCE import kotlin.reflect.KProperty class D { - var c: Int by Delegate() + var c: Int by Delegate() } -var cTopLevel: Int by Delegate() +var cTopLevel: Int by Delegate() class A diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/thisOfNothingNullableType.kt b/compiler/testData/diagnostics/tests/delegatedProperty/thisOfNothingNullableType.kt index 0ef43a4fc44..6c98a7c29e5 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/thisOfNothingNullableType.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/thisOfNothingNullableType.kt @@ -1,4 +1,5 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER +// !WITH_NEW_INFERENCE import kotlin.reflect.KProperty diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/thisOfNothingType.kt b/compiler/testData/diagnostics/tests/delegatedProperty/thisOfNothingType.kt index 1088ea9b8fd..ef29a4d2e0e 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/thisOfNothingType.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/thisOfNothingType.kt @@ -1,4 +1,5 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER +// !WITH_NEW_INFERENCE import kotlin.reflect.KProperty diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/typeMismatchForGetReturnType.kt b/compiler/testData/diagnostics/tests/delegatedProperty/typeMismatchForGetReturnType.kt index 4da869760da..d86d06065ff 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/typeMismatchForGetReturnType.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/typeMismatchForGetReturnType.kt @@ -3,7 +3,7 @@ import kotlin.reflect.KProperty -val c: Int by Delegate() +val c: Int by Delegate() class Delegate { operator fun getValue(t: Any?, p: KProperty<*>): String { diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/typeMismatchForSetParameter.kt b/compiler/testData/diagnostics/tests/delegatedProperty/typeMismatchForSetParameter.kt index c91bcf038b8..3b8626d6c19 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/typeMismatchForSetParameter.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/typeMismatchForSetParameter.kt @@ -1,12 +1,13 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER +// !WITH_NEW_INFERENCE import kotlin.reflect.KProperty class A { - var a: Int by Delegate() + var a: Int by Delegate() } -var aTopLevel: Int by Delegate() +var aTopLevel: Int by Delegate() class Delegate { operator fun getValue(t: Any?, p: KProperty<*>): Int { diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/typeMismatchForThisGetParameter.kt b/compiler/testData/diagnostics/tests/delegatedProperty/typeMismatchForThisGetParameter.kt index 107485fdbc9..8fa5a3f4218 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/typeMismatchForThisGetParameter.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/typeMismatchForThisGetParameter.kt @@ -1,4 +1,5 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER +// !WITH_NEW_INFERENCE import kotlin.reflect.KProperty