[FIR] Add EXPOSED_SUPER_(CLASS/INTERFACE) checker

This commit is contained in:
rapturemain
2020-04-23 18:53:59 +03:00
committed by Mikhail Glukhikh
parent ef09850df8
commit 49593d308c
27 changed files with 241 additions and 40 deletions
@@ -6,7 +6,7 @@ interface A extends C {
// FILE: B.kt
interface B : A {
interface B : <!EXPOSED_SUPER_INTERFACE!>A<!> {
fun bar()
}
@@ -6,6 +6,6 @@ class J extends K {
// FILE: K.kt
class K : J() {
class K : <!EXPOSED_SUPER_CLASS!>J<!>() {
fun bar() {}
}
@@ -12,6 +12,6 @@ class J extends I {
// FILE: K.kt
open class K : J() {
open class K : <!EXPOSED_SUPER_CLASS!>J<!>() {
fun baz() {}
}
@@ -1,6 +1,6 @@
// FILE: ExceptionTracker.kt
interface ExceptionTracker : LockBasedStorageManager.ExceptionHandlingStrategy {
interface ExceptionTracker : <!EXPOSED_SUPER_INTERFACE!>LockBasedStorageManager.ExceptionHandlingStrategy<!> {
}
// FILE: StorageManager.kt
@@ -7,7 +7,7 @@ internal open class Your: My() {
}
// error, public from internal
open class His: Your() {
open class His: <!EXPOSED_SUPER_CLASS!>Your<!>() {
protected open class Nested
// error, public from internal
val <!EXPOSED_PROPERTY_TYPE!>x<!> = My()
@@ -21,5 +21,5 @@ open class His: Your() {
internal class Their: His() {
// error, effectively internal from protected
class InnerDerived: His.Nested()
class InnerDerived: <!EXPOSED_SUPER_CLASS!>His.Nested<!>()
}
@@ -0,0 +1,10 @@
public open class A {
protected open class B
}
public open class C : A() {
protected open class D {
// internal & protected(in C) <= protected(in A): Ok
internal open class E : <!EXPOSED_SUPER_CLASS!>A.B<!>()
}
}
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
public open class A {
protected open class B
}
@@ -6,6 +5,6 @@ public open class A {
public open class C : A() {
protected open class D {
// internal & protected(in C) <= protected(in A): Ok
internal open class E : A.B()
internal open class E : A.B()
}
}
+1 -1
View File
@@ -1,5 +1,5 @@
// From KT-10753
object My : Inter() {
object My : <!EXPOSED_SUPER_CLASS!>Inter<!>() {
fun <!EXPOSED_FUNCTION_RETURN_TYPE!>foo<!>(<!EXPOSED_PARAMETER_TYPE!>arg: Inter<!>): Inter = arg
val <!EXPOSED_PROPERTY_TYPE!>x<!>: Inter? = null
}
@@ -5,13 +5,13 @@ open class A {
}
public open class C {
// protected relative to C, must be an error
protected open class D : B()
protected open class D : <!EXPOSED_SUPER_CLASS!>B<!>()
}
}
class E : A.C() {
// F has invisible grandparent class B (E does not inherit from A)
class F : A.C.D() {
class F : <!EXPOSED_SUPER_CLASS!>A.C.D<!>() {
init {
// Invoke function from invisible grandparent
foo()
@@ -1,12 +0,0 @@
// See KT-9540
// all protected should have lower bound that is more permissive than private
// protected and internal should have lower bound that is more permissive than private
open class A {
private interface B
protected open class C {
protected interface D : B
internal interface E : B, D
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// See KT-9540
// all protected should have lower bound that is more permissive than private
@@ -10,7 +10,7 @@ public abstract class Outer {
class OuterDerived: Outer() {
// valid, My has better visibility
protected class His: Outer.My()
protected class His: <!EXPOSED_SUPER_CLASS!>Outer.My<!>()
// valid, My and Your have better visibility
override fun <!EXPOSED_FUNCTION_RETURN_TYPE!>foo<!>(<!EXPOSED_PARAMETER_TYPE!>my: Outer.My<!>) = Outer.Your()
}
@@ -7,7 +7,7 @@ abstract class Outer {
class OuterDerived: Outer() {
// valid, My has better visibility
protected class His: Outer.My()
protected class His: <!EXPOSED_SUPER_CLASS!>Outer.My<!>()
// valid, My and Your have better visibility
override fun <!EXPOSED_FUNCTION_RETURN_TYPE!>foo<!>(<!EXPOSED_PARAMETER_TYPE!>my: Outer.My<!>) = Outer.Your()
}
+2 -2
View File
@@ -2,11 +2,11 @@ private interface My
private open class Base
public interface Your: My {
public interface Your: <!EXPOSED_SUPER_INTERFACE!>My<!> {
fun <T: Base> foo(): T
}
public class Derived<T: My>(<!EXPOSED_PARAMETER_TYPE!>val <!EXPOSED_PROPERTY_TYPE!>x<!>: My<!>): Base() {
public class Derived<T: My>(<!EXPOSED_PARAMETER_TYPE!>val <!EXPOSED_PROPERTY_TYPE!>x<!>: My<!>): <!EXPOSED_SUPER_CLASS!>Base<!>() {
constructor(<!EXPOSED_PARAMETER_TYPE!>xx: My?<!>, <!EXPOSED_PARAMETER_TYPE!>x: My<!>): this(xx ?: x)
@@ -6,7 +6,7 @@ abstract class Your {
}
// invalid, List<My> is effectively internal
interface His: List<My>
interface His: <!EXPOSED_SUPER_INTERFACE!>List<My><!>
// invalid, My is internal
interface Generic<E: My>
@@ -14,4 +14,4 @@ package a
import pack1.*
import pack2.*
class X : <!INAPPLICABLE_CANDIDATE!>SomeClass<!>()
class X : <!EXPOSED_SUPER_CLASS, INAPPLICABLE_CANDIDATE!>SomeClass<!>()
@@ -17,5 +17,5 @@ package a
import pack1.SomeClass.*
import pack2.*
class X : <!INAPPLICABLE_CANDIDATE!>N<!>()
class X : <!EXPOSED_SUPER_CLASS, INAPPLICABLE_CANDIDATE!>N<!>()
class Y : PublicNested()
@@ -43,7 +43,7 @@ fun test() {
xx = 40
}
class B : <!INAPPLICABLE_CANDIDATE!>A<!>() {}
class B : <!EXPOSED_SUPER_CLASS, INAPPLICABLE_CANDIDATE!>A<!>() {}
class Q {
class W {
@@ -33,7 +33,7 @@ fun test() {
val po = <!INAPPLICABLE_CANDIDATE!>PO<!>
}
class B : <!INAPPLICABLE_CANDIDATE!>A<!>() {}
class B : <!EXPOSED_SUPER_CLASS, INAPPLICABLE_CANDIDATE!>A<!>() {}
class Q {
class W {
@@ -36,7 +36,7 @@ fun test() {
val po = <!INAPPLICABLE_CANDIDATE!>PO<!>
}
class B : <!INAPPLICABLE_CANDIDATE!>A<!>() {}
class B : <!EXPOSED_SUPER_CLASS, INAPPLICABLE_CANDIDATE!>A<!>() {}
class Q {
class W {