[Tests] Update test data with error suppression warnings

#KT-61129 Fixed
This commit is contained in:
Kirill Rakhman
2023-08-14 13:14:04 +02:00
committed by Space Team
parent 969c716c76
commit 5b9c35de2e
88 changed files with 889 additions and 87 deletions
@@ -1,6 +1,6 @@
// ISSUE: KT-54478
@file:Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER")
@file:Suppress(<!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>, "INVISIBLE_MEMBER")
import kotlin.internal.NoInfer
@@ -4,7 +4,7 @@ interface A {
fun foo()
}
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@Suppress("INVISIBLE_MEMBER", <!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>)
fun <K> checkNotNull(x: K?, y: K): @kotlin.internal.Exact K {
return x ?: y
}
@@ -1,6 +1,6 @@
fun foo(x: String) {}
@Suppress("ARGUMENT_TYPE_MISMATCH")
@Suppress(<!ERROR_SUPPRESSION!>"ARGUMENT_TYPE_MISMATCH"<!>)
fun bar() {
foo(10)
}
@@ -1,20 +1,20 @@
const val x = "123"
@Suppress("CONST_VAL_WITH_GETTER")
@Suppress(<!ERROR_SUPPRESSION!>"CONST_VAL_WITH_GETTER"<!>)
get() = field
val y = "789"
const val z = @Suppress("CONST_VAL_WITH_NON_CONST_INITIALIZER") y
const val z = @Suppress(<!ERROR_SUPPRESSION!>"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(<!ERROR_SUPPRESSION!>"REPEATED_ANNOTATION"<!>) @Ann @Ann Int = 42
typealias Alias<T> = @Suppress("TYPEALIAS_SHOULD_EXPAND_TO_CLASS") T
typealias Alias<T> = @Suppress(<!ERROR_SUPPRESSION!>"TYPEALIAS_SHOULD_EXPAND_TO_CLASS"<!>) T
interface A
interface B : @Suppress("SUPERTYPE_INITIALIZED_IN_INTERFACE") A<!NO_CONSTRUCTOR!>()<!>
interface B : @Suppress(<!ERROR_SUPPRESSION!>"SUPERTYPE_INITIALIZED_IN_INTERFACE"<!>) A<!NO_CONSTRUCTOR!>()<!>
data class D @Suppress("DATA_CLASS_VARARG_PARAMETER") constructor(vararg val x: String)
data class D @Suppress(<!ERROR_SUPPRESSION!>"DATA_CLASS_VARARG_PARAMETER"<!>) constructor(vararg val x: String)
@@ -2,23 +2,23 @@ abstract class A
fun foo(i: Int) {}
<!VALUE_CLASS_WITHOUT_JVM_INLINE_ANNOTATION!>value<!> class B(val i: Int) : @Suppress("VALUE_CLASS_CANNOT_EXTEND_CLASSES") A() {
@Suppress("SECONDARY_CONSTRUCTOR_WITH_BODY_INSIDE_VALUE_CLASS")
<!VALUE_CLASS_WITHOUT_JVM_INLINE_ANNOTATION!>value<!> class B(val i: Int) : @Suppress(<!ERROR_SUPPRESSION!>"VALUE_CLASS_CANNOT_EXTEND_CLASSES"<!>) A() {
@Suppress(<!ERROR_SUPPRESSION!>"SECONDARY_CONSTRUCTOR_WITH_BODY_INSIDE_VALUE_CLASS"<!>)
constructor() : this(42) {
foo(i)
}
@Suppress("ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS")
@Suppress(<!ERROR_SUPPRESSION!>"ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS"<!>)
abstract val y: Int
}
interface C {
@Suppress("PRIVATE_PROPERTY_IN_INTERFACE")
@Suppress(<!ERROR_SUPPRESSION!>"PRIVATE_PROPERTY_IN_INTERFACE"<!>)
private val x: Int
@Suppress("METHOD_OF_ANY_IMPLEMENTED_IN_INTERFACE")
@Suppress(<!ERROR_SUPPRESSION!>"METHOD_OF_ANY_IMPLEMENTED_IN_INTERFACE"<!>)
override fun hashCode() = 42
}
<!MUST_BE_INITIALIZED!>@Suppress("PROPERTY_WITH_NO_TYPE_NO_INITIALIZER")
<!MUST_BE_INITIALIZED!>@Suppress(<!ERROR_SUPPRESSION!>"PROPERTY_WITH_NO_TYPE_NO_INITIALIZER"<!>)
val z<!>
@@ -1,4 +1,4 @@
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@Suppress("INVISIBLE_MEMBER", <!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>)
@kotlin.internal.LowPriorityInOverloadResolution
fun foo(): Int = 1
@@ -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", <!ERROR_SUPPRESSION!>"INCOMPATIBLE_TYPES"<!>)
fun testUnckeckedAsFromAny(x: Any) {
<!UNCHECKED_CAST_TO_FORWARD_DECLARATION!>x as? cnames.structs.FwdStruct<!>
<!UNCHECKED_CAST_TO_FORWARD_DECLARATION!>x as? objcnames.classes.FwdObjcClass<!>
<!UNCHECKED_CAST_TO_FORWARD_DECLARATION!>x as? objcnames.protocols.FwdProtocol<!>
if (1 > 0) { <!UNCHECKED_CAST_TO_FORWARD_DECLARATION!>x as cnames.structs.FwdStruct<!> }
if (1 > 0) { <!UNCHECKED_CAST_TO_FORWARD_DECLARATION!>x as objcnames.classes.FwdObjcClass<!> }
if (1 > 0) { <!UNCHECKED_CAST_TO_FORWARD_DECLARATION!>x as objcnames.protocols.FwdProtocol<!> }
}
fun testIs(x: Any) : Int {
return when {
<!CANNOT_CHECK_FOR_FORWARD_DECLARATION!>x is cnames.structs.FwdStruct<!> -> 1
<!CANNOT_CHECK_FOR_FORWARD_DECLARATION!>x is objcnames.classes.FwdObjcClass<!> -> 2
<!CANNOT_CHECK_FOR_FORWARD_DECLARATION!>x is objcnames.protocols.FwdProtocol<!> -> 3
else -> 4
}
}
fun testIs2(x: lib.FwdStruct) = <!CANNOT_CHECK_FOR_FORWARD_DECLARATION!>x is cnames.structs.FwdStruct<!>
fun testIs3(x: lib.FwdObjcClass) = <!CANNOT_CHECK_FOR_FORWARD_DECLARATION!>x is objcnames.classes.FwdObjcClass<!>
fun testIs4(x: lib.FwdProtocol) = <!CANNOT_CHECK_FOR_FORWARD_DECLARATION!>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() {
<!FORWARD_DECLARATION_AS_CLASS_LITERAL!>cnames.structs.FwdStruct::class<!>
<!FORWARD_DECLARATION_AS_CLASS_LITERAL!>objcnames.classes.FwdObjcClass::class<!>
<!FORWARD_DECLARATION_AS_CLASS_LITERAL!>objcnames.protocols.FwdProtocol::class<!>
}
inline fun <reified T> inlineF(x: T) {}
fun testInline1(x : cnames.structs.FwdStruct) = <!FORWARD_DECLARATION_AS_REIFIED_TYPE_ARGUMENT!>inlineF<!>(x)
fun testInline2(x : objcnames.classes.FwdObjcClass) = <!FORWARD_DECLARATION_AS_REIFIED_TYPE_ARGUMENT!>inlineF<!>(x)
fun testInline3(x : objcnames.protocols.FwdProtocol) = <!FORWARD_DECLARATION_AS_REIFIED_TYPE_ARGUMENT!>inlineF<!>(x)
fun testInline4() {
val a : (cnames.structs.FwdStruct) -> Unit = ::<!FORWARD_DECLARATION_AS_REIFIED_TYPE_ARGUMENT!>inlineF<!>
val b : (objcnames.classes.FwdObjcClass) -> Unit = ::<!FORWARD_DECLARATION_AS_REIFIED_TYPE_ARGUMENT!>inlineF<!>
val c : (objcnames.protocols.FwdProtocol) -> Unit = ::<!FORWARD_DECLARATION_AS_REIFIED_TYPE_ARGUMENT!>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) = <!UNCHECKED_CAST_TO_FORWARD_DECLARATION!>x as cnames.structs.FwdStruct<!>
fun testUnCheckedAs2(x : lib2.FwdObjcClass) = <!UNCHECKED_CAST_TO_FORWARD_DECLARATION!>x as objcnames.classes.FwdObjcClass<!>
fun testUnCheckedAs3(x : lib2.FwdProtocol) = <!UNCHECKED_CAST_TO_FORWARD_DECLARATION!>x as objcnames.protocols.FwdProtocol<!>
fun testUnCheckedAs4(x : lib.FwdStruct) = <!UNCHECKED_CAST_TO_FORWARD_DECLARATION!>x as objcnames.classes.FwdObjcClass<!>
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
// WITH_STDLIB
// FILE: stdlib.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", <!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>)
import kotlin.internal.PlatformDependent
interface I {
@PlatformDependent
fun f() {}
}
class C : I {
fun <!VIRTUAL_MEMBER_HIDDEN!>f<!>() {}
}
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
// ISSUE: KT-57858
// FILE: Sub.kt
@@ -1,4 +1,4 @@
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@file:Suppress("INVISIBLE_MEMBER", <!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>)
package test
import kotlin.internal.RequireKotlin
@@ -2,6 +2,7 @@
// WITH_STDLIB
// SKIP_TXT
// WORKS_WHEN_VALUE_CLASS
// DONT_WARN_ON_ERROR_SUPPRESSION
@file:Suppress("INLINE_CLASS_DEPRECATED")
@@ -2,6 +2,7 @@
// WITH_STDLIB
// SKIP_TXT
// WORKS_WHEN_VALUE_CLASS
// DONT_WARN_ON_ERROR_SUPPRESSION
@file:Suppress("INLINE_CLASS_DEPRECATED")
@@ -0,0 +1,12 @@
// WITH_STDLIB
@file:Suppress(<!ERROR_SUPPRESSION!>"OPTIONAL_DECLARATION_USAGE_IN_NON_COMMON_SOURCE"<!>)
import kotlin.js.*
import kotlin.native.concurrent.*
@JsName("")
public fun test() {}
@ThreadLocal
private val EmptyArray: Array<Int> = arrayOf()
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
// WITH_STDLIB
@file:Suppress("OPTIONAL_DECLARATION_USAGE_IN_NON_COMMON_SOURCE")
@@ -0,0 +1,10 @@
import kotlin.reflect.KClass
typealias MyString = String
fun test(k: KClass<out MyString>) {
k::class.java
}
@Suppress(<!ERROR_SUPPRESSION!>"UPPER_BOUND_VIOLATED"<!>)
public val <T> KClass<T>.java: Class<T> get() = TODO()
@@ -1,5 +1,3 @@
// FIR_IDENTICAL
import kotlin.reflect.KClass
typealias MyString = String
@@ -41,7 +41,7 @@ fun test(i: Inv<Nothing>, iUnit: Inv<Unit>) {
run(A.flexible(iUnit)) { 42 }
}
launch {
@Suppress("UNSUPPORTED")
@Suppress(<!ERROR_SUPPRESSION!>"UNSUPPORTED"<!>)
run<dynamic> { "" }
}
@@ -4,7 +4,7 @@ interface A
interface B : A
interface C : A
@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER", "HIDDEN")
@Suppress(<!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>, "INVISIBLE_MEMBER", "HIDDEN")
fun <K> select(x: K, y: K): @kotlin.internal.Exact K = x
fun foo(a: Any) {}
@@ -4,7 +4,7 @@ interface A
interface B : A
interface C : A
@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER", "HIDDEN")
@Suppress(<!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>, "INVISIBLE_MEMBER", "HIDDEN")
fun <K> select(x: K, y: K): @kotlin.internal.Exact K = x
fun foo(a: Any) {}
@@ -4,7 +4,7 @@ interface ISample
fun <K> elvisSimple(x: K?, y: K): K = y
@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER", "HIDDEN")
@Suppress(<!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>, "INVISIBLE_MEMBER", "HIDDEN")
fun <K> elvisExact(x: K?, y: K): @kotlin.internal.Exact K = y
fun <T : Number> materialize(): T? = TODO()
@@ -4,7 +4,7 @@ interface ISample
fun <K> elvisSimple(x: K?, y: K): K = y
@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER", "HIDDEN")
@Suppress(<!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>, "INVISIBLE_MEMBER", "HIDDEN")
fun <K> elvisExact(x: K?, y: K): @kotlin.internal.Exact K = y
fun <T : Number> materialize(): T? = null
@@ -1,6 +1,6 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@file:Suppress("INVISIBLE_MEMBER", <!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>)
import kotlin.internal.Exact
@@ -0,0 +1,15 @@
// WITH_STDLIB
// !DIAGNOSTICS: -UNUSED_PARAMETER
@file:Suppress("INVISIBLE_MEMBER", <!ERROR_SUPPRESSION!>"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() }
)
}
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
// WITH_STDLIB
// !DIAGNOSTICS: -UNUSED_PARAMETER
@@ -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 = <!ACTUAL_TYPEALIAS_TO_SPECIAL_ANNOTATION!>kotlin.Deprecated<!>
@Suppress(<!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>)
internal actual typealias TypealiasToInternalPkg = <!ACTUAL_TYPEALIAS_TO_SPECIAL_ANNOTATION!>kotlin.internal.RequireKotlin<!>
actual typealias TypealiasToAnnotationPkg = <!ACTUAL_TYPEALIAS_TO_SPECIAL_ANNOTATION!>kotlin.annotation.Target<!>
actual typealias TypealiasToPlatformPkg = kotlin.jvm.Synchronized
typealias NonActualTypealias = kotlin.Deprecated
actual typealias TypealiasNotToAnnotation = kotlin.DeprecationLevel
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
// WITH_STDLIB
// MODULE: m1-common
// FILE: common.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(<!ERROR_SUPPRESSION!>"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() {}
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
// WITH_STDLIB
// MODULE: m1-common
// FILE: common.kt
@@ -1,6 +1,6 @@
import kotlin.contracts.*
@Suppress("OPT_IN_USAGE_ERROR", "OPT_IN_USAGE_FUTURE_ERROR")
@Suppress(<!ERROR_SUPPRESSION!>"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(<!ERROR_SUPPRESSION!>"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(<!ERROR_SUPPRESSION!>"OPT_IN_USAGE_ERROR"<!>, "OPT_IN_USAGE_FUTURE_ERROR")
inline fun exactlyOnce(block: () -> Unit) {
contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
@@ -1,6 +1,6 @@
import kotlin.contracts.*
@Suppress("OPT_IN_USAGE_ERROR", "OPT_IN_USAGE_FUTURE_ERROR")
@Suppress(<!ERROR_SUPPRESSION!>"OPT_IN_USAGE_ERROR"<!>, "OPT_IN_USAGE_FUTURE_ERROR")
fun foo(f1: () -> Unit, f2: () -> Unit) {
contract {
callsInPlace(f1, InvocationKind.EXACTLY_ONCE)
@@ -0,0 +1,21 @@
import kotlin.contracts.*
@Suppress(<!ERROR_SUPPRESSION!>"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()
<!SMARTCAST_IMPOSSIBLE!>s<!>.length
}
}
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
import kotlin.contracts.*
@Suppress("OPT_IN_USAGE_ERROR", "OPT_IN_USAGE_FUTURE_ERROR")
@@ -0,0 +1,5 @@
class A {
@Suppress(<!ERROR_SUPPRESSION!>"NOTHING_TO_OVERRIDE"<!>)
override fun foo() {}
}
@@ -1,5 +1,3 @@
// FIR_IDENTICAL
class A {
@Suppress("NOTHING_TO_OVERRIDE")
override fun foo() {}
@@ -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", <!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>) PrivateObjekt -> Unit
}
@Suppress("INVISIBLE_MEMBER", <!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>) PrivateObjekt
val it = @Suppress("INVISIBLE_MEMBER", <!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>) PrivateObjekt
}
-1
View File
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
// ISSUE: KT-61065
// FILE: PrivateObjekt.kt
@@ -1,6 +1,6 @@
// ISSUE: KT-49035, KT-51201
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@file:Suppress("INVISIBLE_MEMBER", <!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>)
fun <T> foo(it: @kotlin.internal.Exact T) {}
@@ -11,7 +11,7 @@ internal sealed class B(val x: A) : A {
}
// MODULE: b(a)
@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER")
@Suppress(<!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>, "INVISIBLE_MEMBER")
private fun test_1(x: A) {
if (x is B) {
x.foo()
@@ -0,0 +1,19 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER
// FILE: Foo.java
public class Foo {
public static <K, V> void create(java.util.Map<? extends K, ? extends V> m) { return null; }
}
// FILE: test.kt
fun test(properties: Map<String, String>, nullableProperties: Map<String, String>?) {
val f1 = Foo.create(select1(properties, myEmptyMap()))
val f2 = Foo.create(nullableProperties ?: myEmptyMap())
}
fun <T, R> myEmptyMap(): Map<T, R> = TODO()
@Suppress(<!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>, "INVISIBLE_MEMBER", "HIDDEN")
fun <S> select1(x: S, y: S): @kotlin.internal.Exact S = y
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER
// FILE: Foo.java
@@ -0,0 +1,19 @@
// FIR_DUMP
// WITH_REFLECT
import kotlin.reflect.KProperty
@Suppress(<!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>, "INVISIBLE_MEMBER")
public operator fun <V, V1 : V> Map<in String, @kotlin.internal.Exact V>.getValue(thisRef: Any?, property: KProperty<*>): V1 = null!!
val m2: Map<String, *> = mapOf("baz" to "bat")
val bar: String get() = m2.getValue(null, ::bar)
fun foo() {
val m1: Map<String, Any> = mapOf("foo" to "bar")
val foo: String by m1
val baz: String by m2
println(foo) // bar
println(baz) // kotlin.KotlinNothingValueException
println(bar)
}
@@ -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 <V, V1 : R|V|> R|kotlin/collections/Map<in kotlin/String, @Exact V>|.getValue(thisRef: R|kotlin/Any?|, property: R|kotlin/reflect/KProperty<*>|): R|V1| {
^getValue Null(null)!!
}
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
// FIR_DUMP
// WITH_REFLECT
@@ -0,0 +1,26 @@
class Foo {
@Suppress("INVISIBLE_MEMBER", <!ERROR_SUPPRESSION!>"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", <!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>)
@kotlin.internal.LowPriorityInOverloadResolution
constructor(val x: Foo)
fun Baz(x: Foo): Baz {
throw NotImplementedError()
}
fun testBaz(e: Foo) = Baz(e)
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
class Foo {
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@kotlin.internal.LowPriorityInOverloadResolution
@@ -1,6 +1,6 @@
//!DIAGNOSTICS: -UNUSED_VARIABLE
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@Suppress("INVISIBLE_MEMBER", <!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>)
fun <T, U: T> List<@kotlin.internal.Exact T>.firstTyped(): U = throw Exception()
fun test1(l: List<Number>) {
@@ -1,6 +1,6 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -DEBUG_INFO_CONSTANT -UNUSED_EXPRESSION
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@Suppress("INVISIBLE_MEMBER", <!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>)
fun <@kotlin.internal.OnlyInputTypes K, V, V1 : V?>
Map<out K, @kotlin.internal.Exact V>.getOrDefault_Exact(key: K, defaultValue: V1): V1 = TODO()
@@ -0,0 +1,30 @@
//!DIAGNOSTICS: -UNUSED_PARAMETER
@Suppress("INVISIBLE_MEMBER", <!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>)
fun <R> Iterable<*>.filterIsInstance1(): List<@kotlin.internal.NoInfer R> = throw Exception()
@Suppress("INVISIBLE_MEMBER", <!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>)
fun <R> List<*>.filterIsInstance2(): @kotlin.internal.NoInfer List<R> = throw Exception()
fun test(list: List<Int>) {
list.filterIsInstance1<Int>().map { it * 2 }
list.filterIsInstance2<Int>().filter { it > 10 }
}
@Suppress("INVISIBLE_MEMBER", <!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>)
fun <R> foo(t: R): List<@kotlin.internal.NoInfer R> = throw Exception("$t")
fun test() {
foo(1).map { it * 2 }
}
@Suppress("INVISIBLE_MEMBER", <!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>)
fun <R> List<R>.foo(): @kotlin.internal.NoInfer R = throw Exception()
@Suppress("INVISIBLE_MEMBER", <!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>)
fun <R> bar(r: R, f: Function1<@kotlin.internal.NoInfer R, Unit>): Nothing = throw Exception()
fun test1() {
listOf("").foo().length
bar(1) { x -> x + 1 }
}
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
//!DIAGNOSTICS: -UNUSED_PARAMETER
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@@ -0,0 +1,21 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
open class Base()
class CX : Base()
class CY : Base()
@Suppress("INVISIBLE_MEMBER", <!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>)
fun <@kotlin.internal.OnlyInputTypes T> foo(a: T, b: T) {}
@Suppress("INVISIBLE_MEMBER", <!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>)
fun <@kotlin.internal.OnlyInputTypes T : Any> fooA(a: T, b: T) {}
@Suppress("INVISIBLE_MEMBER", <!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>)
fun <@kotlin.internal.OnlyInputTypes T : Base> fooB(a: T, b: T) {}
fun usage(x: CX, y: CY) {
<!TYPE_INFERENCE_ONLY_INPUT_TYPES_ERROR!>foo<!>(x, y) // expected err, got err
<!TYPE_INFERENCE_ONLY_INPUT_TYPES_ERROR!>fooA<!>(x, y) // expected err, got ok
<!TYPE_INFERENCE_ONLY_INPUT_TYPES_ERROR!>fooB<!>(x, y) // expected err, got ok
}
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
open class Base()
@@ -0,0 +1,11 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
@file:Suppress("INVISIBLE_MEMBER", <!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>)
annotation class Anno
fun test(a: List<Class<Anno>>) {
strictSelect(a, emptyList<Anno>().map { it.annotationClass.java })
}
fun <@kotlin.internal.OnlyInputTypes S> strictSelect(arg1: S, arg2: S): S = TODO()
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@@ -0,0 +1,36 @@
// DIAGNOSTICS: -EXTENSION_SHADOWED_BY_MEMBER
// FILE: a.kt
package a
val bar get() = ""
@Suppress("INVISIBLE_MEMBER", <!ERROR_SUPPRESSION!>"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", <!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>)
class Foo {
@kotlin.internal.LowPriorityInOverloadResolution
val bar = 1
@kotlin.internal.LowPriorityInOverloadResolution
val baz = 1
}
fun Foo.test() {
bar.length
baz.qux
}
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
// DIAGNOSTICS: -EXTENSION_SHADOWED_BY_MEMBER
// FILE: a.kt
@@ -1,11 +1,11 @@
//!DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@Suppress("INVISIBLE_MEMBER", <!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>)
@kotlin.jvm.JvmName("containsAny")
@kotlin.internal.LowPriorityInOverloadResolution
public fun <T> Iterable<T>.contains1(element: T): Int = null!!
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@Suppress("INVISIBLE_MEMBER", <!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>)
public fun <T> Iterable<T>.contains1(element: @kotlin.internal.NoInfer T): Boolean = null!!
@@ -1,12 +1,12 @@
//!DIAGNOSTICS: -UNUSED_PARAMETER
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@Suppress("INVISIBLE_MEMBER", <!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>)
fun <T> test1(t1: T, t2: @kotlin.internal.NoInfer T): T = t1
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@Suppress("INVISIBLE_MEMBER", <!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>)
fun <T> @kotlin.internal.NoInfer T.test2(t1: T): T = t1
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@Suppress("INVISIBLE_MEMBER", <!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>)
fun <T> test3(t1: @kotlin.internal.NoInfer T): T = t1
fun usage() {
@@ -15,7 +15,7 @@ fun usage() {
<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>test3<!>("")
}
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@Suppress("INVISIBLE_MEMBER", <!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>)
fun <T> List<T>.contains1(e: @kotlin.internal.NoInfer T): Boolean = true
fun test(i: Int?, a: Any, l: List<Int>) {
@@ -24,7 +24,7 @@ fun test(i: Int?, a: Any, l: List<Int>) {
l.contains1(i)
}
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@Suppress("INVISIBLE_MEMBER", <!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>)
fun <T> assertEquals1(e1: T, e2: @kotlin.internal.NoInfer T): Boolean = true
fun test(s: String) {
@@ -0,0 +1,17 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
// FILE: TestBase.java
public class TestBase<T> { }
// FILE: Test.java
public class Test<K> extends TestBase<K> { }
// FILE: main.kt
@Suppress("INVISIBLE_MEMBER", <!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>)
fun <@kotlin.internal.OnlyInputTypes K> TestBase<out K>.foo(key: K) = null
fun foo(result: Test<*>) {
result.foo("sd") // Type inference failed (NI), OK in OI
}
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
// FILE: TestBase.java
@@ -0,0 +1,24 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
@file:Suppress("INVISIBLE_MEMBER", <!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>)
interface IFace<K, out V>
fun <@kotlin.internal.OnlyInputTypes K, V> IFace<out K, V>.get(key: K): V? = TODO()
fun <@kotlin.internal.OnlyInputTypes I> id(arg: I): I = arg
interface InvBase<B>
class DerivedInv : InvBase<DerivedInv>
class InvRecursive<E : InvBase<E>>
fun test1(argument: InvRecursive<*>, receiver: IFace<InvRecursive<DerivedInv>, Any>) {
receiver.get(argument)
}
fun test2(arg: InvRecursive<out DerivedInv>) {
id(arg)
}
fun test3(arg: InvRecursive<in DerivedInv>) {
id(arg)
}
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@@ -0,0 +1,46 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
@Suppress("INVISIBLE_MEMBER", <!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>)
public fun <@kotlin.internal.OnlyInputTypes T> Iterable<T>.contains1(element: T): Boolean = null!!
class In<in T>
class Out<out T>
class Inv<T>
fun test_1(list: List<In<Number>>, x: In<Number>, y: In<Int>, z: In<Any>) {
list.contains1(x)
list.contains1(y)
list.contains1(z)
}
fun test_2(list: List<In<Int>>, x: In<Int>, y: In<Number>, z: In<Any>) {
list.contains1(x)
list.contains1(y)
list.contains1(z)
}
fun test_3(list: List<Out<Number>>, x: Out<Number>, y: Out<Int>, z: Out<Any>) {
list.contains1(x)
list.contains1(y)
list.contains1(z)
}
fun test_4(list: List<Out<Int>>, x: Out<Int>, y: Out<Number>, z: Out<Any>) {
list.contains1(x)
list.contains1(y)
list.contains1(z)
}
fun test_5(list: List<Inv<Number>>, x: Inv<Number>, y: Inv<Int>, z: Inv<Any>) {
list.contains1(x)
list.<!TYPE_INFERENCE_ONLY_INPUT_TYPES_ERROR!>contains1<!>(y)
list.<!TYPE_INFERENCE_ONLY_INPUT_TYPES_ERROR!>contains1<!>(z)
}
fun test_6(list: List<Inv<Int>>, x: Inv<Int>, y: Inv<Number>, z: Inv<Any>) {
list.contains1(x)
list.<!TYPE_INFERENCE_ONLY_INPUT_TYPES_ERROR!>contains1<!>(y)
list.<!TYPE_INFERENCE_ONLY_INPUT_TYPES_ERROR!>contains1<!>(z)
}
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@@ -3,7 +3,7 @@
// FULL_JDK
import java.lang.reflect.Field
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@Suppress("INVISIBLE_MEMBER", <!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>)
fun <@kotlin.internal.OnlyInputTypes T> assertEquals(expected: T, actual: T): T = actual
fun test(field: Field) {
@@ -1,19 +1,19 @@
//!DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@Suppress("INVISIBLE_MEMBER", <!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>)
@kotlin.jvm.JvmName("containsAny")
@kotlin.internal.LowPriorityInOverloadResolution
public fun <T> Iterable<T>.contains1(element: T): Int = null!!
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@Suppress("INVISIBLE_MEMBER", <!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>)
public fun <@kotlin.internal.OnlyInputTypes T> Iterable<T>.contains1(element: T): Boolean = null!!
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@Suppress("INVISIBLE_MEMBER", <!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>)
@JvmName("getAny")
@kotlin.internal.LowPriorityInOverloadResolution
public fun <K, V> Map<K, V>.get1(key: Any?): Int = null!!
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@Suppress("INVISIBLE_MEMBER", <!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>)
public fun <@kotlin.internal.OnlyInputTypes K, V> Map<out K, V>.get1(key: K): V? = null!!
fun test(map: Map<Int, String>) {
@@ -2,13 +2,13 @@
class Inv<T>
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@Suppress("INVISIBLE_MEMBER", <!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>)
fun <@kotlin.internal.OnlyInputTypes K> Inv<out K>.onlyOut(e: K) {}
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@Suppress("INVISIBLE_MEMBER", <!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>)
fun <@kotlin.internal.OnlyInputTypes K : Number> Inv<out K>.onlyOutUB(e: K) {}
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@Suppress("INVISIBLE_MEMBER", <!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>)
fun <@kotlin.internal.OnlyInputTypes K> Inv<in K>.onlyIn(e: K) {}
fun test(
@@ -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", <!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>)
fun <@kotlin.internal.OnlyInputTypes T> assertEquals1(t1: T, t2: T) {}
fun test() {
assertEquals1(null, Foo.foo())
assertEquals1("", Foo.foo())
}
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
//!DIAGNOSTICS: -UNUSED_PARAMETER
//FILE:Foo.java
@@ -0,0 +1,112 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER
// Issue: KT-26698
@Suppress("INVISIBLE_MEMBER", <!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>)
public fun <@kotlin.internal.OnlyInputTypes T> Iterable<T>.contains1(element: T): Boolean = null!!
@Suppress("INVISIBLE_MEMBER", <!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>)
public fun <@kotlin.internal.OnlyInputTypes T> Iterable<T>.foo(element: T): T = null!!
class Inv<T>
class Inv2<T, R>
class In<in T>
class Out<out T>
// -------------------------------------------------------
fun test_0(x: Inv2<in Number, out Number>, list: List<Inv2<Any, Int>>) {
list.<!TYPE_INFERENCE_ONLY_INPUT_TYPES_ERROR!>foo<!>(x)
}
// ------------------------- Inv -------------------------
fun test_1(x: Inv<Number>, list: List<Inv<Number>>) {
list.contains1(x)
}
fun test_2(x: Inv<Number>, list: List<Inv<Int>>) {
list.<!TYPE_INFERENCE_ONLY_INPUT_TYPES_ERROR!>contains1<!>(x)
}
fun test_3(x: Inv<Number>, list: List<Inv<Any>>) {
list.<!TYPE_INFERENCE_ONLY_INPUT_TYPES_ERROR!>contains1<!>(x)
}
fun test_4(x: Inv<in Number>, list: List<Inv<Any>>) {
list.<!TYPE_INFERENCE_ONLY_INPUT_TYPES_ERROR!>contains1<!>(x)
}
fun test_5(x: Inv<in Number>, list: List<Inv<Number>>) {
list.<!TYPE_INFERENCE_ONLY_INPUT_TYPES_ERROR!>contains1<!>(x)
}
fun test_6(x: Inv<in Number>, list: List<Inv<Int>>) {
list.<!TYPE_INFERENCE_ONLY_INPUT_TYPES_ERROR!>contains1<!>(x)
}
fun test_7(x: Inv<out Number>, list: List<Inv<Any>>) {
list.<!TYPE_INFERENCE_ONLY_INPUT_TYPES_ERROR!>contains1<!>(x)
}
fun test_8(x: Inv<out Number>, list: List<Inv<Number>>) {
list.contains1(x)
}
fun test_9(x: Inv<out Number>, list: List<Inv<Int>>) {
list.contains1(x)
}
// ------------------------- In -------------------------
fun test_11(x: In<Number>, list: List<In<Number>>) {
list.contains1(x)
}
fun test_12(x: In<Number>, list: List<In<Int>>) {
list.contains1(x)
}
fun test_13(x: In<Number>, list: List<In<Any>>) {
list.contains1(x)
}
// ------------------------- Out -------------------------
fun test_21(x: Out<Number>, list: List<Out<Number>>) {
list.contains1(x)
}
fun test_22(x: Out<Number>, list: List<Out<Int>>) {
list.contains1(x)
}
fun test_23(x: Out<Number>, list: List<Out<Any>>) {
list.contains1(x)
}
// --------------------------------------------------------
fun test_31(x: Inv<Number>, list: List<Inv<in Number>>) {
list.contains1(x)
}
fun test_32(x: Inv<Number>, list: List<Inv<in Int>>) {
list.contains1(x)
}
fun test_33(x: Inv<Number>, list: List<Inv<in Any>>) {
list.<!TYPE_INFERENCE_ONLY_INPUT_TYPES_ERROR!>contains1<!>(x)
}
fun test_34(x: Inv<Number>, list: List<Inv<out Number>>) {
list.contains1(x)
}
fun test_35(x: Inv<Number>, list: List<Inv<out Int>>) {
list.<!TYPE_INFERENCE_ONLY_INPUT_TYPES_ERROR!>contains1<!>(x)
}
fun test_36(x: Inv<Number>, list: List<Inv<out Any>>) {
list.contains1(x)
}
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER
// Issue: KT-26698
@@ -0,0 +1,53 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
@file:Suppress("INVISIBLE_MEMBER", <!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>)
import kotlin.internal.OnlyInputTypes
interface Bound
class First : Bound
class Second : Bound
class Inv<I >(val v: I)
class InvB<I : Bound>(val v: I)
class In<in C>(v: C)
class InB<in C : Bound>(v: C)
class Out<out O>(val v: O)
class OutB<out O : Bound>(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<Bound> = strictSelect(Out(first), Out(second))
val outb: OutB<Bound> = strictSelect(OutB(first), OutB(second))
strictSelect<Out<Bound>>(Out(first), Out(second))
strictSelect<OutB<Bound>>(OutB(first), OutB(second))
}
fun testFail(first: First, bound: Bound, second: Second) {
<!TYPE_INFERENCE_ONLY_INPUT_TYPES_ERROR!>strictSelect<!>(InvB(first), InvB(bound))
<!TYPE_INFERENCE_ONLY_INPUT_TYPES_ERROR!>strictSelect<!>(Inv(first), Inv(bound))
<!TYPE_INFERENCE_ONLY_INPUT_TYPES_ERROR!>strictSelect<!>(Out(first), Out(second))
<!TYPE_INFERENCE_ONLY_INPUT_TYPES_ERROR!>strictSelect<!>(In(first), In(second))
<!TYPE_INFERENCE_ONLY_INPUT_TYPES_ERROR!>strictSelect<!>(InB(first), InB(second))
<!TYPE_INFERENCE_ONLY_INPUT_TYPES_ERROR!>strictSelect<!>(Out(Inv(first)), Out(Inv(second)))
<!TYPE_INFERENCE_ONLY_INPUT_TYPES_ERROR!>strictSelect<!>(In(Inv(first)), In(Inv(second)))
}
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@@ -1,6 +1,6 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@file:Suppress("INVISIBLE_MEMBER", <!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>)
class Inv<T>
class Out<out T>
@@ -1,7 +1,7 @@
// !LANGUAGE: -StrictOnlyInputTypesChecks
// !DIAGNOSTICS: -UNUSED_PARAMETER
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@Suppress("INVISIBLE_MEMBER", <!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>)
fun <@kotlin.internal.OnlyInputTypes S> select(a1: S, a2: S): S = TODO()
interface Common
@@ -0,0 +1,25 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
private object TopLevelTypeVariable {
@Suppress("INVISIBLE_MEMBER", <!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>, "HIDDEN")
fun <T> foo(): @kotlin.internal.NoInfer T = TODO()
fun <K> bar(k: K) {}
fun test() {
bar(foo<Int>())
}
}
private object NestedTypeVariable {
class Inv<T>
@Suppress("INVISIBLE_MEMBER", <!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>, "HIDDEN")
fun <T> foo(): Inv<@kotlin.internal.NoInfer T> = TODO()
fun <K> bar(p: Inv<K>) {}
fun test() {
bar(foo<String>())
}
}
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
private object TopLevelTypeVariable {
@@ -0,0 +1,24 @@
//!DIAGNOSTICS: -UNUSED_PARAMETER
@Suppress("INVISIBLE_MEMBER", <!ERROR_SUPPRESSION!>"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)
<!TYPE_INFERENCE_ONLY_INPUT_TYPES_ERROR!>assertEquals1<!>(b, c)
assertEquals1(3, 3)
assertEquals1(1 or 2, 2 or 1)
}
@Suppress("INVISIBLE_MEMBER", <!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>)
public fun <@kotlin.internal.OnlyInputTypes T> expect1(expected: T, block: () -> T) {}
fun test() {
expect1(2) { byteArrayOf(1, 2, 3).indexOf(3) }
}
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
//!DIAGNOSTICS: -UNUSED_PARAMETER
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@@ -0,0 +1,31 @@
// WITH_STDLIB
// FIR_DUMP
// FILE: First.kt
package sample.pack
@Suppress(<!ERROR_SUPPRESSION!>"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()
}
}
}
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
// WITH_STDLIB
// FIR_DUMP
@@ -0,0 +1,12 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
@Suppress("INVISIBLE_MEMBER", <!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>)
inline fun <reified @kotlin.internal.PureReifiable T> foo(x: T) {}
fun test() {
foo<List<String>>(listOf(""))
foo(listOf(""))
foo<Array<String>>(arrayOf(""))
foo(arrayOf(""))
}
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@@ -6,11 +6,11 @@ package b
import a.A
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@Suppress("INVISIBLE_MEMBER", <!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>)
@kotlin.internal.HidesMembers
fun A.forEach(i: Int) = i
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@Suppress("INVISIBLE_MEMBER", <!ERROR_SUPPRESSION!>"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", <!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>)
@kotlin.internal.HidesMembers
fun A.forEach() = ""
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@Suppress("INVISIBLE_MEMBER", <!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>)
@kotlin.internal.HidesMembers
fun A.forEach(s: String) {}
@@ -6,12 +6,12 @@ class A {
fun forEach(i: Int) = this
}
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@Suppress("INVISIBLE_MEMBER", <!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>)
@kotlin.internal.HidesMembers
fun A.forEach(i: Int) = i
class B {
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@Suppress("INVISIBLE_MEMBER", <!ERROR_SUPPRESSION!>"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", <!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>)
@kotlin.internal.HidesMembers
fun A.forEach() = ""
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@Suppress("INVISIBLE_MEMBER", <!ERROR_SUPPRESSION!>"INVISIBLE_REFERENCE"<!>)
@kotlin.internal.HidesMembers
fun A.forEach(i: Int) = ""
@@ -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
@@ -0,0 +1,37 @@
// WITH_STDLIB
package test
import kotlinx.parcelize.*
import android.os.Parcelable
@Parcelize
class A(val firstName: String) : Parcelable {
val <!PROPERTY_WONT_BE_SERIALIZED!>secondName<!>: String = ""
val <!PROPERTY_WONT_BE_SERIALIZED!>delegated<!> by lazy { "" }
lateinit var <!PROPERTY_WONT_BE_SERIALIZED!>lateinit<!>: String
val customGetter: String
get() = ""
var customSetter: String
get() = ""
set(v) {}
}
@Parcelize
@Suppress(<!ERROR_SUPPRESSION!>"WRONG_ANNOTATION_TARGET_WITH_USE_SITE_TARGET"<!>)
class B(<!INAPPLICABLE_IGNORED_ON_PARCEL_CONSTRUCTOR_PROPERTY!>@IgnoredOnParcel<!> val firstName: String) : Parcelable {
@IgnoredOnParcel
var a: String = ""
@field:IgnoredOnParcel
var <!PROPERTY_WONT_BE_SERIALIZED!>b<!>: String = ""
@get:IgnoredOnParcel
var c: String = ""
@set:IgnoredOnParcel
var <!PROPERTY_WONT_BE_SERIALIZED!>d<!>: String = ""
}
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
// WITH_STDLIB
package test