From f656a9fdc614a6e53a68aae1d62725e3e5b0a51e Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Wed, 13 Mar 2024 12:09:04 +0100 Subject: [PATCH] Migrate some KT-65789 & KT-58920 tests on using take(arg) --- .../constructorVsCompanionMember.fir.txt | 62 ------------------- .../constructorVsCompanionMember.kt | 19 +++--- .../constructorVsCompanionMember.txt | 44 ------------- .../constructorVsSyntheticValues.fir.kt | 13 ++-- .../constructorVsSyntheticValues.fir.txt | 54 ---------------- .../constructorVsSyntheticValues.kt | 13 ++-- ...tructorVsSyntheticValuesPrioritized.fir.kt | 2 +- ...constructorVsSyntheticValuesPrioritized.kt | 2 +- .../constructorVsTopLevel.fir.txt | 23 ------- .../constructorVsTopLevel.kt | 10 +-- .../constructorVsTopLevel.txt | 19 ------ 11 files changed, 36 insertions(+), 225 deletions(-) delete mode 100644 compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsCompanionMember.fir.txt delete mode 100644 compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsCompanionMember.txt delete mode 100644 compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsSyntheticValues.fir.txt delete mode 100644 compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsTopLevel.fir.txt delete mode 100644 compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsTopLevel.txt diff --git a/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsCompanionMember.fir.txt b/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsCompanionMember.fir.txt deleted file mode 100644 index de21f30ac3d..00000000000 --- a/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsCompanionMember.fir.txt +++ /dev/null @@ -1,62 +0,0 @@ -FILE: constructorVsCompanionMember.kt - package bar - - public final class Owner : R|kotlin/Any| { - public constructor(): R|bar/Owner| { - super() - } - - public final companion object Companion : R|kotlin/Any| { - private constructor(): R|bar/Owner.Companion| { - super() - } - - public final fun Foo(string: R|kotlin/String?|): R|kotlin/Unit| { - } - - public final class Foo : R|kotlin/Any| { - public constructor(str: R|kotlin/String|): R|bar/Owner.Companion.Foo| { - super() - } - - public final val str: R|kotlin/String| = R|/str| - public get(): R|kotlin/String| - - } - - public final fun Bar(string: R|kotlin/String|): R|kotlin/Unit| { - } - - public final class Bar : R|kotlin/Any| { - public constructor(str: R|kotlin/String?|): R|bar/Owner.Companion.Bar| { - super() - } - - public final val str: R|kotlin/String?| = R|/str| - public get(): R|kotlin/String?| - - } - - public final val foo: R|kotlin/Unit| = this@R|bar/Owner.Companion|.R|bar/Owner.Companion.Foo|(String(1)) - public get(): R|kotlin/Unit| - - public final val bar: R|kotlin/Unit| = this@R|bar/Owner.Companion|.R|bar/Owner.Companion.Bar|(String(2)) - public get(): R|kotlin/Unit| - - } - - public final val foo: R|bar/Owner.Companion.Foo| = R|bar/Owner.Companion.Foo.Foo|(String(3)) - public get(): R|bar/Owner.Companion.Foo| - - public final val bar: R|bar/Owner.Companion.Bar| = R|bar/Owner.Companion.Bar.Bar|(String(4)) - public get(): R|bar/Owner.Companion.Bar| - - } - public final val ownerFoo: R|kotlin/Unit| = Q|bar/Owner|.R|bar/Owner.Companion.Foo|(String(1)) - public get(): R|kotlin/Unit| - public final val ownerCompanionFoo: R|bar/Owner.Companion.Foo| = Q|bar/Owner.Companion|.R|bar/Owner.Companion.Foo.Foo|(String(2)) - public get(): R|bar/Owner.Companion.Foo| - public final val ownerBar: R|kotlin/Unit| = Q|bar/Owner|.R|bar/Owner.Companion.Bar|(String(3)) - public get(): R|kotlin/Unit| - public final val ownerCompanionBar: R|bar/Owner.Companion.Bar| = Q|bar/Owner.Companion|.R|bar/Owner.Companion.Bar.Bar|(String(4)) - public get(): R|bar/Owner.Companion.Bar| diff --git a/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsCompanionMember.kt b/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsCompanionMember.kt index e449eb569ea..165e9ec0212 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsCompanionMember.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsCompanionMember.kt @@ -1,10 +1,11 @@ // FIR_IDENTICAL // ISSUE: KT-65789 // DIAGNOSTICS: -DEBUG_INFO_LEAKING_THIS -// FIR_DUMP package bar +fun take(arg: T): T = arg + class Owner { companion object { @@ -16,16 +17,16 @@ class Owner { class Bar(val str: String?) - val foo = Foo("1") // K1/K2: function - val bar = Bar("2") // K1/K2: function + val foo = take(Foo("1")) + val bar = take(Bar("2")) } - val foo = Foo("3") // K1/K2: constructor - val bar = Bar("4") // K1/K2: constructor + val foo = take(Foo("3")) + val bar = take(Bar("4")) } -val ownerFoo = Owner.Foo("1") // K1/K2: function -val ownerCompanionFoo = Owner.Companion.Foo("2") // K1/K2: constructor +val ownerFoo = take(Owner.Foo("1")) +val ownerCompanionFoo = take(Owner.Companion.Foo("2")) -val ownerBar = Owner.Bar("3") // K1/K2: function -val ownerCompanionBar = Owner.Companion.Bar("4") // K1/K2: constructor +val ownerBar = take(Owner.Bar("3")) +val ownerCompanionBar = take(Owner.Companion.Bar("4")) diff --git a/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsCompanionMember.txt b/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsCompanionMember.txt deleted file mode 100644 index 08d83e2132b..00000000000 --- a/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsCompanionMember.txt +++ /dev/null @@ -1,44 +0,0 @@ -package - -package bar { - public val ownerBar: kotlin.Unit - public val ownerCompanionBar: bar.Owner.Companion.Bar - public val ownerCompanionFoo: bar.Owner.Companion.Foo - public val ownerFoo: kotlin.Unit - - public final class Owner { - public constructor Owner() - public final val bar: bar.Owner.Companion.Bar - public final val foo: bar.Owner.Companion.Foo - 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 companion object Companion { - private constructor Companion() - public final val bar: kotlin.Unit - public final val foo: kotlin.Unit - public final fun Bar(/*0*/ string: kotlin.String): kotlin.Unit - public final fun Foo(/*0*/ string: kotlin.String?): 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 - - public final class Bar { - public constructor Bar(/*0*/ str: kotlin.String?) - public final val str: kotlin.String? - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String - } - - public final class Foo { - public constructor Foo(/*0*/ str: kotlin.String) - public final val str: kotlin.String - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String - } - } - } -} diff --git a/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsSyntheticValues.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsSyntheticValues.fir.kt index 4da76a6412e..060fb4eb585 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsSyntheticValues.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsSyntheticValues.fir.kt @@ -1,6 +1,10 @@ -// ISSUE: KT-65789 +// ISSUE: KT-65789, KT-58920 // LANGUAGE: -PrioritizedEnumEntries -// FIR_DUMP +// WITH_REFLECT + +import kotlin.reflect.* + +fun take(arg: T): T = arg enum class SomeClass { FIRST, LAST; @@ -15,5 +19,6 @@ enum class SomeClass { val resultValues = SomeClass.values() val resultValuesRef = SomeClass::values -val resultEntries = SomeClass.entries -val resultEntriesRef = SomeClass::entries + +val resultEntries = take(SomeClass.entries) +val resultEntriesRef = take>(SomeClass::entries) diff --git a/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsSyntheticValues.fir.txt b/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsSyntheticValues.fir.txt deleted file mode 100644 index 9f2b9c4cf2d..00000000000 --- a/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsSyntheticValues.fir.txt +++ /dev/null @@ -1,54 +0,0 @@ -FILE: constructorVsSyntheticValues.fir.kt - public final enum class SomeClass : R|kotlin/Enum| { - private constructor(): R|SomeClass| { - super|>() - } - - public final static enum entry FIRST: R|SomeClass| - public final static enum entry LAST: R|SomeClass| - public final class values : R|kotlin/Any| { - public constructor(): R|SomeClass.values| { - super() - } - - public final companion object Companion : R|kotlin/Any| { - private constructor(): R|SomeClass.values.Companion| { - super() - } - - } - - } - - public final class entries : R|kotlin/Any| { - public constructor(): R|SomeClass.entries| { - super() - } - - public final companion object Companion : R|kotlin/Any| { - private constructor(): R|SomeClass.entries.Companion| { - super() - } - - } - - } - - public final static fun values(): R|kotlin/Array| { - } - - public final static fun valueOf(value: R|kotlin/String|): R|SomeClass| { - } - - public final static val entries: R|kotlin/enums/EnumEntries| - public get(): R|kotlin/enums/EnumEntries| - - } - public final val resultValues: = Q|SomeClass|.#() - public get(): - public final val resultValuesRef: = Q|SomeClass|::# - public get(): - public final val resultEntries: R|SomeClass.entries.Companion| = Q|SomeClass.entries| - public get(): R|SomeClass.entries.Companion| - public final val resultEntriesRef: R|kotlin/reflect/KFunction0| = Q|SomeClass|::R|/SomeClass.entries.entries| - public get(): R|kotlin/reflect/KFunction0| diff --git a/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsSyntheticValues.kt b/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsSyntheticValues.kt index 523cb802af3..96679265364 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsSyntheticValues.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsSyntheticValues.kt @@ -1,6 +1,10 @@ -// ISSUE: KT-65789 +// ISSUE: KT-65789, KT-58920 // LANGUAGE: -PrioritizedEnumEntries -// FIR_DUMP +// WITH_REFLECT + +import kotlin.reflect.* + +fun take(arg: T): T = arg enum class SomeClass { FIRST, LAST; @@ -15,5 +19,6 @@ enum class SomeClass { val resultValues = SomeClass.values() val resultValuesRef = SomeClass::values -val resultEntries = SomeClass.entries -val resultEntriesRef = SomeClass::entries + +val resultEntries = take(SomeClass.entries) +val resultEntriesRef = take>(SomeClass::entries) diff --git a/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsSyntheticValuesPrioritized.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsSyntheticValuesPrioritized.fir.kt index 2449632d7d1..b309e57a375 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsSyntheticValuesPrioritized.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsSyntheticValuesPrioritized.fir.kt @@ -1,4 +1,4 @@ -// ISSUE: KT-65789 +// ISSUE: KT-65789, KT-58920 // LANGUAGE: +PrioritizedEnumEntries // FIR_DUMP diff --git a/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsSyntheticValuesPrioritized.kt b/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsSyntheticValuesPrioritized.kt index 6936136b6b5..7f720c07824 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsSyntheticValuesPrioritized.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsSyntheticValuesPrioritized.kt @@ -1,4 +1,4 @@ -// ISSUE: KT-65789 +// ISSUE: KT-65789, KT-58920 // LANGUAGE: +PrioritizedEnumEntries // FIR_DUMP diff --git a/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsTopLevel.fir.txt b/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsTopLevel.fir.txt deleted file mode 100644 index 859114bd4ed..00000000000 --- a/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsTopLevel.fir.txt +++ /dev/null @@ -1,23 +0,0 @@ -FILE: Foo.kt - package bar - - public final fun Foo(string: R|kotlin/String?|): R|kotlin/Unit| { - } - public final class Foo : R|kotlin/Any| { - public constructor(str: R|kotlin/String|): R|bar/Foo| { - super() - } - - public final val str: R|kotlin/String| = R|/str| - public get(): R|kotlin/String| - - } - public final val foo: R|bar/Foo| = R|bar/Foo.Foo|(String(1)) - public get(): R|bar/Foo| - public final val barFoo: R|bar/Foo| = Q|bar|.R|bar/Foo.Foo|(String(2)) - public get(): R|bar/Foo| -FILE: another.kt - package foo - - public final val foo: R|bar/Foo| = R|bar/Foo.Foo|(String(3)) - public get(): R|bar/Foo| diff --git a/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsTopLevel.kt b/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsTopLevel.kt index e06990e8423..fa49650f744 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsTopLevel.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsTopLevel.kt @@ -1,20 +1,22 @@ // FIR_IDENTICAL // ISSUE: KT-65789 -// FIR_DUMP // FILE: Foo.kt package bar +fun take(arg: T): T = arg + fun Foo(string: String?) {} class Foo(val str: String) -val foo = Foo("1") -val barFoo = bar.Foo("2") +val foo = take(Foo("1")) +val barFoo = take(bar.Foo("2")) // FILE: another.kt package foo import bar.Foo +import bar.take -val foo = Foo("3") +val foo = take(Foo("3")) diff --git a/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsTopLevel.txt b/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsTopLevel.txt deleted file mode 100644 index c6854e79ee9..00000000000 --- a/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorVsTopLevel.txt +++ /dev/null @@ -1,19 +0,0 @@ -package - -package bar { - public val barFoo: bar.Foo - public val foo: bar.Foo - public fun Foo(/*0*/ string: kotlin.String?): kotlin.Unit - - public final class Foo { - public constructor Foo(/*0*/ str: kotlin.String) - public final val str: kotlin.String - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String - } -} - -package foo { - public val foo: bar.Foo -}