Introduce error for SUPER_CALL_FROM_PUBLIC_INLINE
^KT-45378 Fixed
This commit is contained in:
+24
@@ -15921,12 +15921,36 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
||||
runTest("compiler/testData/diagnostics/tests/inline/stringTemplate.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("superCall.kt")
|
||||
public void testSuperCall() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inline/superCall.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("superCallDepecation.kt")
|
||||
public void testSuperCallDepecation() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inline/superCallDepecation.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("superCallDepecationWarning.kt")
|
||||
public void testSuperCallDepecationWarning() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inline/superCallDepecationWarning.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("superCallFromMultipleSubclasses.kt")
|
||||
public void testSuperCallFromMultipleSubclasses() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inline/superCallFromMultipleSubclasses.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("superProperty.kt")
|
||||
public void testSuperProperty() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inline/superProperty.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unsupportedConstruction.kt")
|
||||
public void testUnsupportedConstruction() throws Exception {
|
||||
|
||||
+24
@@ -15921,12 +15921,36 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
|
||||
runTest("compiler/testData/diagnostics/tests/inline/stringTemplate.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("superCall.kt")
|
||||
public void testSuperCall() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inline/superCall.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("superCallDepecation.kt")
|
||||
public void testSuperCallDepecation() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inline/superCallDepecation.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("superCallDepecationWarning.kt")
|
||||
public void testSuperCallDepecationWarning() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inline/superCallDepecationWarning.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("superCallFromMultipleSubclasses.kt")
|
||||
public void testSuperCallFromMultipleSubclasses() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inline/superCallFromMultipleSubclasses.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("superProperty.kt")
|
||||
public void testSuperProperty() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inline/superProperty.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unsupportedConstruction.kt")
|
||||
public void testUnsupportedConstruction() throws Exception {
|
||||
|
||||
+1
-1
@@ -1271,7 +1271,7 @@ object DIAGNOSTICS_LIST : DiagnosticList("FirErrors") {
|
||||
parameter<Symbol>("referencedDeclaration")
|
||||
}
|
||||
|
||||
val SUPER_CALL_FROM_PUBLIC_INLINE by warning<KtElement>(PositioningStrategy.REFERENCE_BY_QUALIFIED) {
|
||||
val SUPER_CALL_FROM_PUBLIC_INLINE by error<KtElement>(PositioningStrategy.REFERENCE_BY_QUALIFIED) {
|
||||
parameter<Symbol>("symbol")
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -663,7 +663,7 @@ object FirErrors {
|
||||
val PROTECTED_CALL_FROM_PUBLIC_INLINE_ERROR by error2<KtElement, FirBasedSymbol<*>, FirBasedSymbol<*>>(SourceElementPositioningStrategies.REFERENCE_BY_QUALIFIED)
|
||||
val PROTECTED_CALL_FROM_PUBLIC_INLINE by warning2<KtElement, FirBasedSymbol<*>, FirBasedSymbol<*>>(SourceElementPositioningStrategies.REFERENCE_BY_QUALIFIED)
|
||||
val PRIVATE_CLASS_MEMBER_FROM_INLINE by error2<KtElement, FirBasedSymbol<*>, FirBasedSymbol<*>>(SourceElementPositioningStrategies.REFERENCE_BY_QUALIFIED)
|
||||
val SUPER_CALL_FROM_PUBLIC_INLINE by warning1<KtElement, FirBasedSymbol<*>>(SourceElementPositioningStrategies.REFERENCE_BY_QUALIFIED)
|
||||
val SUPER_CALL_FROM_PUBLIC_INLINE by error1<KtElement, FirBasedSymbol<*>>(SourceElementPositioningStrategies.REFERENCE_BY_QUALIFIED)
|
||||
val DECLARATION_CANT_BE_INLINED by error0<KtDeclaration>(SourceElementPositioningStrategies.DECLARATION_SIGNATURE)
|
||||
val OVERRIDE_BY_INLINE by warning0<KtDeclaration>(SourceElementPositioningStrategies.DECLARATION_SIGNATURE)
|
||||
val NON_INTERNAL_PUBLISHED_API by error0<KtElement>()
|
||||
|
||||
@@ -1164,7 +1164,7 @@ public interface Errors {
|
||||
DiagnosticFactory0<KtAnnotationEntry> NON_INTERNAL_PUBLISHED_API = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactoryForDeprecation1<PsiElement, CallableDescriptor> PROTECTED_CALL_FROM_PUBLIC_INLINE = DiagnosticFactoryForDeprecation1.create(LanguageFeature.ProhibitProtectedCallFromInline);
|
||||
DiagnosticFactory1<PsiElement, CallableDescriptor> PROTECTED_CONSTRUCTOR_CALL_FROM_PUBLIC_INLINE = DiagnosticFactory1.create(WARNING);
|
||||
DiagnosticFactory1<PsiElement, CallableDescriptor> SUPER_CALL_FROM_PUBLIC_INLINE = DiagnosticFactory1.create(WARNING);
|
||||
DiagnosticFactoryForDeprecation1<PsiElement, CallableDescriptor> SUPER_CALL_FROM_PUBLIC_INLINE = DiagnosticFactoryForDeprecation1.create(LanguageFeature.ProhibitSuperCallsFromPublicInline);
|
||||
DiagnosticFactory2<KtElement, KtExpression, DeclarationDescriptor> INVALID_DEFAULT_FUNCTIONAL_PARAMETER_FOR_INLINE = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory2<KtElement, KtExpression, DeclarationDescriptor> NOT_SUPPORTED_INLINE_PARAMETER_IN_INLINE_PARAMETER_DEFAULT_VALUE = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory0<PsiElement> PRIVATE_INLINE_FUNCTIONS_RETURNING_ANONYMOUS_OBJECTS = DiagnosticFactory0.create(WARNING);
|
||||
|
||||
@@ -316,7 +316,11 @@ internal class InlineChecker(private val descriptor: FunctionDescriptor) : CallC
|
||||
val descriptor = thisTypeForSuperCall.constructor.declarationDescriptor as? DeclarationDescriptorWithVisibility ?: return
|
||||
|
||||
if (!isDefinedInInlineFunction(descriptor)) {
|
||||
context.trace.report(SUPER_CALL_FROM_PUBLIC_INLINE.on(expression.parent.parent ?: superCall, callableDescriptor))
|
||||
context.trace.report(
|
||||
SUPER_CALL_FROM_PUBLIC_INLINE.on(
|
||||
context.languageVersionSettings, expression.parent.parent ?: superCall, callableDescriptor
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// !LANGUAGE: -ProhibitSuperCallsFromPublicInline
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// !LANGUAGE: -ProhibitSuperCallsFromPublicInline
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// !LANGUAGE: -ProhibitSuperCallsFromPublicInline
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
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<!>()
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
class SomeContainer {
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
open class A {
|
||||
open fun test() = "OK"
|
||||
}
|
||||
|
||||
object X : A() {
|
||||
override fun test(): String {
|
||||
return "fail"
|
||||
}
|
||||
|
||||
<!NOTHING_TO_INLINE!>inline<!> fun doTest(): String {
|
||||
return <!SUPER_CALL_FROM_PUBLIC_INLINE!>super<!>.test()
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
return X.doTest()
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
open class A {
|
||||
open fun test() = "OK"
|
||||
}
|
||||
|
||||
object X : A() {
|
||||
override fun test(): String {
|
||||
return "fail"
|
||||
}
|
||||
|
||||
<!NOTHING_TO_INLINE!>inline<!> fun doTest(): String {
|
||||
return <!SUPER_CALL_FROM_PUBLIC_INLINE_ERROR!>super.test()<!>
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
return X.doTest()
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package
|
||||
|
||||
public fun box(): kotlin.String
|
||||
|
||||
package test {
|
||||
|
||||
public open class A {
|
||||
public constructor A()
|
||||
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 fun test(): kotlin.String
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public object X : test.A {
|
||||
private constructor X()
|
||||
public final inline fun doTest(): kotlin.String
|
||||
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*/ fun test(): kotlin.String
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
}
|
||||
@@ -7,21 +7,21 @@ open class AndroidTargetConfigurator :
|
||||
AndroidModuleConfigurator {
|
||||
|
||||
public inline fun inlineFun(): String {
|
||||
return <!SUPER_CALL_FROM_PUBLIC_INLINE!>super.classFun()<!> + <!SUPER_CALL_FROM_PUBLIC_INLINE!>super<ModuleConfiguratorWithTests>.getConfiguratorSettings()<!> + <!SUPER_CALL_FROM_PUBLIC_INLINE!>super<AndroidModuleConfigurator>.getConfiguratorSettings()<!>
|
||||
return <!SUPER_CALL_FROM_PUBLIC_INLINE_ERROR!>super.classFun()<!> + <!SUPER_CALL_FROM_PUBLIC_INLINE_ERROR!>super<ModuleConfiguratorWithTests>.getConfiguratorSettings()<!> + <!SUPER_CALL_FROM_PUBLIC_INLINE_ERROR!>super<AndroidModuleConfigurator>.getConfiguratorSettings()<!>
|
||||
}
|
||||
|
||||
@PublishedApi
|
||||
internal inline fun inlineFunPublished(): String {
|
||||
return <!SUPER_CALL_FROM_PUBLIC_INLINE!>super.classFun()<!> + <!SUPER_CALL_FROM_PUBLIC_INLINE!>super<ModuleConfiguratorWithTests>.getConfiguratorSettings()<!> + <!SUPER_CALL_FROM_PUBLIC_INLINE!>super<AndroidModuleConfigurator>.getConfiguratorSettings()<!>
|
||||
return <!SUPER_CALL_FROM_PUBLIC_INLINE_ERROR!>super.classFun()<!> + <!SUPER_CALL_FROM_PUBLIC_INLINE_ERROR!>super<ModuleConfiguratorWithTests>.getConfiguratorSettings()<!> + <!SUPER_CALL_FROM_PUBLIC_INLINE_ERROR!>super<AndroidModuleConfigurator>.getConfiguratorSettings()<!>
|
||||
}
|
||||
|
||||
public inline fun inlineFunAnonymousObjects(): String {
|
||||
{
|
||||
<!SUPER_CALL_FROM_PUBLIC_INLINE!>super.classFun()<!> + <!SUPER_CALL_FROM_PUBLIC_INLINE!>super<ModuleConfiguratorWithTests>.getConfiguratorSettings()<!> + <!SUPER_CALL_FROM_PUBLIC_INLINE!>super<AndroidModuleConfigurator>.getConfiguratorSettings()<!>
|
||||
<!SUPER_CALL_FROM_PUBLIC_INLINE_ERROR!>super.classFun()<!> + <!SUPER_CALL_FROM_PUBLIC_INLINE_ERROR!>super<ModuleConfiguratorWithTests>.getConfiguratorSettings()<!> + <!SUPER_CALL_FROM_PUBLIC_INLINE_ERROR!>super<AndroidModuleConfigurator>.getConfiguratorSettings()<!>
|
||||
}()
|
||||
|
||||
return object {
|
||||
fun run() = <!SUPER_CALL_FROM_PUBLIC_INLINE!>super@AndroidTargetConfigurator.classFun()<!> + <!SUPER_CALL_FROM_PUBLIC_INLINE!>super<ModuleConfiguratorWithTests>@AndroidTargetConfigurator.getConfiguratorSettings()<!> + <!SUPER_CALL_FROM_PUBLIC_INLINE!>super<AndroidModuleConfigurator>@AndroidTargetConfigurator.getConfiguratorSettings()<!>
|
||||
fun run() = <!SUPER_CALL_FROM_PUBLIC_INLINE_ERROR!>super@AndroidTargetConfigurator.classFun()<!> + <!SUPER_CALL_FROM_PUBLIC_INLINE_ERROR!>super<ModuleConfiguratorWithTests>@AndroidTargetConfigurator.getConfiguratorSettings()<!> + <!SUPER_CALL_FROM_PUBLIC_INLINE_ERROR!>super<AndroidModuleConfigurator>@AndroidTargetConfigurator.getConfiguratorSettings()<!>
|
||||
}.run()
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ sealed class FooSealed : Base() {
|
||||
class B: FooSealed()
|
||||
|
||||
inline fun test() {
|
||||
<!SUPER_CALL_FROM_PUBLIC_INLINE!>super.classFun()<!>
|
||||
<!SUPER_CALL_FROM_PUBLIC_INLINE_ERROR!>super.classFun()<!>
|
||||
}
|
||||
|
||||
}
|
||||
@@ -103,7 +103,7 @@ enum class FooEmum {
|
||||
A, B {
|
||||
|
||||
inline fun test() {
|
||||
<!SUPER_CALL_FROM_PUBLIC_INLINE!>super.classFun()<!>
|
||||
<!SUPER_CALL_FROM_PUBLIC_INLINE_ERROR!>super.classFun()<!>
|
||||
}
|
||||
};
|
||||
|
||||
@@ -114,8 +114,8 @@ class FooOuter : Base() {
|
||||
|
||||
inner class FooInner: Base() {
|
||||
inline fun test() {
|
||||
<!SUPER_CALL_FROM_PUBLIC_INLINE!>super@FooOuter.classFun()<!>
|
||||
<!SUPER_CALL_FROM_PUBLIC_INLINE!>super.classFun()<!>
|
||||
<!SUPER_CALL_FROM_PUBLIC_INLINE_ERROR!>super@FooOuter.classFun()<!>
|
||||
<!SUPER_CALL_FROM_PUBLIC_INLINE_ERROR!>super.classFun()<!>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+123
@@ -0,0 +1,123 @@
|
||||
// !LANGUAGE: -ProhibitSuperCallsFromPublicInline
|
||||
// !DIAGNOSTICS: -EXPOSED_PARAMETER_TYPE -NOTHING_TO_INLINE
|
||||
|
||||
// FILE: main.kt
|
||||
open class AndroidTargetConfigurator :
|
||||
Base(),
|
||||
ModuleConfiguratorWithTests,
|
||||
AndroidModuleConfigurator {
|
||||
|
||||
public inline fun inlineFun(): String {
|
||||
return <!SUPER_CALL_FROM_PUBLIC_INLINE!>super<!>.classFun() + <!SUPER_CALL_FROM_PUBLIC_INLINE!>super<ModuleConfiguratorWithTests><!>.getConfiguratorSettings() + <!SUPER_CALL_FROM_PUBLIC_INLINE!>super<AndroidModuleConfigurator><!>.getConfiguratorSettings()
|
||||
}
|
||||
|
||||
@PublishedApi
|
||||
internal inline fun inlineFunPublished(): String {
|
||||
return super.classFun() + super<ModuleConfiguratorWithTests>.getConfiguratorSettings() + super<AndroidModuleConfigurator>.getConfiguratorSettings()
|
||||
}
|
||||
|
||||
public inline fun inlineFunAnonymousObjects(): String {
|
||||
{
|
||||
<!SUPER_CALL_FROM_PUBLIC_INLINE!>super<!>.classFun() + <!SUPER_CALL_FROM_PUBLIC_INLINE!>super<ModuleConfiguratorWithTests><!>.getConfiguratorSettings() + <!SUPER_CALL_FROM_PUBLIC_INLINE!>super<AndroidModuleConfigurator><!>.getConfiguratorSettings()
|
||||
}()
|
||||
|
||||
return object {
|
||||
fun run() = <!SUPER_CALL_FROM_PUBLIC_INLINE!>super@AndroidTargetConfigurator<!>.classFun() + <!SUPER_CALL_FROM_PUBLIC_INLINE!>super<ModuleConfiguratorWithTests>@AndroidTargetConfigurator<!>.getConfiguratorSettings() + <!SUPER_CALL_FROM_PUBLIC_INLINE!>super<AndroidModuleConfigurator>@AndroidTargetConfigurator<!>.getConfiguratorSettings()
|
||||
}.run()
|
||||
}
|
||||
|
||||
public inline fun inlineFunAnonymousNoDiagnostics(): String {
|
||||
return object: AndroidTargetConfigurator(), ModuleConfiguratorWithTests, AndroidModuleConfigurator {
|
||||
|
||||
override fun getConfiguratorSettings(): String {
|
||||
return super<AndroidTargetConfigurator>.getConfiguratorSettings()
|
||||
}
|
||||
|
||||
inline fun anonymousInline() {
|
||||
super.classFun() + super<<!QUALIFIED_SUPERTYPE_EXTENDED_BY_OTHER_SUPERTYPE!>ModuleConfiguratorWithTests<!>>.getConfiguratorSettings() + super<<!QUALIFIED_SUPERTYPE_EXTENDED_BY_OTHER_SUPERTYPE!>AndroidModuleConfigurator<!>>.getConfiguratorSettings()
|
||||
}
|
||||
|
||||
fun run() = super.classFun() + super<<!QUALIFIED_SUPERTYPE_EXTENDED_BY_OTHER_SUPERTYPE!>ModuleConfiguratorWithTests<!>>.getConfiguratorSettings() + super<<!QUALIFIED_SUPERTYPE_EXTENDED_BY_OTHER_SUPERTYPE!>AndroidModuleConfigurator<!>>.getConfiguratorSettings()
|
||||
}.run()
|
||||
}
|
||||
|
||||
|
||||
|
||||
internal inline fun inlineInternal(): String {
|
||||
return super.classFun() + super<ModuleConfiguratorWithTests>.getConfiguratorSettings() + super<AndroidModuleConfigurator>.getConfiguratorSettings()
|
||||
}
|
||||
|
||||
private inline fun inlinePrivate(): String {
|
||||
return super.classFun() + super<ModuleConfiguratorWithTests>.getConfiguratorSettings() + super<AndroidModuleConfigurator>.getConfiguratorSettings()
|
||||
}
|
||||
|
||||
|
||||
//non-inline
|
||||
override fun getConfiguratorSettings() =
|
||||
super.classFun() + super<ModuleConfiguratorWithTests>.getConfiguratorSettings() + super<AndroidModuleConfigurator>.getConfiguratorSettings()
|
||||
|
||||
fun noInline() {
|
||||
{
|
||||
super.classFun() + super<ModuleConfiguratorWithTests>.getConfiguratorSettings() + super<AndroidModuleConfigurator>.getConfiguratorSettings()
|
||||
}()
|
||||
|
||||
object {
|
||||
fun run() = super@AndroidTargetConfigurator.classFun() + super<ModuleConfiguratorWithTests>@AndroidTargetConfigurator.getConfiguratorSettings() + super<AndroidModuleConfigurator>@AndroidTargetConfigurator.getConfiguratorSettings()
|
||||
}.run()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
open class Base {
|
||||
fun classFun(): String = "Class"
|
||||
}
|
||||
|
||||
interface ModuleConfiguratorWithTests : ModuleConfiguratorWithSettings {
|
||||
override fun getConfiguratorSettings() = "K"
|
||||
}
|
||||
|
||||
interface ModuleConfiguratorWithSettings {
|
||||
fun getConfiguratorSettings(): String = ""
|
||||
}
|
||||
|
||||
|
||||
interface AndroidModuleConfigurator :
|
||||
ModuleConfiguratorWithSettings {
|
||||
override fun getConfiguratorSettings(): String {
|
||||
return "O"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sealed class FooSealed : Base() {
|
||||
class A : FooSealed()
|
||||
|
||||
class B: FooSealed()
|
||||
|
||||
inline fun test() {
|
||||
<!SUPER_CALL_FROM_PUBLIC_INLINE!>super<!>.classFun()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
enum class FooEmum {
|
||||
A, B {
|
||||
|
||||
inline fun test() {
|
||||
super.classFun()
|
||||
}
|
||||
};
|
||||
|
||||
fun classFun(): String = "Class"
|
||||
}
|
||||
|
||||
class FooOuter : Base() {
|
||||
|
||||
inner class FooInner: Base() {
|
||||
inline fun test() {
|
||||
<!SUPER_CALL_FROM_PUBLIC_INLINE!>super@FooOuter<!>.classFun()
|
||||
<!SUPER_CALL_FROM_PUBLIC_INLINE!>super<!>.classFun()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
// !LANGUAGE: -ProhibitSuperCallsFromPublicInline
|
||||
// !DIAGNOSTICS: -EXPOSED_PARAMETER_TYPE -NOTHING_TO_INLINE
|
||||
|
||||
// FILE: main.kt
|
||||
open class AndroidTargetConfigurator :
|
||||
Base(),
|
||||
ModuleConfiguratorWithTests,
|
||||
AndroidModuleConfigurator {
|
||||
|
||||
public inline fun inlineFun(): String {
|
||||
return <!SUPER_CALL_FROM_PUBLIC_INLINE_WARNING!>super.classFun()<!> + <!SUPER_CALL_FROM_PUBLIC_INLINE_WARNING!>super<ModuleConfiguratorWithTests>.getConfiguratorSettings()<!> + <!SUPER_CALL_FROM_PUBLIC_INLINE_WARNING!>super<AndroidModuleConfigurator>.getConfiguratorSettings()<!>
|
||||
}
|
||||
|
||||
@PublishedApi
|
||||
internal inline fun inlineFunPublished(): String {
|
||||
return <!SUPER_CALL_FROM_PUBLIC_INLINE_WARNING!>super.classFun()<!> + <!SUPER_CALL_FROM_PUBLIC_INLINE_WARNING!>super<ModuleConfiguratorWithTests>.getConfiguratorSettings()<!> + <!SUPER_CALL_FROM_PUBLIC_INLINE_WARNING!>super<AndroidModuleConfigurator>.getConfiguratorSettings()<!>
|
||||
}
|
||||
|
||||
public inline fun inlineFunAnonymousObjects(): String {
|
||||
{
|
||||
<!SUPER_CALL_FROM_PUBLIC_INLINE_WARNING!>super.classFun()<!> + <!SUPER_CALL_FROM_PUBLIC_INLINE_WARNING!>super<ModuleConfiguratorWithTests>.getConfiguratorSettings()<!> + <!SUPER_CALL_FROM_PUBLIC_INLINE_WARNING!>super<AndroidModuleConfigurator>.getConfiguratorSettings()<!>
|
||||
}()
|
||||
|
||||
return object {
|
||||
fun run() = <!SUPER_CALL_FROM_PUBLIC_INLINE_WARNING!>super@AndroidTargetConfigurator.classFun()<!> + <!SUPER_CALL_FROM_PUBLIC_INLINE_WARNING!>super<ModuleConfiguratorWithTests>@AndroidTargetConfigurator.getConfiguratorSettings()<!> + <!SUPER_CALL_FROM_PUBLIC_INLINE_WARNING!>super<AndroidModuleConfigurator>@AndroidTargetConfigurator.getConfiguratorSettings()<!>
|
||||
}.run()
|
||||
}
|
||||
|
||||
public inline fun inlineFunAnonymousNoDiagnostics(): String {
|
||||
return object: AndroidTargetConfigurator(), ModuleConfiguratorWithTests, AndroidModuleConfigurator {
|
||||
|
||||
override fun getConfiguratorSettings(): String {
|
||||
return super<AndroidTargetConfigurator>.getConfiguratorSettings()
|
||||
}
|
||||
|
||||
inline fun anonymousInline() {
|
||||
super.classFun() + super<<!QUALIFIED_SUPERTYPE_EXTENDED_BY_OTHER_SUPERTYPE!>ModuleConfiguratorWithTests<!>>.getConfiguratorSettings() + super<<!QUALIFIED_SUPERTYPE_EXTENDED_BY_OTHER_SUPERTYPE!>AndroidModuleConfigurator<!>>.getConfiguratorSettings()
|
||||
}
|
||||
|
||||
fun run() = super.classFun() + super<<!QUALIFIED_SUPERTYPE_EXTENDED_BY_OTHER_SUPERTYPE!>ModuleConfiguratorWithTests<!>>.getConfiguratorSettings() + super<<!QUALIFIED_SUPERTYPE_EXTENDED_BY_OTHER_SUPERTYPE!>AndroidModuleConfigurator<!>>.getConfiguratorSettings()
|
||||
}.run()
|
||||
}
|
||||
|
||||
|
||||
|
||||
internal inline fun inlineInternal(): String {
|
||||
return super.classFun() + super<ModuleConfiguratorWithTests>.getConfiguratorSettings() + super<AndroidModuleConfigurator>.getConfiguratorSettings()
|
||||
}
|
||||
|
||||
private inline fun inlinePrivate(): String {
|
||||
return super.classFun() + super<ModuleConfiguratorWithTests>.getConfiguratorSettings() + super<AndroidModuleConfigurator>.getConfiguratorSettings()
|
||||
}
|
||||
|
||||
|
||||
//non-inline
|
||||
override fun getConfiguratorSettings() =
|
||||
super.classFun() + super<ModuleConfiguratorWithTests>.getConfiguratorSettings() + super<AndroidModuleConfigurator>.getConfiguratorSettings()
|
||||
|
||||
fun noInline() {
|
||||
{
|
||||
super.classFun() + super<ModuleConfiguratorWithTests>.getConfiguratorSettings() + super<AndroidModuleConfigurator>.getConfiguratorSettings()
|
||||
}()
|
||||
|
||||
object {
|
||||
fun run() = super@AndroidTargetConfigurator.classFun() + super<ModuleConfiguratorWithTests>@AndroidTargetConfigurator.getConfiguratorSettings() + super<AndroidModuleConfigurator>@AndroidTargetConfigurator.getConfiguratorSettings()
|
||||
}.run()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
open class Base {
|
||||
fun classFun(): String = "Class"
|
||||
}
|
||||
|
||||
interface ModuleConfiguratorWithTests : ModuleConfiguratorWithSettings {
|
||||
override fun getConfiguratorSettings() = "K"
|
||||
}
|
||||
|
||||
interface ModuleConfiguratorWithSettings {
|
||||
fun getConfiguratorSettings(): String = ""
|
||||
}
|
||||
|
||||
|
||||
interface AndroidModuleConfigurator :
|
||||
ModuleConfiguratorWithSettings {
|
||||
override fun getConfiguratorSettings(): String {
|
||||
return "O"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sealed class FooSealed : Base() {
|
||||
class A : FooSealed()
|
||||
|
||||
class B: FooSealed()
|
||||
|
||||
inline fun test() {
|
||||
<!SUPER_CALL_FROM_PUBLIC_INLINE_WARNING!>super.classFun()<!>
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
enum class FooEmum {
|
||||
A, B {
|
||||
|
||||
inline fun test() {
|
||||
<!SUPER_CALL_FROM_PUBLIC_INLINE_WARNING!>super.classFun()<!>
|
||||
}
|
||||
};
|
||||
|
||||
fun classFun(): String = "Class"
|
||||
}
|
||||
|
||||
class FooOuter : Base() {
|
||||
|
||||
inner class FooInner: Base() {
|
||||
inline fun test() {
|
||||
<!SUPER_CALL_FROM_PUBLIC_INLINE_WARNING!>super@FooOuter.classFun()<!>
|
||||
<!SUPER_CALL_FROM_PUBLIC_INLINE_WARNING!>super.classFun()<!>
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
package
|
||||
|
||||
public interface AndroidModuleConfigurator : ModuleConfiguratorWithSettings {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ fun getConfiguratorSettings(): kotlin.String
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public open class AndroidTargetConfigurator : Base, ModuleConfiguratorWithTests, AndroidModuleConfigurator {
|
||||
public constructor AndroidTargetConfigurator()
|
||||
public final override /*1*/ /*fake_override*/ fun classFun(): kotlin.String
|
||||
public open override /*3*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ fun getConfiguratorSettings(): kotlin.String
|
||||
public open override /*3*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public final inline fun inlineFun(): kotlin.String
|
||||
public final inline fun inlineFunAnonymousNoDiagnostics(): kotlin.String
|
||||
public final inline fun inlineFunAnonymousObjects(): kotlin.String
|
||||
@kotlin.PublishedApi internal final inline fun inlineFunPublished(): kotlin.String
|
||||
internal final inline fun inlineInternal(): kotlin.String
|
||||
private final inline fun inlinePrivate(): kotlin.String
|
||||
public final fun noInline(): kotlin.Unit
|
||||
public open override /*3*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public open class Base {
|
||||
public constructor Base()
|
||||
public final fun classFun(): kotlin.String
|
||||
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
|
||||
}
|
||||
|
||||
public final enum class FooEmum : kotlin.Enum<FooEmum> {
|
||||
enum entry A
|
||||
|
||||
enum entry B
|
||||
|
||||
private constructor FooEmum()
|
||||
public final override /*1*/ /*fake_override*/ val name: kotlin.String
|
||||
public final override /*1*/ /*fake_override*/ val ordinal: kotlin.Int
|
||||
public final fun classFun(): kotlin.String
|
||||
protected final override /*1*/ /*fake_override*/ fun clone(): kotlin.Any
|
||||
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: FooEmum): kotlin.Int
|
||||
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
protected/*protected and package*/ final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun finalize(): kotlin.Unit
|
||||
public final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun getDeclaringClass(): java.lang.Class<FooEmum!>!
|
||||
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
// Static members
|
||||
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): FooEmum
|
||||
public final /*synthesized*/ fun values(): kotlin.Array<FooEmum>
|
||||
}
|
||||
|
||||
public final class FooOuter : Base {
|
||||
public constructor FooOuter()
|
||||
public final override /*1*/ /*fake_override*/ fun classFun(): kotlin.String
|
||||
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
|
||||
|
||||
public final inner class FooInner : Base {
|
||||
public constructor FooInner()
|
||||
public final override /*1*/ /*fake_override*/ fun classFun(): kotlin.String
|
||||
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 final inline fun test(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class FooSealed : Base {
|
||||
protected constructor FooSealed()
|
||||
public final override /*1*/ /*fake_override*/ fun classFun(): kotlin.String
|
||||
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 final inline fun test(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
public final class A : FooSealed {
|
||||
public constructor A()
|
||||
public final override /*1*/ /*fake_override*/ fun classFun(): kotlin.String
|
||||
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 final override /*1*/ inline /*fake_override*/ fun test(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class B : FooSealed {
|
||||
public constructor B()
|
||||
public final override /*1*/ /*fake_override*/ fun classFun(): kotlin.String
|
||||
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 final override /*1*/ inline /*fake_override*/ fun test(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
}
|
||||
|
||||
public interface ModuleConfiguratorWithSettings {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open fun getConfiguratorSettings(): kotlin.String
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface ModuleConfiguratorWithTests : ModuleConfiguratorWithSettings {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ fun getConfiguratorSettings(): kotlin.String
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
open class A {
|
||||
open fun test(s: String) = s
|
||||
}
|
||||
|
||||
object B : A() {
|
||||
override fun test(s: String) = "fail"
|
||||
|
||||
<!NOTHING_TO_INLINE!>inline<!> fun doTest(s: String) = <!SUPER_CALL_FROM_PUBLIC_INLINE!>super<!>.test(s)
|
||||
}
|
||||
|
||||
object C : A() {
|
||||
override fun test(s: String) = "fail"
|
||||
|
||||
<!NOTHING_TO_INLINE!>inline<!> fun doTest(s: String) = <!SUPER_CALL_FROM_PUBLIC_INLINE!>super<!>.test(s)
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
return B.doTest("O") + C.doTest("K")
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
open class A {
|
||||
open fun test(s: String) = s
|
||||
}
|
||||
|
||||
object B : A() {
|
||||
override fun test(s: String) = "fail"
|
||||
|
||||
<!NOTHING_TO_INLINE!>inline<!> fun doTest(s: String) = <!SUPER_CALL_FROM_PUBLIC_INLINE_ERROR!>super.test(s)<!>
|
||||
}
|
||||
|
||||
object C : A() {
|
||||
override fun test(s: String) = "fail"
|
||||
|
||||
<!NOTHING_TO_INLINE!>inline<!> fun doTest(s: String) = <!SUPER_CALL_FROM_PUBLIC_INLINE_ERROR!>super.test(s)<!>
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
return B.doTest("O") + C.doTest("K")
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package
|
||||
|
||||
public fun box(): kotlin.String
|
||||
|
||||
package test {
|
||||
|
||||
public open class A {
|
||||
public constructor A()
|
||||
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 fun test(/*0*/ s: kotlin.String): kotlin.String
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public object B : test.A {
|
||||
private constructor B()
|
||||
public final inline fun doTest(/*0*/ s: kotlin.String): kotlin.String
|
||||
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*/ fun test(/*0*/ s: kotlin.String): kotlin.String
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public object C : test.A {
|
||||
private constructor C()
|
||||
public final inline fun doTest(/*0*/ s: kotlin.String): kotlin.String
|
||||
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*/ fun test(/*0*/ s: kotlin.String): kotlin.String
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
open class A {
|
||||
open val test = "OK"
|
||||
}
|
||||
|
||||
object X : A() {
|
||||
override val test: String
|
||||
get() = "fail"
|
||||
|
||||
<!NOTHING_TO_INLINE!>inline<!> fun doTest(): String {
|
||||
return <!SUPER_CALL_FROM_PUBLIC_INLINE!>super<!>.test
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
return X.doTest()
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
open class A {
|
||||
open val test = "OK"
|
||||
}
|
||||
|
||||
object X : A() {
|
||||
override val test: String
|
||||
get() = "fail"
|
||||
|
||||
<!NOTHING_TO_INLINE!>inline<!> fun doTest(): String {
|
||||
<!SUPER_CALL_FROM_PUBLIC_INLINE_ERROR!>return super.test<!>
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
return X.doTest()
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package
|
||||
|
||||
public fun box(): kotlin.String
|
||||
|
||||
package test {
|
||||
|
||||
public open class A {
|
||||
public constructor A()
|
||||
public open val test: kotlin.String = "OK"
|
||||
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
|
||||
}
|
||||
|
||||
public object X : test.A {
|
||||
private constructor X()
|
||||
public open override /*1*/ val test: kotlin.String
|
||||
public final inline fun doTest(): kotlin.String
|
||||
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
|
||||
}
|
||||
}
|
||||
Generated
+24
@@ -15927,12 +15927,36 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
runTest("compiler/testData/diagnostics/tests/inline/stringTemplate.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("superCall.kt")
|
||||
public void testSuperCall() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inline/superCall.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("superCallDepecation.kt")
|
||||
public void testSuperCallDepecation() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inline/superCallDepecation.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("superCallDepecationWarning.kt")
|
||||
public void testSuperCallDepecationWarning() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inline/superCallDepecationWarning.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("superCallFromMultipleSubclasses.kt")
|
||||
public void testSuperCallFromMultipleSubclasses() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inline/superCallFromMultipleSubclasses.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("superProperty.kt")
|
||||
public void testSuperProperty() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inline/superProperty.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unsupportedConstruction.kt")
|
||||
public void testUnsupportedConstruction() throws Exception {
|
||||
|
||||
@@ -214,6 +214,7 @@ enum class LanguageFeature(
|
||||
RepeatableAnnotationContainerConstraints(KOTLIN_1_6, kind = BUG_FIX),
|
||||
UseBuilderInferenceOnlyIfNeeded(KOTLIN_1_6),
|
||||
SuspendConversion(KOTLIN_1_6),
|
||||
ProhibitSuperCallsFromPublicInline(KOTLIN_1_6),
|
||||
|
||||
// 1.7
|
||||
|
||||
|
||||
Reference in New Issue
Block a user