[FIR] Make type parameters inaccessible for non-inner nested types

#KT-57209
This commit is contained in:
Kirill Rakhman
2023-03-14 17:20:35 +01:00
committed by Space Team
parent c39ab956a0
commit 1f0d56e157
24 changed files with 227 additions and 181 deletions
@@ -1,104 +0,0 @@
// !LANGUAGE: +FunctionalInterfaceConversion
fun interface Good {
fun invoke()
}
<!FUN_INTERFACE_WRONG_COUNT_OF_ABSTRACT_MEMBERS!>fun<!> interface Foo1
<!FUN_INTERFACE_WRONG_COUNT_OF_ABSTRACT_MEMBERS!>fun<!> interface Foo2 {
}
<!FUN_INTERFACE_WRONG_COUNT_OF_ABSTRACT_MEMBERS!>fun<!> interface Foo3 {
fun foo()
fun bar()
}
interface BaseWithSAM {
fun base()
}
<!FUN_INTERFACE_WRONG_COUNT_OF_ABSTRACT_MEMBERS!>fun<!> interface Foo4 : BaseWithSAM {
fun oneMore()
}
fun interface Foo4WithDefault : BaseWithSAM {
fun oneMore() {}
}
interface BaseWithDefault {
fun def() {}
}
fun interface Foo4WithBaseDefault : BaseWithDefault {
fun oneMore()
}
fun interface GoodWithBase : BaseWithSAM
<!FUN_INTERFACE_WRONG_COUNT_OF_ABSTRACT_MEMBERS!>fun<!> interface Foo5 {
<!FUN_INTERFACE_CANNOT_HAVE_ABSTRACT_PROPERTIES!>val<!> prop: Int
}
fun interface Foo6 {
fun foo()
<!FUN_INTERFACE_CANNOT_HAVE_ABSTRACT_PROPERTIES!>val<!> prop: Int
}
fun interface Foo7 : BaseWithSAM {
<!FUN_INTERFACE_CANNOT_HAVE_ABSTRACT_PROPERTIES!>val<!> prop: Int
}
fun interface GoodWithPropAndBase : BaseWithSAM {
val prop: Int get() = 42
}
fun interface Foo8 {
fun <!FUN_INTERFACE_ABSTRACT_METHOD_WITH_TYPE_PARAMETERS!><T><!> invoke(x: T)
}
fun interface GoodGeneric<T> {
fun invoke(x: T)
}
interface BaseWithGeneric {
fun <T> invoke(x: T)
}
<!FUN_INTERFACE_ABSTRACT_METHOD_WITH_TYPE_PARAMETERS!>fun<!> interface Foo9 : BaseWithGeneric
fun interface GoodExtensionGeneric : GoodGeneric<String>
fun interface GoodSuspend {
suspend fun invoke()
}
class WithNestedFun<K> {
<!FUN_INTERFACE_WRONG_COUNT_OF_ABSTRACT_MEMBERS!>fun<!> interface NestedSimple
fun interface GoodFun {
fun invoke()
}
fun interface NestedFun {
fun inovke(element: K)
}
}
fun <T> local() {
<!LOCAL_INTERFACE_NOT_ALLOWED!>fun interface LocalFun<!> {
fun invoke(element: T)
}
}
fun interface WithDefaultValue {
fun invoke(<!FUN_INTERFACE_ABSTRACT_METHOD_WITH_DEFAULT_VALUE!>s: String = ""<!>)
}
interface BaseWithDefaultValue {
fun invoke(s: String = "")
}
<!FUN_INTERFACE_ABSTRACT_METHOD_WITH_DEFAULT_VALUE!>fun<!> interface DeriveDefault : BaseWithDefaultValue
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !LANGUAGE: +FunctionalInterfaceConversion
fun interface Good {
@@ -0,0 +1,39 @@
// SKIP_TXT
class Foo<T> {
companion object {
fun foo(arg: <!UNRESOLVED_REFERENCE!>T<!>) {}
}
object O {
fun foo(arg: <!UNRESOLVED_REFERENCE!>T<!>) {}
}
class Nested {
fun foo(arg: <!UNRESOLVED_REFERENCE!>T<!>) {}
}
inner class Inner<R> {
fun foo(arg1: T, arg2: R) {}
<!NESTED_CLASS_NOT_ALLOWED!>class InnerNested<!> {
fun foo(arg1: <!UNRESOLVED_REFERENCE!>T<!>, arg2: <!UNRESOLVED_REFERENCE!>R<!>) {}
}
}
enum class E {
;
fun foo(arg: <!UNRESOLVED_REFERENCE!>T<!>) {}
}
val obj = object {
fun foo(arg: T) {}
}
fun <R> bar() {
class Local {
fun baz(arg1: T, arg2: R) {}
}
}
}
@@ -0,0 +1,39 @@
// SKIP_TXT
class Foo<T> {
companion object {
fun foo(arg: <!UNRESOLVED_REFERENCE!>T<!>) {}
}
object O {
fun foo(arg: <!UNRESOLVED_REFERENCE!>T<!>) {}
}
class Nested {
fun foo(arg: <!UNRESOLVED_REFERENCE!>T<!>) {}
}
inner class Inner<R> {
fun foo(arg1: T, arg2: R) {}
<!NESTED_CLASS_NOT_ALLOWED!>class InnerNested<!> {
fun foo(arg1: <!INACCESSIBLE_OUTER_CLASS_EXPRESSION!>T<!>, arg2: <!UNRESOLVED_REFERENCE!>R<!>) {}
}
}
enum class E {
;
fun foo(arg: <!UNRESOLVED_REFERENCE!>T<!>) {}
}
val obj = object {
fun foo(arg: T) {}
}
fun <R> bar() {
class Local {
fun baz(arg1: T, arg2: R) {}
}
}
}
@@ -1,6 +1,6 @@
class Outer<T> {
class Nested {
fun foo(t: T) = t
fun foo(t: <!UNRESOLVED_REFERENCE!>T<!>) = t
}
class Nested2<T> {
@@ -10,4 +10,4 @@ class Outer<T> {
inner class Inner {
fun foo(t: T) = t
}
}
}