diff --git a/compiler/fir/analysis-tests/testData/resolve/annotations/kt54478.kt b/compiler/fir/analysis-tests/testData/resolve/annotations/kt54478.kt index cb4d372c653..2497a99d662 100644 --- a/compiler/fir/analysis-tests/testData/resolve/annotations/kt54478.kt +++ b/compiler/fir/analysis-tests/testData/resolve/annotations/kt54478.kt @@ -1,6 +1,6 @@ // ISSUE: KT-54478 -@file:Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") +@file:Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") import kotlin.internal.NoInfer diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/kt50875.kt b/compiler/fir/analysis-tests/testData/resolve/smartcasts/kt50875.kt index a4bd1ec6613..9d1100b1c39 100644 --- a/compiler/fir/analysis-tests/testData/resolve/smartcasts/kt50875.kt +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/kt50875.kt @@ -4,7 +4,7 @@ interface A { fun foo() } -@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") fun checkNotNull(x: K?, y: K): @kotlin.internal.Exact K { return x ?: y } diff --git a/compiler/fir/analysis-tests/testData/resolve/suppress/singleError.kt b/compiler/fir/analysis-tests/testData/resolve/suppress/singleError.kt index 4dbdac633d7..be1a2c7e275 100644 --- a/compiler/fir/analysis-tests/testData/resolve/suppress/singleError.kt +++ b/compiler/fir/analysis-tests/testData/resolve/suppress/singleError.kt @@ -1,6 +1,6 @@ fun foo(x: String) {} -@Suppress("ARGUMENT_TYPE_MISMATCH") +@Suppress("ARGUMENT_TYPE_MISMATCH") fun bar() { foo(10) } diff --git a/compiler/fir/analysis-tests/testData/resolve/suppress/withSuppression.kt b/compiler/fir/analysis-tests/testData/resolve/suppress/withSuppression.kt index 470648f86ae..1dd58387f87 100644 --- a/compiler/fir/analysis-tests/testData/resolve/suppress/withSuppression.kt +++ b/compiler/fir/analysis-tests/testData/resolve/suppress/withSuppression.kt @@ -1,20 +1,20 @@ const val x = "123" - @Suppress("CONST_VAL_WITH_GETTER") + @Suppress("CONST_VAL_WITH_GETTER") get() = field val y = "789" -const val z = @Suppress("CONST_VAL_WITH_NON_CONST_INITIALIZER") y +const val z = @Suppress("CONST_VAL_WITH_NON_CONST_INITIALIZER") y @Target(AnnotationTarget.TYPE) annotation class Ann -fun foo(): @Suppress("REPEATED_ANNOTATION") @Ann @Ann Int = 42 +fun foo(): @Suppress("REPEATED_ANNOTATION") @Ann @Ann Int = 42 -typealias Alias = @Suppress("TYPEALIAS_SHOULD_EXPAND_TO_CLASS") T +typealias Alias = @Suppress("TYPEALIAS_SHOULD_EXPAND_TO_CLASS") T interface A -interface B : @Suppress("SUPERTYPE_INITIALIZED_IN_INTERFACE") A() +interface B : @Suppress("SUPERTYPE_INITIALIZED_IN_INTERFACE") A() -data class D @Suppress("DATA_CLASS_VARARG_PARAMETER") constructor(vararg val x: String) +data class D @Suppress("DATA_CLASS_VARARG_PARAMETER") constructor(vararg val x: String) diff --git a/compiler/fir/analysis-tests/testData/resolve/suppress/withSuppression2.kt b/compiler/fir/analysis-tests/testData/resolve/suppress/withSuppression2.kt index 27973ebf798..b3e252aab2f 100644 --- a/compiler/fir/analysis-tests/testData/resolve/suppress/withSuppression2.kt +++ b/compiler/fir/analysis-tests/testData/resolve/suppress/withSuppression2.kt @@ -2,23 +2,23 @@ abstract class A fun foo(i: Int) {} -value class B(val i: Int) : @Suppress("VALUE_CLASS_CANNOT_EXTEND_CLASSES") A() { - @Suppress("SECONDARY_CONSTRUCTOR_WITH_BODY_INSIDE_VALUE_CLASS") +value class B(val i: Int) : @Suppress("VALUE_CLASS_CANNOT_EXTEND_CLASSES") A() { + @Suppress("SECONDARY_CONSTRUCTOR_WITH_BODY_INSIDE_VALUE_CLASS") constructor() : this(42) { foo(i) } - @Suppress("ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS") + @Suppress("ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS") abstract val y: Int } interface C { - @Suppress("PRIVATE_PROPERTY_IN_INTERFACE") + @Suppress("PRIVATE_PROPERTY_IN_INTERFACE") private val x: Int - @Suppress("METHOD_OF_ANY_IMPLEMENTED_IN_INTERFACE") + @Suppress("METHOD_OF_ANY_IMPLEMENTED_IN_INTERFACE") override fun hashCode() = 42 } -@Suppress("PROPERTY_WITH_NO_TYPE_NO_INITIALIZER") +@Suppress("PROPERTY_WITH_NO_TYPE_NO_INITIALIZER") val z diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/lowPriorityInResolution.kt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/lowPriorityInResolution.kt index c46b548b4a5..56d8e25c71f 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/lowPriorityInResolution.kt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/lowPriorityInResolution.kt @@ -1,4 +1,4 @@ -@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") @kotlin.internal.LowPriorityInOverloadResolution fun foo(): Int = 1 diff --git a/compiler/testData/diagnostics/nativeTests/forwardDeclarations.fir.kt b/compiler/testData/diagnostics/nativeTests/forwardDeclarations.fir.kt new file mode 100644 index 00000000000..c5eed710676 --- /dev/null +++ b/compiler/testData/diagnostics/nativeTests/forwardDeclarations.fir.kt @@ -0,0 +1,103 @@ +// WITH_STDLIB + +// FILE: stdlib.kt + +package kotlinx.cinterop + +abstract class CStructVar +interface ObjCObject +abstract class ObjCObjectBase : ObjCObject + +// FILE: cnames.kt + +package cnames.structs + +class FwdStruct {} + +// FILE: objcnamesClasses.kt + +package objcnames.classes + +class FwdObjcClass {} + +// FILE: objcnamesProtocols.kt + +package objcnames.protocols + +interface FwdProtocol {} + +// FILE: lib.kt + +package lib + +import kotlinx.cinterop.* + +class FwdStruct : CStructVar() +class FwdObjcClass : ObjCObjectBase() +interface FwdProtocol : ObjCObject + +// FILE: lib2.kt + +package lib2 + +class FwdStruct +class FwdObjcClass +interface FwdProtocol + + +// FILE: main.kt + +// this inspections differs in K1/K2, but unrelated to what is tested in this test +@file:Suppress("CAST_NEVER_SUCCEEDS", "UNUSED_PARAMETER", "UNUSED_EXPRESSION", "UNUSED_VARIABLE", "INCOMPATIBLE_TYPES") + +fun testUnckeckedAsFromAny(x: Any) { + x as? cnames.structs.FwdStruct + x as? objcnames.classes.FwdObjcClass + x as? objcnames.protocols.FwdProtocol + if (1 > 0) { x as cnames.structs.FwdStruct } + if (1 > 0) { x as objcnames.classes.FwdObjcClass } + if (1 > 0) { x as objcnames.protocols.FwdProtocol } +} + +fun testIs(x: Any) : Int { + return when { + x is cnames.structs.FwdStruct -> 1 + x is objcnames.classes.FwdObjcClass -> 2 + x is objcnames.protocols.FwdProtocol -> 3 + else -> 4 + } +} + +fun testIs2(x: lib.FwdStruct) = x is cnames.structs.FwdStruct +fun testIs3(x: lib.FwdObjcClass) = x is objcnames.classes.FwdObjcClass +fun testIs4(x: lib.FwdProtocol) = x is objcnames.protocols.FwdProtocol + + +fun testClass1(x : cnames.structs.FwdStruct) = x::class +fun testClass2(x : objcnames.classes.FwdObjcClass) = x::class +fun testClass3(x : objcnames.protocols.FwdProtocol) = x::class +fun testClass4() { + cnames.structs.FwdStruct::class + objcnames.classes.FwdObjcClass::class + objcnames.protocols.FwdProtocol::class +} +inline fun inlineF(x: T) {} + +fun testInline1(x : cnames.structs.FwdStruct) = inlineF(x) +fun testInline2(x : objcnames.classes.FwdObjcClass) = inlineF(x) +fun testInline3(x : objcnames.protocols.FwdProtocol) = inlineF(x) +fun testInline4() { + val a : (cnames.structs.FwdStruct) -> Unit = ::inlineF + val b : (objcnames.classes.FwdObjcClass) -> Unit = ::inlineF + val c : (objcnames.protocols.FwdProtocol) -> Unit = ::inlineF +} + +fun testCheckedAs1(x : lib.FwdStruct) = x as cnames.structs.FwdStruct +fun testCheckedAs2(x : lib.FwdObjcClass) = x as objcnames.classes.FwdObjcClass +fun testCheckedAs3(x : lib.FwdProtocol) = x as objcnames.protocols.FwdProtocol + +fun testUnCheckedAs1(x : lib2.FwdStruct) = x as cnames.structs.FwdStruct +fun testUnCheckedAs2(x : lib2.FwdObjcClass) = x as objcnames.classes.FwdObjcClass +fun testUnCheckedAs3(x : lib2.FwdProtocol) = x as objcnames.protocols.FwdProtocol + +fun testUnCheckedAs4(x : lib.FwdStruct) = x as objcnames.classes.FwdObjcClass diff --git a/compiler/testData/diagnostics/nativeTests/forwardDeclarations.kt b/compiler/testData/diagnostics/nativeTests/forwardDeclarations.kt index 821b8c2dedf..e73dd2c79be 100644 --- a/compiler/testData/diagnostics/nativeTests/forwardDeclarations.kt +++ b/compiler/testData/diagnostics/nativeTests/forwardDeclarations.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL // WITH_STDLIB // FILE: stdlib.kt diff --git a/compiler/testData/diagnostics/nativeTests/overridesMemberWithPlatformDependent.fir.kt b/compiler/testData/diagnostics/nativeTests/overridesMemberWithPlatformDependent.fir.kt new file mode 100644 index 00000000000..cf459dadbc6 --- /dev/null +++ b/compiler/testData/diagnostics/nativeTests/overridesMemberWithPlatformDependent.fir.kt @@ -0,0 +1,21 @@ +// ISSUE: KT-57858 + +// FILE: Sub.kt +package kotlin.internal + +@Target(AnnotationTarget.FUNCTION) +annotation class PlatformDependent + +// FILE: Main.kt +@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") + +import kotlin.internal.PlatformDependent + +interface I { + @PlatformDependent + fun f() {} +} + +class C : I { + fun f() {} +} diff --git a/compiler/testData/diagnostics/nativeTests/overridesMemberWithPlatformDependent.kt b/compiler/testData/diagnostics/nativeTests/overridesMemberWithPlatformDependent.kt index b5e58a1ad43..b4dedda759f 100644 --- a/compiler/testData/diagnostics/nativeTests/overridesMemberWithPlatformDependent.kt +++ b/compiler/testData/diagnostics/nativeTests/overridesMemberWithPlatformDependent.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL // ISSUE: KT-57858 // FILE: Sub.kt diff --git a/compiler/testData/diagnostics/tests/annotations/illegalRequireKotlinValue.fir.kt b/compiler/testData/diagnostics/tests/annotations/illegalRequireKotlinValue.fir.kt index afa3068031f..9d1f461265b 100644 --- a/compiler/testData/diagnostics/tests/annotations/illegalRequireKotlinValue.fir.kt +++ b/compiler/testData/diagnostics/tests/annotations/illegalRequireKotlinValue.fir.kt @@ -1,4 +1,4 @@ -@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") package test import kotlin.internal.RequireKotlin diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/noContextReceiversOnValueClasses.fir.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/noContextReceiversOnValueClasses.fir.kt index 4854c02eb0e..bc75479633a 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/noContextReceiversOnValueClasses.fir.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/noContextReceiversOnValueClasses.fir.kt @@ -2,6 +2,7 @@ // WITH_STDLIB // SKIP_TXT // WORKS_WHEN_VALUE_CLASS +// DONT_WARN_ON_ERROR_SUPPRESSION @file:Suppress("INLINE_CLASS_DEPRECATED") diff --git a/compiler/testData/diagnostics/tests/extensions/contextReceivers/noContextReceiversOnValueClasses.kt b/compiler/testData/diagnostics/tests/extensions/contextReceivers/noContextReceiversOnValueClasses.kt index 80a25ff01cd..53f437f71c2 100644 --- a/compiler/testData/diagnostics/tests/extensions/contextReceivers/noContextReceiversOnValueClasses.kt +++ b/compiler/testData/diagnostics/tests/extensions/contextReceivers/noContextReceiversOnValueClasses.kt @@ -2,6 +2,7 @@ // WITH_STDLIB // SKIP_TXT // WORKS_WHEN_VALUE_CLASS +// DONT_WARN_ON_ERROR_SUPPRESSION @file:Suppress("INLINE_CLASS_DEPRECATED") diff --git a/compiler/testData/diagnostics/tests/imports/OptionalAnnotationClasses.fir.kt b/compiler/testData/diagnostics/tests/imports/OptionalAnnotationClasses.fir.kt new file mode 100644 index 00000000000..7f58ac009be --- /dev/null +++ b/compiler/testData/diagnostics/tests/imports/OptionalAnnotationClasses.fir.kt @@ -0,0 +1,12 @@ +// WITH_STDLIB + +@file:Suppress("OPTIONAL_DECLARATION_USAGE_IN_NON_COMMON_SOURCE") + +import kotlin.js.* +import kotlin.native.concurrent.* + +@JsName("") +public fun test() {} + +@ThreadLocal +private val EmptyArray: Array = arrayOf() \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/imports/OptionalAnnotationClasses.kt b/compiler/testData/diagnostics/tests/imports/OptionalAnnotationClasses.kt index a9865efbb49..ee49f33e430 100644 --- a/compiler/testData/diagnostics/tests/imports/OptionalAnnotationClasses.kt +++ b/compiler/testData/diagnostics/tests/imports/OptionalAnnotationClasses.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL // WITH_STDLIB @file:Suppress("OPTIONAL_DECLARATION_USAGE_IN_NON_COMMON_SOURCE") diff --git a/compiler/testData/diagnostics/tests/inference/capturedTypes/capturedTypeWithInnerTypealias.fir.kt b/compiler/testData/diagnostics/tests/inference/capturedTypes/capturedTypeWithInnerTypealias.fir.kt new file mode 100644 index 00000000000..0bc2a41106d --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/capturedTypes/capturedTypeWithInnerTypealias.fir.kt @@ -0,0 +1,10 @@ +import kotlin.reflect.KClass + +typealias MyString = String + +fun test(k: KClass) { + k::class.java +} + +@Suppress("UPPER_BOUND_VIOLATED") +public val KClass.java: Class get() = TODO() diff --git a/compiler/testData/diagnostics/tests/inference/capturedTypes/capturedTypeWithInnerTypealias.kt b/compiler/testData/diagnostics/tests/inference/capturedTypes/capturedTypeWithInnerTypealias.kt index f7aab21509e..21170a89ca3 100644 --- a/compiler/testData/diagnostics/tests/inference/capturedTypes/capturedTypeWithInnerTypealias.kt +++ b/compiler/testData/diagnostics/tests/inference/capturedTypes/capturedTypeWithInnerTypealias.kt @@ -1,5 +1,3 @@ -// FIR_IDENTICAL - import kotlin.reflect.KClass typealias MyString = String diff --git a/compiler/testData/diagnostics/tests/inference/coercionToUnit/coercionToUnitWithNothingType.fir.kt b/compiler/testData/diagnostics/tests/inference/coercionToUnit/coercionToUnitWithNothingType.fir.kt index daaa1ba5670..f4326e9ac01 100644 --- a/compiler/testData/diagnostics/tests/inference/coercionToUnit/coercionToUnitWithNothingType.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/coercionToUnit/coercionToUnitWithNothingType.fir.kt @@ -41,7 +41,7 @@ fun test(i: Inv, iUnit: Inv) { run(A.flexible(iUnit)) { 42 } } launch { - @Suppress("UNSUPPORTED") + @Suppress("UNSUPPORTED") run { "" } } diff --git a/compiler/testData/diagnostics/tests/inference/commonSystem/lessSpecificTypeForArgumentCallWithExactAnnotation.fir.kt b/compiler/testData/diagnostics/tests/inference/commonSystem/lessSpecificTypeForArgumentCallWithExactAnnotation.fir.kt index cb9a0ce05c1..b98230c5d6f 100644 --- a/compiler/testData/diagnostics/tests/inference/commonSystem/lessSpecificTypeForArgumentCallWithExactAnnotation.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/commonSystem/lessSpecificTypeForArgumentCallWithExactAnnotation.fir.kt @@ -4,7 +4,7 @@ interface A interface B : A interface C : A -@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER", "HIDDEN") +@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER", "HIDDEN") fun select(x: K, y: K): @kotlin.internal.Exact K = x fun foo(a: Any) {} diff --git a/compiler/testData/diagnostics/tests/inference/commonSystem/lessSpecificTypeForArgumentCallWithExactAnnotation_ni.fir.kt b/compiler/testData/diagnostics/tests/inference/commonSystem/lessSpecificTypeForArgumentCallWithExactAnnotation_ni.fir.kt index cb9a0ce05c1..b98230c5d6f 100644 --- a/compiler/testData/diagnostics/tests/inference/commonSystem/lessSpecificTypeForArgumentCallWithExactAnnotation_ni.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/commonSystem/lessSpecificTypeForArgumentCallWithExactAnnotation_ni.fir.kt @@ -4,7 +4,7 @@ interface A interface B : A interface C : A -@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER", "HIDDEN") +@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER", "HIDDEN") fun select(x: K, y: K): @kotlin.internal.Exact K = x fun foo(a: Any) {} diff --git a/compiler/testData/diagnostics/tests/inference/commonSystem/postponedCompletionWithExactAnnotation.fir.kt b/compiler/testData/diagnostics/tests/inference/commonSystem/postponedCompletionWithExactAnnotation.fir.kt index 4491ba6b8e5..d442c47afca 100644 --- a/compiler/testData/diagnostics/tests/inference/commonSystem/postponedCompletionWithExactAnnotation.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/commonSystem/postponedCompletionWithExactAnnotation.fir.kt @@ -4,7 +4,7 @@ interface ISample fun elvisSimple(x: K?, y: K): K = y -@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER", "HIDDEN") +@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER", "HIDDEN") fun elvisExact(x: K?, y: K): @kotlin.internal.Exact K = y fun materialize(): T? = TODO() diff --git a/compiler/testData/diagnostics/tests/inference/commonSystem/postponedCompletionWithExactAnnotation_ni.fir.kt b/compiler/testData/diagnostics/tests/inference/commonSystem/postponedCompletionWithExactAnnotation_ni.fir.kt index 59e2fbe15b7..7840422c6e2 100644 --- a/compiler/testData/diagnostics/tests/inference/commonSystem/postponedCompletionWithExactAnnotation_ni.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/commonSystem/postponedCompletionWithExactAnnotation_ni.fir.kt @@ -4,7 +4,7 @@ interface ISample fun elvisSimple(x: K?, y: K): K = y -@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER", "HIDDEN") +@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER", "HIDDEN") fun elvisExact(x: K?, y: K): @kotlin.internal.Exact K = y fun materialize(): T? = null diff --git a/compiler/testData/diagnostics/tests/inference/completion/withExact.fir.kt b/compiler/testData/diagnostics/tests/inference/completion/withExact.fir.kt index 9d65b583a8d..917c7d4a245 100644 --- a/compiler/testData/diagnostics/tests/inference/completion/withExact.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/completion/withExact.fir.kt @@ -1,6 +1,6 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER -@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") import kotlin.internal.Exact diff --git a/compiler/testData/diagnostics/tests/inference/onlyInputTypesWithMultilevelIncorporation.fir.kt b/compiler/testData/diagnostics/tests/inference/onlyInputTypesWithMultilevelIncorporation.fir.kt new file mode 100644 index 00000000000..911d5e55cd0 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/onlyInputTypesWithMultilevelIncorporation.fir.kt @@ -0,0 +1,15 @@ +// WITH_STDLIB +// !DIAGNOSTICS: -UNUSED_PARAMETER + +@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") + +import kotlin.internal.OnlyInputTypes + +fun <@OnlyInputTypes T> assertEquals(expected: T, actual: T, message: String? = null) {} + +fun main() { + assertEquals( + mapOf(1 to "1", 2 to "2", 3 to "3"), + intArrayOf(1, 2, 3).associateWith { it.toString() } + ) +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/onlyInputTypesWithMultilevelIncorporation.kt b/compiler/testData/diagnostics/tests/inference/onlyInputTypesWithMultilevelIncorporation.kt index 49aa4ebf02b..cb95482cba8 100644 --- a/compiler/testData/diagnostics/tests/inference/onlyInputTypesWithMultilevelIncorporation.kt +++ b/compiler/testData/diagnostics/tests/inference/onlyInputTypesWithMultilevelIncorporation.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL // WITH_STDLIB // !DIAGNOSTICS: -UNUSED_PARAMETER diff --git a/compiler/testData/diagnostics/tests/multiplatform/actualTypealiasToSpecialAnnotation.fir.kt b/compiler/testData/diagnostics/tests/multiplatform/actualTypealiasToSpecialAnnotation.fir.kt new file mode 100644 index 00000000000..7aea3d6a858 --- /dev/null +++ b/compiler/testData/diagnostics/tests/multiplatform/actualTypealiasToSpecialAnnotation.fir.kt @@ -0,0 +1,27 @@ +// WITH_STDLIB +// MODULE: m1-common +// FILE: common.kt +expect annotation class TypealiasToKotlinPkg + +internal expect annotation class TypealiasToInternalPkg + +expect annotation class TypealiasToAnnotationPkg + +expect annotation class TypealiasToPlatformPkg + +expect enum class TypealiasNotToAnnotation + +// MODULE: m1-jvm()()(m1-common) +// FILE: jvm.kt +actual typealias TypealiasToKotlinPkg = kotlin.Deprecated + +@Suppress("INVISIBLE_REFERENCE") +internal actual typealias TypealiasToInternalPkg = kotlin.internal.RequireKotlin + +actual typealias TypealiasToAnnotationPkg = kotlin.annotation.Target + +actual typealias TypealiasToPlatformPkg = kotlin.jvm.Synchronized + +typealias NonActualTypealias = kotlin.Deprecated + +actual typealias TypealiasNotToAnnotation = kotlin.DeprecationLevel diff --git a/compiler/testData/diagnostics/tests/multiplatform/actualTypealiasToSpecialAnnotation.kt b/compiler/testData/diagnostics/tests/multiplatform/actualTypealiasToSpecialAnnotation.kt index 15ea0204e0f..ba31529473e 100644 --- a/compiler/testData/diagnostics/tests/multiplatform/actualTypealiasToSpecialAnnotation.kt +++ b/compiler/testData/diagnostics/tests/multiplatform/actualTypealiasToSpecialAnnotation.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL // WITH_STDLIB // MODULE: m1-common // FILE: common.kt diff --git a/compiler/testData/diagnostics/tests/multiplatform/annotationMatching/skippedAnnotations.fir.kt b/compiler/testData/diagnostics/tests/multiplatform/annotationMatching/skippedAnnotations.fir.kt new file mode 100644 index 00000000000..3b23cf07f59 --- /dev/null +++ b/compiler/testData/diagnostics/tests/multiplatform/annotationMatching/skippedAnnotations.fir.kt @@ -0,0 +1,29 @@ +// WITH_STDLIB +// MODULE: m1-common +// FILE: common.kt +package kotlin + +@OptIn(ExperimentalMultiplatform::class) +@OptionalExpectation +expect annotation class OptionalExpectationOnExpectOnly + +@RequiresOptIn +annotation class MyOptIn + +@SinceKotlin("1.8") +@Deprecated(message = "Some text") +@DeprecatedSinceKotlin("1.8") +@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") +@MyOptIn +@WasExperimental(MyOptIn::class) +@kotlin.internal.RequireKotlin(version = "1.8") +expect fun skippedAnnotationsOnExpectOnly() + +// MODULE: m1-jvm()()(m1-common) +// FILE: jvm.kt +package kotlin + +@OptIn(ExperimentalMultiplatform::class) +actual annotation class OptionalExpectationOnExpectOnly + +actual fun skippedAnnotationsOnExpectOnly() {} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/multiplatform/annotationMatching/skippedAnnotations.kt b/compiler/testData/diagnostics/tests/multiplatform/annotationMatching/skippedAnnotations.kt index 2fcfe73d38a..a1c60baad61 100644 --- a/compiler/testData/diagnostics/tests/multiplatform/annotationMatching/skippedAnnotations.kt +++ b/compiler/testData/diagnostics/tests/multiplatform/annotationMatching/skippedAnnotations.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL // WITH_STDLIB // MODULE: m1-common // FILE: common.kt diff --git a/compiler/testData/diagnostics/tests/smartCasts/variables/capturedByAtLeastOnce.fir.kt b/compiler/testData/diagnostics/tests/smartCasts/variables/capturedByAtLeastOnce.fir.kt index a4462fd8c7f..31ac3826568 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/variables/capturedByAtLeastOnce.fir.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/variables/capturedByAtLeastOnce.fir.kt @@ -1,6 +1,6 @@ import kotlin.contracts.* -@Suppress("OPT_IN_USAGE_ERROR", "OPT_IN_USAGE_FUTURE_ERROR") +@Suppress("OPT_IN_USAGE_ERROR", "OPT_IN_USAGE_FUTURE_ERROR") inline fun atLeastOnce(block: () -> Unit) { contract { callsInPlace(block, InvocationKind.AT_LEAST_ONCE) @@ -8,7 +8,7 @@ inline fun atLeastOnce(block: () -> Unit) { block() } -@Suppress("OPT_IN_USAGE_ERROR", "OPT_IN_USAGE_FUTURE_ERROR") +@Suppress("OPT_IN_USAGE_ERROR", "OPT_IN_USAGE_FUTURE_ERROR") inline fun atMostOnce(block: () -> Unit) { contract { callsInPlace(block, InvocationKind.AT_MOST_ONCE) @@ -16,7 +16,7 @@ inline fun atMostOnce(block: () -> Unit) { block() } -@Suppress("OPT_IN_USAGE_ERROR", "OPT_IN_USAGE_FUTURE_ERROR") +@Suppress("OPT_IN_USAGE_ERROR", "OPT_IN_USAGE_FUTURE_ERROR") inline fun exactlyOnce(block: () -> Unit) { contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) diff --git a/compiler/testData/diagnostics/tests/smartCasts/variables/capturedByMultipleLambdas.fir.kt b/compiler/testData/diagnostics/tests/smartCasts/variables/capturedByMultipleLambdas.fir.kt index c00758d47fe..6002fe30da8 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/variables/capturedByMultipleLambdas.fir.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/variables/capturedByMultipleLambdas.fir.kt @@ -1,6 +1,6 @@ import kotlin.contracts.* -@Suppress("OPT_IN_USAGE_ERROR", "OPT_IN_USAGE_FUTURE_ERROR") +@Suppress("OPT_IN_USAGE_ERROR", "OPT_IN_USAGE_FUTURE_ERROR") fun foo(f1: () -> Unit, f2: () -> Unit) { contract { callsInPlace(f1, InvocationKind.EXACTLY_ONCE) diff --git a/compiler/testData/diagnostics/tests/smartCasts/variables/capturedByNested.fir.kt b/compiler/testData/diagnostics/tests/smartCasts/variables/capturedByNested.fir.kt new file mode 100644 index 00000000000..5981d68c57e --- /dev/null +++ b/compiler/testData/diagnostics/tests/smartCasts/variables/capturedByNested.fir.kt @@ -0,0 +1,21 @@ +import kotlin.contracts.* + +@Suppress("OPT_IN_USAGE_ERROR", "OPT_IN_USAGE_FUTURE_ERROR") +fun exactlyOnce(f: () -> Unit) { + contract { + callsInPlace(f, InvocationKind.EXACTLY_ONCE) + } + f() +} + +fun test() { + var s: String? = "" + if (s != null) { + val block: () -> Unit + exactlyOnce { + block = { s = null } + } + block() + s.length + } +} diff --git a/compiler/testData/diagnostics/tests/smartCasts/variables/capturedByNested.kt b/compiler/testData/diagnostics/tests/smartCasts/variables/capturedByNested.kt index cc713e13c9a..f2e75d0edf5 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/variables/capturedByNested.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/variables/capturedByNested.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL import kotlin.contracts.* @Suppress("OPT_IN_USAGE_ERROR", "OPT_IN_USAGE_FUTURE_ERROR") diff --git a/compiler/testData/diagnostics/tests/suppress/oneWarning/suppressOnDeclarationItself.fir.kt b/compiler/testData/diagnostics/tests/suppress/oneWarning/suppressOnDeclarationItself.fir.kt new file mode 100644 index 00000000000..dee6596a314 --- /dev/null +++ b/compiler/testData/diagnostics/tests/suppress/oneWarning/suppressOnDeclarationItself.fir.kt @@ -0,0 +1,5 @@ +class A { + @Suppress("NOTHING_TO_OVERRIDE") + override fun foo() {} +} + diff --git a/compiler/testData/diagnostics/tests/suppress/oneWarning/suppressOnDeclarationItself.kt b/compiler/testData/diagnostics/tests/suppress/oneWarning/suppressOnDeclarationItself.kt index 2710f8690e4..535272a5fa8 100644 --- a/compiler/testData/diagnostics/tests/suppress/oneWarning/suppressOnDeclarationItself.kt +++ b/compiler/testData/diagnostics/tests/suppress/oneWarning/suppressOnDeclarationItself.kt @@ -1,5 +1,3 @@ -// FIR_IDENTICAL - class A { @Suppress("NOTHING_TO_OVERRIDE") override fun foo() {} diff --git a/compiler/testData/diagnostics/tests/suppressInWhen.fir.kt b/compiler/testData/diagnostics/tests/suppressInWhen.fir.kt new file mode 100644 index 00000000000..d6c74857fef --- /dev/null +++ b/compiler/testData/diagnostics/tests/suppressInWhen.fir.kt @@ -0,0 +1,18 @@ +// ISSUE: KT-61065 +// FILE: PrivateObjekt.kt + +private object PrivateObjekt + +// FILE: Main.kt + +fun test(arg: Any?) { + when (arg) { + // K1: ok + // K2: INVISIBLE_REFERENCE + @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") PrivateObjekt -> Unit + } + + @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") PrivateObjekt + + val it = @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") PrivateObjekt +} diff --git a/compiler/testData/diagnostics/tests/suppressInWhen.kt b/compiler/testData/diagnostics/tests/suppressInWhen.kt index 948455eccbe..7f647f9e90b 100644 --- a/compiler/testData/diagnostics/tests/suppressInWhen.kt +++ b/compiler/testData/diagnostics/tests/suppressInWhen.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL // ISSUE: KT-61065 // FILE: PrivateObjekt.kt diff --git a/compiler/testData/diagnostics/tests/typeParameters/typeMismatchErrorHasExpectedGenericTypeArgumentInsteadOfTypeParameter.fir.kt b/compiler/testData/diagnostics/tests/typeParameters/typeMismatchErrorHasExpectedGenericTypeArgumentInsteadOfTypeParameter.fir.kt index 11876d7c4b6..376412574e2 100644 --- a/compiler/testData/diagnostics/tests/typeParameters/typeMismatchErrorHasExpectedGenericTypeArgumentInsteadOfTypeParameter.fir.kt +++ b/compiler/testData/diagnostics/tests/typeParameters/typeMismatchErrorHasExpectedGenericTypeArgumentInsteadOfTypeParameter.fir.kt @@ -1,6 +1,6 @@ // ISSUE: KT-49035, KT-51201 -@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") fun foo(it: @kotlin.internal.Exact T) {} diff --git a/compiler/testData/diagnostics/tests/visibility/smartCastAndSuppressedVisibility.fir.kt b/compiler/testData/diagnostics/tests/visibility/smartCastAndSuppressedVisibility.fir.kt index c936cd06c2b..a095bf15229 100644 --- a/compiler/testData/diagnostics/tests/visibility/smartCastAndSuppressedVisibility.fir.kt +++ b/compiler/testData/diagnostics/tests/visibility/smartCastAndSuppressedVisibility.fir.kt @@ -11,7 +11,7 @@ internal sealed class B(val x: A) : A { } // MODULE: b(a) -@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") +@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") private fun test_1(x: A) { if (x is B) { x.foo() diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/elvisOperatorAgainstFlexibleType.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/elvisOperatorAgainstFlexibleType.fir.kt new file mode 100644 index 00000000000..5afce8e3432 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/elvisOperatorAgainstFlexibleType.fir.kt @@ -0,0 +1,19 @@ +// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER + +// FILE: Foo.java + +public class Foo { + public static void create(java.util.Map m) { return null; } +} + +// FILE: test.kt + +fun test(properties: Map, nullableProperties: Map?) { + val f1 = Foo.create(select1(properties, myEmptyMap())) + val f2 = Foo.create(nullableProperties ?: myEmptyMap()) +} + +fun myEmptyMap(): Map = TODO() + +@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER", "HIDDEN") +fun select1(x: S, y: S): @kotlin.internal.Exact S = y diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/elvisOperatorAgainstFlexibleType.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/elvisOperatorAgainstFlexibleType.kt index 75d3d917bd3..b898efead73 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/elvisOperatorAgainstFlexibleType.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/elvisOperatorAgainstFlexibleType.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER // FILE: Foo.java diff --git a/compiler/testData/diagnostics/testsWithStdLib/implicitNothingInDelegate.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/implicitNothingInDelegate.fir.kt new file mode 100644 index 00000000000..ce06f305fb6 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/implicitNothingInDelegate.fir.kt @@ -0,0 +1,19 @@ +// FIR_DUMP +// WITH_REFLECT + +import kotlin.reflect.KProperty + +@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") +public operator fun Map.getValue(thisRef: Any?, property: KProperty<*>): V1 = null!! + +val m2: Map = mapOf("baz" to "bat") +val bar: String get() = m2.getValue(null, ::bar) + +fun foo() { + val m1: Map = mapOf("foo" to "bar") + val foo: String by m1 + val baz: String by m2 + println(foo) // bar + println(baz) // kotlin.KotlinNothingValueException + println(bar) +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/implicitNothingInDelegate.fir.txt b/compiler/testData/diagnostics/testsWithStdLib/implicitNothingInDelegate.fir.txt index 0c34466069d..87443d0171a 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/implicitNothingInDelegate.fir.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/implicitNothingInDelegate.fir.txt @@ -1,4 +1,4 @@ -FILE: implicitNothingInDelegate.kt +FILE: implicitNothingInDelegate.fir.kt @R|kotlin/Suppress|(names = vararg(String(INVISIBLE_REFERENCE), String(INVISIBLE_MEMBER))) public final operator fun R|kotlin/collections/Map|.getValue(thisRef: R|kotlin/Any?|, property: R|kotlin/reflect/KProperty<*>|): R|V1| { ^getValue Null(null)!! } diff --git a/compiler/testData/diagnostics/testsWithStdLib/implicitNothingInDelegate.kt b/compiler/testData/diagnostics/testsWithStdLib/implicitNothingInDelegate.kt index a032ffe9047..5240a5a79d9 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/implicitNothingInDelegate.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/implicitNothingInDelegate.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL // FIR_DUMP // WITH_REFLECT diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/checkLowPriorityIsResolvedSuccessfully.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/checkLowPriorityIsResolvedSuccessfully.fir.kt new file mode 100644 index 00000000000..53cebc9de59 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/checkLowPriorityIsResolvedSuccessfully.fir.kt @@ -0,0 +1,26 @@ +class Foo { + @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") + @kotlin.internal.LowPriorityInOverloadResolution + val test: Bar = Bar() +} + +fun Foo.test() {} +class Bar +class Scope { + operator fun Bar.invoke(f: () -> Unit) {} +} + +fun Scope.bar(e: Foo) { + e.test {} +} + +class Baz +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +@kotlin.internal.LowPriorityInOverloadResolution +constructor(val x: Foo) + +fun Baz(x: Foo): Baz { + throw NotImplementedError() +} + +fun testBaz(e: Foo) = Baz(e) diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/checkLowPriorityIsResolvedSuccessfully.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/checkLowPriorityIsResolvedSuccessfully.kt index 908302aabc9..51704220718 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/checkLowPriorityIsResolvedSuccessfully.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/checkLowPriorityIsResolvedSuccessfully.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL class Foo { @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") @kotlin.internal.LowPriorityInOverloadResolution diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/exactAnnotation.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/exactAnnotation.fir.kt index 4ab5791bab0..f80bab45e17 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/exactAnnotation.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/exactAnnotation.fir.kt @@ -1,6 +1,6 @@ //!DIAGNOSTICS: -UNUSED_VARIABLE -@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") fun List<@kotlin.internal.Exact T>.firstTyped(): U = throw Exception() fun test1(l: List) { diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/exactAnnotationWithUpperBoundConstraint.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/exactAnnotationWithUpperBoundConstraint.fir.kt index 41456ee2e5f..a4f458130f2 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/exactAnnotationWithUpperBoundConstraint.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/exactAnnotationWithUpperBoundConstraint.fir.kt @@ -1,6 +1,6 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER -DEBUG_INFO_CONSTANT -UNUSED_EXPRESSION -@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") fun <@kotlin.internal.OnlyInputTypes K, V, V1 : V?> Map.getOrDefault_Exact(key: K, defaultValue: V1): V1 = TODO() diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/internalAnnotationsOnTypes.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/internalAnnotationsOnTypes.fir.kt new file mode 100644 index 00000000000..18f628b8374 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/internalAnnotationsOnTypes.fir.kt @@ -0,0 +1,30 @@ +//!DIAGNOSTICS: -UNUSED_PARAMETER + +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +fun Iterable<*>.filterIsInstance1(): List<@kotlin.internal.NoInfer R> = throw Exception() + +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +fun List<*>.filterIsInstance2(): @kotlin.internal.NoInfer List = throw Exception() + +fun test(list: List) { + list.filterIsInstance1().map { it * 2 } + list.filterIsInstance2().filter { it > 10 } +} + +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +fun foo(t: R): List<@kotlin.internal.NoInfer R> = throw Exception("$t") + +fun test() { + foo(1).map { it * 2 } +} + +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +fun List.foo(): @kotlin.internal.NoInfer R = throw Exception() + +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +fun bar(r: R, f: Function1<@kotlin.internal.NoInfer R, Unit>): Nothing = throw Exception() + +fun test1() { + listOf("").foo().length + bar(1) { x -> x + 1 } +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/internalAnnotationsOnTypes.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/internalAnnotationsOnTypes.kt index bd9f7f96c57..589abfaac12 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/internalAnnotationsOnTypes.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/internalAnnotationsOnTypes.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL //!DIAGNOSTICS: -UNUSED_PARAMETER @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt26698.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt26698.fir.kt new file mode 100644 index 00000000000..d732e4a68e9 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt26698.fir.kt @@ -0,0 +1,21 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE + +open class Base() +class CX : Base() +class CY : Base() + +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +fun <@kotlin.internal.OnlyInputTypes T> foo(a: T, b: T) {} + +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +fun <@kotlin.internal.OnlyInputTypes T : Any> fooA(a: T, b: T) {} + +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +fun <@kotlin.internal.OnlyInputTypes T : Base> fooB(a: T, b: T) {} + + +fun usage(x: CX, y: CY) { + foo(x, y) // expected err, got err + fooA(x, y) // expected err, got ok + fooB(x, y) // expected err, got ok +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt26698.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt26698.kt index 1b803bbd500..b12d0f58aad 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt26698.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt26698.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE open class Base() diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt35210.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt35210.fir.kt new file mode 100644 index 00000000000..ed00b39a012 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt35210.fir.kt @@ -0,0 +1,11 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + +@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") + +annotation class Anno + +fun test(a: List>) { + strictSelect(a, emptyList().map { it.annotationClass.java }) +} + +fun <@kotlin.internal.OnlyInputTypes S> strictSelect(arg1: S, arg2: S): S = TODO() diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt35210.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt35210.kt index 05f4b3a114d..fc28220c197 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt35210.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt35210.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER @file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/lowPriorityTopLevelValAndObject.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/lowPriorityTopLevelValAndObject.fir.kt new file mode 100644 index 00000000000..9460507f967 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/lowPriorityTopLevelValAndObject.fir.kt @@ -0,0 +1,36 @@ +// DIAGNOSTICS: -EXTENSION_SHADOWED_BY_MEMBER + +// FILE: a.kt +package a + +val bar get() = "" + +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +@kotlin.internal.LowPriorityInOverloadResolution +val baz get() = "" + +// FILE: b.kt +package b + +object bar +object baz { + val qux = 1 +} + +// FILE: test.kt +import a.* +import b.* + +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +class Foo { + @kotlin.internal.LowPriorityInOverloadResolution + val bar = 1 + + @kotlin.internal.LowPriorityInOverloadResolution + val baz = 1 +} + +fun Foo.test() { + bar.length + baz.qux +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/lowPriorityTopLevelValAndObject.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/lowPriorityTopLevelValAndObject.kt index f6bd131007e..fe5c2b2285b 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/lowPriorityTopLevelValAndObject.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/lowPriorityTopLevelValAndObject.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL // DIAGNOSTICS: -EXTENSION_SHADOWED_BY_MEMBER // FILE: a.kt diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/noInferAndLowPriority.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/noInferAndLowPriority.fir.kt index b646ba67ba7..77e63cffd4e 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/noInferAndLowPriority.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/noInferAndLowPriority.fir.kt @@ -1,11 +1,11 @@ //!DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") @kotlin.jvm.JvmName("containsAny") @kotlin.internal.LowPriorityInOverloadResolution public fun Iterable.contains1(element: T): Int = null!! -@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") public fun Iterable.contains1(element: @kotlin.internal.NoInfer T): Boolean = null!! diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/noInferAnnotation.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/noInferAnnotation.fir.kt index 660c1b2055e..8315da9de4e 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/noInferAnnotation.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/noInferAnnotation.fir.kt @@ -1,12 +1,12 @@ //!DIAGNOSTICS: -UNUSED_PARAMETER -@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") fun test1(t1: T, t2: @kotlin.internal.NoInfer T): T = t1 -@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") fun @kotlin.internal.NoInfer T.test2(t1: T): T = t1 -@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") fun test3(t1: @kotlin.internal.NoInfer T): T = t1 fun usage() { @@ -15,7 +15,7 @@ fun usage() { test3("") } -@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") fun List.contains1(e: @kotlin.internal.NoInfer T): Boolean = true fun test(i: Int?, a: Any, l: List) { @@ -24,7 +24,7 @@ fun test(i: Int?, a: Any, l: List) { l.contains1(i) } -@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") fun assertEquals1(e1: T, e2: @kotlin.internal.NoInfer T): Boolean = true fun test(s: String) { diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypeAndJava.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypeAndJava.fir.kt new file mode 100644 index 00000000000..b5391e180c3 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypeAndJava.fir.kt @@ -0,0 +1,17 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + +// FILE: TestBase.java + +public class TestBase { } + +// FILE: Test.java + +public class Test extends TestBase { } + +// FILE: main.kt + +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +fun <@kotlin.internal.OnlyInputTypes K> TestBase.foo(key: K) = null +fun foo(result: Test<*>) { + result.foo("sd") // Type inference failed (NI), OK in OI +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypeAndJava.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypeAndJava.kt index cdfff5814d3..22a6b28759f 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypeAndJava.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypeAndJava.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER // FILE: TestBase.java diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypeRecursiveBoundAndProjections.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypeRecursiveBoundAndProjections.fir.kt new file mode 100644 index 00000000000..3e63912513c --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypeRecursiveBoundAndProjections.fir.kt @@ -0,0 +1,24 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + +@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") + +interface IFace + +fun <@kotlin.internal.OnlyInputTypes K, V> IFace.get(key: K): V? = TODO() +fun <@kotlin.internal.OnlyInputTypes I> id(arg: I): I = arg + +interface InvBase +class DerivedInv : InvBase +class InvRecursive> + +fun test1(argument: InvRecursive<*>, receiver: IFace, Any>) { + receiver.get(argument) +} + +fun test2(arg: InvRecursive) { + id(arg) +} + +fun test3(arg: InvRecursive) { + id(arg) +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypeRecursiveBoundAndProjections.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypeRecursiveBoundAndProjections.kt index df166ba2065..fcad07fe37a 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypeRecursiveBoundAndProjections.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypeRecursiveBoundAndProjections.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER @file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypes.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypes.fir.kt new file mode 100644 index 00000000000..19380d54a10 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypes.fir.kt @@ -0,0 +1,46 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE + +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +public fun <@kotlin.internal.OnlyInputTypes T> Iterable.contains1(element: T): Boolean = null!! + +class In + +class Out + +class Inv + +fun test_1(list: List>, x: In, y: In, z: In) { + list.contains1(x) + list.contains1(y) + list.contains1(z) +} + +fun test_2(list: List>, x: In, y: In, z: In) { + list.contains1(x) + list.contains1(y) + list.contains1(z) +} + +fun test_3(list: List>, x: Out, y: Out, z: Out) { + list.contains1(x) + list.contains1(y) + list.contains1(z) +} + +fun test_4(list: List>, x: Out, y: Out, z: Out) { + list.contains1(x) + list.contains1(y) + list.contains1(z) +} + +fun test_5(list: List>, x: Inv, y: Inv, z: Inv) { + list.contains1(x) + list.contains1(y) + list.contains1(z) +} + +fun test_6(list: List>, x: Inv, y: Inv, z: Inv) { + list.contains1(x) + list.contains1(y) + list.contains1(z) +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypes.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypes.kt index 8fa1eace4a2..6802cdfd797 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypes.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypes.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAndClassLiterals.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAndClassLiterals.fir.kt index f9823c06fc1..0fafca6ed3a 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAndClassLiterals.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAndClassLiterals.fir.kt @@ -3,7 +3,7 @@ // FULL_JDK import java.lang.reflect.Field -@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") fun <@kotlin.internal.OnlyInputTypes T> assertEquals(expected: T, actual: T): T = actual fun test(field: Field) { diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAndLowPriority.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAndLowPriority.fir.kt index b42dcf79726..fccfa07c7c8 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAndLowPriority.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAndLowPriority.fir.kt @@ -1,19 +1,19 @@ //!DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") @kotlin.jvm.JvmName("containsAny") @kotlin.internal.LowPriorityInOverloadResolution public fun Iterable.contains1(element: T): Int = null!! -@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") public fun <@kotlin.internal.OnlyInputTypes T> Iterable.contains1(element: T): Boolean = null!! -@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") @JvmName("getAny") @kotlin.internal.LowPriorityInOverloadResolution public fun Map.get1(key: Any?): Int = null!! -@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") public fun <@kotlin.internal.OnlyInputTypes K, V> Map.get1(key: K): V? = null!! fun test(map: Map) { diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAndTopLevelCapturedTypes.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAndTopLevelCapturedTypes.fir.kt index 839cb7b2ff4..7508e04c33f 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAndTopLevelCapturedTypes.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAndTopLevelCapturedTypes.fir.kt @@ -2,13 +2,13 @@ class Inv -@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") fun <@kotlin.internal.OnlyInputTypes K> Inv.onlyOut(e: K) {} -@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") fun <@kotlin.internal.OnlyInputTypes K : Number> Inv.onlyOutUB(e: K) {} -@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") fun <@kotlin.internal.OnlyInputTypes K> Inv.onlyIn(e: K) {} fun test( diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAnnotationWithPlatformTypes.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAnnotationWithPlatformTypes.fir.kt new file mode 100644 index 00000000000..c9798381f8e --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAnnotationWithPlatformTypes.fir.kt @@ -0,0 +1,19 @@ +//!DIAGNOSTICS: -UNUSED_PARAMETER + +//FILE:Foo.java + +public class Foo { + public static String foo() { + return null; + } +} + +//FILE:Bar.kt + +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +fun <@kotlin.internal.OnlyInputTypes T> assertEquals1(t1: T, t2: T) {} + +fun test() { + assertEquals1(null, Foo.foo()) + assertEquals1("", Foo.foo()) +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAnnotationWithPlatformTypes.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAnnotationWithPlatformTypes.kt index 5d4881aaafd..6e534cfe513 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAnnotationWithPlatformTypes.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAnnotationWithPlatformTypes.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL //!DIAGNOSTICS: -UNUSED_PARAMETER //FILE:Foo.java diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesCaptured.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesCaptured.fir.kt new file mode 100644 index 00000000000..ee598a54275 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesCaptured.fir.kt @@ -0,0 +1,112 @@ +// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER +// Issue: KT-26698 + +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +public fun <@kotlin.internal.OnlyInputTypes T> Iterable.contains1(element: T): Boolean = null!! + +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +public fun <@kotlin.internal.OnlyInputTypes T> Iterable.foo(element: T): T = null!! + +class Inv +class Inv2 + +class In +class Out + +// ------------------------------------------------------- + +fun test_0(x: Inv2, list: List>) { + list.foo(x) +} + +// ------------------------- Inv ------------------------- + +fun test_1(x: Inv, list: List>) { + list.contains1(x) +} + +fun test_2(x: Inv, list: List>) { + list.contains1(x) +} + +fun test_3(x: Inv, list: List>) { + list.contains1(x) +} + +fun test_4(x: Inv, list: List>) { + list.contains1(x) +} + +fun test_5(x: Inv, list: List>) { + list.contains1(x) +} + +fun test_6(x: Inv, list: List>) { + list.contains1(x) +} + +fun test_7(x: Inv, list: List>) { + list.contains1(x) +} + +fun test_8(x: Inv, list: List>) { + list.contains1(x) +} + +fun test_9(x: Inv, list: List>) { + list.contains1(x) +} + +// ------------------------- In ------------------------- + +fun test_11(x: In, list: List>) { + list.contains1(x) +} + +fun test_12(x: In, list: List>) { + list.contains1(x) +} + +fun test_13(x: In, list: List>) { + list.contains1(x) +} + +// ------------------------- Out ------------------------- + +fun test_21(x: Out, list: List>) { + list.contains1(x) +} + +fun test_22(x: Out, list: List>) { + list.contains1(x) +} + +fun test_23(x: Out, list: List>) { + list.contains1(x) +} + +// -------------------------------------------------------- + +fun test_31(x: Inv, list: List>) { + list.contains1(x) +} + +fun test_32(x: Inv, list: List>) { + list.contains1(x) +} + +fun test_33(x: Inv, list: List>) { + list.contains1(x) +} + +fun test_34(x: Inv, list: List>) { + list.contains1(x) +} + +fun test_35(x: Inv, list: List>) { + list.contains1(x) +} + +fun test_36(x: Inv, list: List>) { + list.contains1(x) +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesCaptured.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesCaptured.kt index 6e1b0c55372..3cab312337d 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesCaptured.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesCaptured.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER // Issue: KT-26698 diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesCommonConstraintSystem.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesCommonConstraintSystem.fir.kt new file mode 100644 index 00000000000..45fce545ae1 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesCommonConstraintSystem.fir.kt @@ -0,0 +1,53 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE + +@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") + +import kotlin.internal.OnlyInputTypes + +interface Bound +class First : Bound +class Second : Bound +class Inv(val v: I) +class InvB(val v: I) +class In(v: C) +class InB(v: C) +class Out(val v: O) +class OutB(val v: O) + +fun <@OnlyInputTypes M> strictId(arg: M): M = arg +fun <@OnlyInputTypes S> strictSelect(arg1: S, arg2: S): S = arg1 + +fun testOK(first: First, bound: Bound, second: Second) { + strictId(Inv(15)) + strictId(Inv("foo")) + strictId(Inv(first)) + strictId(InvB(first)) + strictId(In(first)) + strictId(InB(first)) + strictId(Out(first)) + strictId(OutB(first)) + strictId(Inv(Inv(Inv(first)))) + + strictSelect(Inv(first), Inv(first)) + strictSelect(InvB(first), InvB(first)) + + strictSelect(Out(first), Out(bound)) + strictSelect(OutB(first), OutB(bound)) + strictSelect(In(first), In(bound)) + strictSelect(InB(first), InB(bound)) + + val out: Out = strictSelect(Out(first), Out(second)) + val outb: OutB = strictSelect(OutB(first), OutB(second)) + strictSelect>(Out(first), Out(second)) + strictSelect>(OutB(first), OutB(second)) +} + +fun testFail(first: First, bound: Bound, second: Second) { + strictSelect(InvB(first), InvB(bound)) + strictSelect(Inv(first), Inv(bound)) + strictSelect(Out(first), Out(second)) + strictSelect(In(first), In(second)) + strictSelect(InB(first), InB(second)) + strictSelect(Out(Inv(first)), Out(Inv(second))) + strictSelect(In(Inv(first)), In(Inv(second))) +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesCommonConstraintSystem.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesCommonConstraintSystem.kt index 5d1ce6b2c96..f6665db1914 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesCommonConstraintSystem.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesCommonConstraintSystem.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE @file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesUpperBound.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesUpperBound.fir.kt index ecbe41d72e4..ced5464c784 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesUpperBound.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesUpperBound.fir.kt @@ -1,6 +1,6 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") class Inv class Out diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesWarning.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesWarning.fir.kt index 662cb6bd402..e153fd19ef6 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesWarning.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesWarning.fir.kt @@ -1,7 +1,7 @@ // !LANGUAGE: -StrictOnlyInputTypesChecks // !DIAGNOSTICS: -UNUSED_PARAMETER -@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") fun <@kotlin.internal.OnlyInputTypes S> select(a1: S, a2: S): S = TODO() interface Common diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/propagationOfNoInferAnnotation.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/propagationOfNoInferAnnotation.fir.kt new file mode 100644 index 00000000000..42e62ef6eee --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/propagationOfNoInferAnnotation.fir.kt @@ -0,0 +1,25 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + +private object TopLevelTypeVariable { + @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE", "HIDDEN") + fun foo(): @kotlin.internal.NoInfer T = TODO() + + fun bar(k: K) {} + + fun test() { + bar(foo()) + } +} + +private object NestedTypeVariable { + class Inv + + @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE", "HIDDEN") + fun foo(): Inv<@kotlin.internal.NoInfer T> = TODO() + + fun bar(p: Inv) {} + + fun test() { + bar(foo()) + } +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/propagationOfNoInferAnnotation.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/propagationOfNoInferAnnotation.kt index 72014270ae5..aaf37741399 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/propagationOfNoInferAnnotation.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/propagationOfNoInferAnnotation.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER private object TopLevelTypeVariable { diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/resolveWithOnlyInputTypesAnnotation.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/resolveWithOnlyInputTypesAnnotation.fir.kt new file mode 100644 index 00000000000..a8dfcd17935 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/resolveWithOnlyInputTypesAnnotation.fir.kt @@ -0,0 +1,24 @@ +//!DIAGNOSTICS: -UNUSED_PARAMETER + +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +fun <@kotlin.internal.OnlyInputTypes T> assertEquals1(t1: T, t2: T) {} + +open class A +class B: A() +class C: A() +class D + +fun test1(a: A, b: B, c: C) { + assertEquals1(a, b) + assertEquals1(b, c) + + assertEquals1(3, 3) + assertEquals1(1 or 2, 2 or 1) +} + +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +public fun <@kotlin.internal.OnlyInputTypes T> expect1(expected: T, block: () -> T) {} + +fun test() { + expect1(2) { byteArrayOf(1, 2, 3).indexOf(3) } +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/resolveWithOnlyInputTypesAnnotation.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/resolveWithOnlyInputTypesAnnotation.kt index efd1fe7d595..09337b56616 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/resolveWithOnlyInputTypesAnnotation.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/resolveWithOnlyInputTypesAnnotation.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL //!DIAGNOSTICS: -UNUSED_PARAMETER @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") diff --git a/compiler/testData/diagnostics/testsWithStdLib/kt55503_2.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/kt55503_2.fir.kt new file mode 100644 index 00000000000..9989deecf0a --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/kt55503_2.fir.kt @@ -0,0 +1,31 @@ +// WITH_STDLIB +// FIR_DUMP + +// FILE: First.kt + +package sample.pack + +@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") +@kotlin.internal.HidesMembers +fun A.forEach() = "::A.forEach" + +class A { + fun B.forEach() = "A::B.forEach" +} + +class B + +// FILE: Second.kt + +package sample + +import sample.pack.* + +fun box() { + return with(A()) { + with(B()) { + // Both K1 & K2 resolve to A::B.check + forEach() + } + } +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/kt55503_2.kt b/compiler/testData/diagnostics/testsWithStdLib/kt55503_2.kt index f71bfbe43cd..42861b15e8c 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/kt55503_2.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/kt55503_2.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL // WITH_STDLIB // FIR_DUMP diff --git a/compiler/testData/diagnostics/testsWithStdLib/pureReifiable.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/pureReifiable.fir.kt new file mode 100644 index 00000000000..257337ab972 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/pureReifiable.fir.kt @@ -0,0 +1,12 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +inline fun foo(x: T) {} + +fun test() { + foo>(listOf("")) + foo(listOf("")) + + foo>(arrayOf("")) + foo(arrayOf("")) +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/pureReifiable.kt b/compiler/testData/diagnostics/testsWithStdLib/pureReifiable.kt index 203678eff51..648e86cbe34 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/pureReifiable.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/pureReifiable.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") diff --git a/compiler/testData/diagnostics/testsWithStdLib/resolve/hidesMembers.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/resolve/hidesMembers.fir.kt index aadc9fb1e0f..48ba21d28d7 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/resolve/hidesMembers.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/resolve/hidesMembers.fir.kt @@ -6,11 +6,11 @@ package b import a.A -@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") @kotlin.internal.HidesMembers fun A.forEach(i: Int) = i -@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") @kotlin.internal.HidesMembers fun A.forEach(s: String) {} @@ -28,11 +28,11 @@ class A { fun forEach(i: String) = this } -@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") @kotlin.internal.HidesMembers fun A.forEach() = "" -@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") @kotlin.internal.HidesMembers fun A.forEach(s: String) {} diff --git a/compiler/testData/diagnostics/testsWithStdLib/resolve/hidesMembers2.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/resolve/hidesMembers2.fir.kt index 1b43cbdcdde..750f7b51c5f 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/resolve/hidesMembers2.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/resolve/hidesMembers2.fir.kt @@ -6,12 +6,12 @@ class A { fun forEach(i: Int) = this } -@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") @kotlin.internal.HidesMembers fun A.forEach(i: Int) = i class B { - @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") + @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") @kotlin.internal.HidesMembers fun A.forEach() = this@B @@ -25,11 +25,11 @@ class B { } fun test2(a: A) { - @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") + @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") @kotlin.internal.HidesMembers fun A.forEach() = "" - @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") + @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") @kotlin.internal.HidesMembers fun A.forEach(i: Int) = "" diff --git a/compiler/testData/javaModules/coroutinesDebugMetadata/usage.fir.txt b/compiler/testData/javaModules/coroutinesDebugMetadata/usage.fir.txt new file mode 100644 index 00000000000..234542b7a23 --- /dev/null +++ b/compiler/testData/javaModules/coroutinesDebugMetadata/usage.fir.txt @@ -0,0 +1,7 @@ +compiler/testData/javaModules/coroutinesDebugMetadata/usage/usage.kt:1:16: warning: this code uses error suppression for 'INVISIBLE_REFERENCE'. While it might compile and work, the compiler behavior is UNSPECIFIED and WON'T BE PRESERVED. Please report your use case to the Kotlin issue tracker instead: https://kotl.in/issue +@file:Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER", "CANNOT_OVERRIDE_INVISIBLE_MEMBER") + ^ +compiler/testData/javaModules/coroutinesDebugMetadata/usage/usage.kt:1:59: warning: this code uses error suppression for 'CANNOT_OVERRIDE_INVISIBLE_MEMBER'. While it might compile and work, the compiler behavior is UNSPECIFIED and WON'T BE PRESERVED. Please report your use case to the Kotlin issue tracker instead: https://kotl.in/issue +@file:Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER", "CANNOT_OVERRIDE_INVISIBLE_MEMBER") + ^ +OK diff --git a/plugins/parcelize/parcelize-compiler/testData/diagnostics/properties.fir.kt b/plugins/parcelize/parcelize-compiler/testData/diagnostics/properties.fir.kt new file mode 100644 index 00000000000..b24618385ef --- /dev/null +++ b/plugins/parcelize/parcelize-compiler/testData/diagnostics/properties.fir.kt @@ -0,0 +1,37 @@ +// WITH_STDLIB +package test + +import kotlinx.parcelize.* +import android.os.Parcelable + +@Parcelize +class A(val firstName: String) : Parcelable { + val secondName: String = "" + + val delegated by lazy { "" } + + lateinit var lateinit: String + + val customGetter: String + get() = "" + + var customSetter: String + get() = "" + set(v) {} +} + +@Parcelize +@Suppress("WRONG_ANNOTATION_TARGET_WITH_USE_SITE_TARGET") +class B(@IgnoredOnParcel val firstName: String) : Parcelable { + @IgnoredOnParcel + var a: String = "" + + @field:IgnoredOnParcel + var b: String = "" + + @get:IgnoredOnParcel + var c: String = "" + + @set:IgnoredOnParcel + var d: String = "" +} diff --git a/plugins/parcelize/parcelize-compiler/testData/diagnostics/properties.kt b/plugins/parcelize/parcelize-compiler/testData/diagnostics/properties.kt index 7accf7d15dc..cf02ad6ed4f 100644 --- a/plugins/parcelize/parcelize-compiler/testData/diagnostics/properties.kt +++ b/plugins/parcelize/parcelize-compiler/testData/diagnostics/properties.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL // WITH_STDLIB package test