Introduce error for PROTECTED_CONSTRUCTOR_CALL_FROM_PUBLIC_INLINE

^KT-42972 Fixed
This commit is contained in:
Victor Petukhov
2021-09-22 12:15:06 +03:00
parent 01e853fb9b
commit 561ef5947a
11 changed files with 89 additions and 5 deletions
+1 -1
View File
@@ -5,5 +5,5 @@ open class Foo protected constructor()
inline fun foo(f: () -> Unit) = object: Foo() {}
class A : Foo() {
inline fun foo(f: () -> Unit) = <!PROTECTED_CONSTRUCTOR_CALL_FROM_PUBLIC_INLINE, PROTECTED_CONSTRUCTOR_NOT_IN_SUPER_CALL!>Foo<!>()
inline fun foo(f: () -> Unit) = <!PROTECTED_CONSTRUCTOR_CALL_FROM_PUBLIC_INLINE_ERROR, PROTECTED_CONSTRUCTOR_NOT_IN_SUPER_CALL!>Foo<!>()
}
+2 -2
View File
@@ -6,13 +6,13 @@ class SomeContainer {
protected fun makeLimit(): Limit = TODO()
public inline fun foo(f: () -> Unit) {
<!PROTECTED_CONSTRUCTOR_CALL_FROM_PUBLIC_INLINE!>Limit<!>()
<!PROTECTED_CONSTRUCTOR_CALL_FROM_PUBLIC_INLINE_ERROR!>Limit<!>()
<!PROTECTED_CALL_FROM_PUBLIC_INLINE_ERROR!>makeLimit<!>()
}
}
open class A protected constructor() {
inline fun foo(f: () -> Unit) {
<!PROTECTED_CONSTRUCTOR_CALL_FROM_PUBLIC_INLINE!>A<!>()
<!PROTECTED_CONSTRUCTOR_CALL_FROM_PUBLIC_INLINE_ERROR!>A<!>()
}
}
@@ -0,0 +1,19 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
// !LANGUAGE: -ProhibitProtectedConstructorCallFromPublicInline
class SomeContainer {
protected class Limit
protected fun makeLimit(): Limit = TODO()
public inline fun foo(f: () -> Unit) {
<!PROTECTED_CONSTRUCTOR_CALL_FROM_PUBLIC_INLINE!>Limit<!>()
<!PROTECTED_CALL_FROM_PUBLIC_INLINE_ERROR!>makeLimit<!>()
}
}
open class A protected constructor() {
inline fun foo(f: () -> Unit) {
<!PROTECTED_CONSTRUCTOR_CALL_FROM_PUBLIC_INLINE!>A<!>()
}
}
@@ -0,0 +1,19 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
// !LANGUAGE: -ProhibitProtectedConstructorCallFromPublicInline
class SomeContainer {
protected class Limit
protected fun makeLimit(): Limit = TODO()
public inline fun foo(f: () -> Unit) {
<!PROTECTED_CONSTRUCTOR_CALL_FROM_PUBLIC_INLINE_WARNING!>Limit<!>()
<!PROTECTED_CALL_FROM_PUBLIC_INLINE_ERROR!>makeLimit<!>()
}
}
open class A protected constructor() {
inline fun foo(f: () -> Unit) {
<!PROTECTED_CONSTRUCTOR_CALL_FROM_PUBLIC_INLINE_WARNING!>A<!>()
}
}
@@ -0,0 +1,25 @@
package
public open class A {
protected constructor A()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final inline fun foo(/*0*/ f: () -> kotlin.Unit): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final class SomeContainer {
public constructor SomeContainer()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final inline fun foo(/*0*/ f: () -> kotlin.Unit): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
protected final fun makeLimit(): SomeContainer.Limit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
protected final class Limit {
public constructor Limit()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
}