Fix for KT-15410: "Protected function call from public-API inline function" for protected constructor call
#KT-15410 Fixed
This commit is contained in:
+2
-1
@@ -258,7 +258,8 @@ class InlineChecker implements CallChecker {
|
|||||||
checkPrivateClassMemberAccess(calledDescriptor, expression, context);
|
checkPrivateClassMemberAccess(calledDescriptor, expression, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isInlineFunPublicOrPublishedApi &&
|
if (!(calledDescriptor instanceof ConstructorDescriptor) &&
|
||||||
|
isInlineFunPublicOrPublishedApi &&
|
||||||
inlineFunEffectiveVisibility.toVisibility() != Visibilities.PROTECTED &&
|
inlineFunEffectiveVisibility.toVisibility() != Visibilities.PROTECTED &&
|
||||||
calledFunEffectiveVisibility.toVisibility() == Visibilities.PROTECTED) {
|
calledFunEffectiveVisibility.toVisibility() == Visibilities.PROTECTED) {
|
||||||
context.getTrace().report(Errors.PROTECTED_CALL_FROM_PUBLIC_INLINE.on(expression, calledDescriptor));
|
context.getTrace().report(Errors.PROTECTED_CALL_FROM_PUBLIC_INLINE.on(expression, calledDescriptor));
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||||
|
|
||||||
|
open class Foo protected constructor()
|
||||||
|
|
||||||
|
inline fun foo(f: () -> Unit) = object: Foo() {}
|
||||||
|
|
||||||
|
class A : Foo() {
|
||||||
|
inline fun foo(f: () -> Unit) = <!PROTECTED_CONSTRUCTOR_NOT_IN_SUPER_CALL!>Foo<!>()
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public inline fun foo(/*0*/ f: () -> kotlin.Unit): Foo
|
||||||
|
|
||||||
|
public final class A : Foo {
|
||||||
|
public 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): Foo
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
public open class Foo {
|
||||||
|
protected constructor Foo()
|
||||||
|
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
|
||||||
|
}
|
||||||
@@ -10933,6 +10933,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt15410.kt")
|
||||||
|
public void testKt15410() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inline/kt15410.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt4869.kt")
|
@TestMetadata("kt4869.kt")
|
||||||
public void testKt4869() throws Exception {
|
public void testKt4869() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inline/kt4869.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inline/kt4869.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user