diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java index f83afdbc928..1cf63e3a562 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java @@ -11472,6 +11472,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag runTest("compiler/testData/diagnostics/tests/functionLiterals/kt47493.kt"); } + @Test + @TestMetadata("kt51317.kt") + public void testKt51317() throws Exception { + runTest("compiler/testData/diagnostics/tests/functionLiterals/kt51317.kt"); + } + @Test @TestMetadata("kt6541_extensionForExtensionFunction.kt") public void testKt6541_extensionForExtensionFunction() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java index 66f9edfd526..89d9caad36a 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java @@ -11472,6 +11472,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti runTest("compiler/testData/diagnostics/tests/functionLiterals/kt47493.kt"); } + @Test + @TestMetadata("kt51317.kt") + public void testKt51317() throws Exception { + runTest("compiler/testData/diagnostics/tests/functionLiterals/kt51317.kt"); + } + @Test @TestMetadata("kt6541_extensionForExtensionFunction.kt") public void testKt6541_extensionForExtensionFunction() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java index 3b460647613..d1ca1c8e5d0 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java @@ -11472,6 +11472,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac runTest("compiler/testData/diagnostics/tests/functionLiterals/kt47493.kt"); } + @Test + @TestMetadata("kt51317.kt") + public void testKt51317() throws Exception { + runTest("compiler/testData/diagnostics/tests/functionLiterals/kt51317.kt"); + } + @Test @TestMetadata("kt6541_extensionForExtensionFunction.kt") public void testKt6541_extensionForExtensionFunction() throws Exception { diff --git a/compiler/testData/diagnostics/tests/functionLiterals/kt51317.fir.kt b/compiler/testData/diagnostics/tests/functionLiterals/kt51317.fir.kt new file mode 100644 index 00000000000..fa6d1df9fb9 --- /dev/null +++ b/compiler/testData/diagnostics/tests/functionLiterals/kt51317.fir.kt @@ -0,0 +1,11 @@ +val f: (String.() -> String)? = null + +fun box(): String { + val g = when { + f != null -> f + else -> { + { this + "K" } + } + } + return g("O") +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/functionLiterals/kt51317.kt b/compiler/testData/diagnostics/tests/functionLiterals/kt51317.kt new file mode 100644 index 00000000000..70738728d97 --- /dev/null +++ b/compiler/testData/diagnostics/tests/functionLiterals/kt51317.kt @@ -0,0 +1,11 @@ +val f: (String.() -> String)? = null + +fun box(): String { + val g = when { + f != null -> f + else -> { + { this + "K" } + } + } + return g("O") +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/functionLiterals/kt51317.txt b/compiler/testData/diagnostics/tests/functionLiterals/kt51317.txt new file mode 100644 index 00000000000..b206c621f76 --- /dev/null +++ b/compiler/testData/diagnostics/tests/functionLiterals/kt51317.txt @@ -0,0 +1,4 @@ +package + +public val f: (kotlin.String.() -> kotlin.String)? = null +public fun box(): kotlin.String diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java index da24f25ea43..ba0893ea89a 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java @@ -11478,6 +11478,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/functionLiterals/kt47493.kt"); } + @Test + @TestMetadata("kt51317.kt") + public void testKt51317() throws Exception { + runTest("compiler/testData/diagnostics/tests/functionLiterals/kt51317.kt"); + } + @Test @TestMetadata("kt6541_extensionForExtensionFunction.kt") public void testKt6541_extensionForExtensionFunction() throws Exception { diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/AnnotationsTypeAttribute.kt b/core/descriptors/src/org/jetbrains/kotlin/types/AnnotationsTypeAttribute.kt index d4379c4d0ff..5a8cda10f3e 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/AnnotationsTypeAttribute.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/AnnotationsTypeAttribute.kt @@ -10,9 +10,11 @@ import org.jetbrains.kotlin.descriptors.annotations.composeAnnotations import kotlin.reflect.KClass class AnnotationsTypeAttribute(val annotations: Annotations) : TypeAttribute() { - override fun union(other: AnnotationsTypeAttribute?): AnnotationsTypeAttribute? = null + override fun union(other: AnnotationsTypeAttribute?): AnnotationsTypeAttribute? = + if (other == this) this else null - override fun intersect(other: AnnotationsTypeAttribute?): AnnotationsTypeAttribute? = null + override fun intersect(other: AnnotationsTypeAttribute?): AnnotationsTypeAttribute? = + if (other == this) this else null override fun add(other: AnnotationsTypeAttribute?): AnnotationsTypeAttribute { if (other == null) return this @@ -23,6 +25,13 @@ class AnnotationsTypeAttribute(val annotations: Annotations) : TypeAttribute get() = AnnotationsTypeAttribute::class + + override fun equals(other: Any?): Boolean { + if (other !is AnnotationsTypeAttribute) return false + return other.annotations == this.annotations + } + + override fun hashCode(): Int = annotations.hashCode() } val TypeAttributes.annotationsAttribute: AnnotationsTypeAttribute? by TypeAttributes.attributeAccessor()