K2 opt-in: don't take sub./int. override parent classes into account
#KT-54823 Fixed
This commit is contained in:
committed by
Space Team
parent
c1c5933c72
commit
73cb4d1a6e
+6
@@ -37850,6 +37850,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
|
|||||||
runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/bodyUsagesAndInline.kt");
|
runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/bodyUsagesAndInline.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("callOfBaseFunctionFromGeneric.kt")
|
||||||
|
public void testCallOfBaseFunctionFromGeneric() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/callOfBaseFunctionFromGeneric.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("classMembers.kt")
|
@TestMetadata("classMembers.kt")
|
||||||
public void testClassMembers() throws Exception {
|
public void testClassMembers() throws Exception {
|
||||||
|
|||||||
+6
@@ -37850,6 +37850,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
|||||||
runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/bodyUsagesAndInline.kt");
|
runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/bodyUsagesAndInline.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("callOfBaseFunctionFromGeneric.kt")
|
||||||
|
public void testCallOfBaseFunctionFromGeneric() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/callOfBaseFunctionFromGeneric.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("classMembers.kt")
|
@TestMetadata("classMembers.kt")
|
||||||
public void testClassMembers() throws Exception {
|
public void testClassMembers() throws Exception {
|
||||||
|
|||||||
+6
@@ -37850,6 +37850,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
|
|||||||
runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/bodyUsagesAndInline.kt");
|
runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/bodyUsagesAndInline.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("callOfBaseFunctionFromGeneric.kt")
|
||||||
|
public void testCallOfBaseFunctionFromGeneric() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/callOfBaseFunctionFromGeneric.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("classMembers.kt")
|
@TestMetadata("classMembers.kt")
|
||||||
public void testClassMembers() throws Exception {
|
public void testClassMembers() throws Exception {
|
||||||
|
|||||||
+7
-9
@@ -159,16 +159,20 @@ object FirOptInUsageBaseChecker {
|
|||||||
if (this is FirNamedFunctionSymbol) {
|
if (this is FirNamedFunctionSymbol) {
|
||||||
parentClassScope?.processDirectlyOverriddenFunctions(this) {
|
parentClassScope?.processDirectlyOverriddenFunctions(this) {
|
||||||
it.loadExperimentalities(
|
it.loadExperimentalities(
|
||||||
context, result, visited, fromSetter = false, dispatchReceiverType = null, fromSupertype = false
|
context, result, visited, fromSetter = false, dispatchReceiverType, fromSupertype = false
|
||||||
)
|
)
|
||||||
ProcessorAction.NEXT
|
ProcessorAction.NEXT
|
||||||
}
|
}
|
||||||
} else if (this is FirPropertySymbol) {
|
} else if (this is FirPropertySymbol) {
|
||||||
parentClassScope?.processDirectlyOverriddenProperties(this) {
|
parentClassScope?.processDirectlyOverriddenProperties(this) {
|
||||||
it.loadExperimentalities(context, result, visited, fromSetter, dispatchReceiverType = null, fromSupertype = false)
|
it.loadExperimentalities(context, result, visited, fromSetter, dispatchReceiverType, fromSupertype = false)
|
||||||
ProcessorAction.NEXT
|
ProcessorAction.NEXT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (dispatchReceiverType == null) {
|
||||||
|
parentClassSymbol?.loadExperimentalities(
|
||||||
|
context, result, visited, fromSetter = false, dispatchReceiverType = null, fromSupertype = false
|
||||||
|
)
|
||||||
}
|
}
|
||||||
if (fir !is FirConstructor) {
|
if (fir !is FirConstructor) {
|
||||||
// Without coneTypeSafe v fails in MT test (FirRenderer.kt)
|
// Without coneTypeSafe v fails in MT test (FirRenderer.kt)
|
||||||
@@ -180,13 +184,7 @@ object FirOptInUsageBaseChecker {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (dispatchReceiverType == null) {
|
dispatchReceiverType?.addExperimentalities(context, result, visited)
|
||||||
parentClassSymbol?.loadExperimentalities(
|
|
||||||
context, result, visited, fromSetter = false, dispatchReceiverType = null, fromSupertype = false
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
dispatchReceiverType.addExperimentalities(context, result, visited)
|
|
||||||
}
|
|
||||||
if (fromSetter && this is FirPropertySymbol) {
|
if (fromSetter && this is FirPropertySymbol) {
|
||||||
setterSymbol?.loadExperimentalities(
|
setterSymbol?.loadExperimentalities(
|
||||||
context, result, visited, fromSetter = false, dispatchReceiverType, fromSupertype = false
|
context, result, visited, fromSetter = false, dispatchReceiverType, fromSupertype = false
|
||||||
|
|||||||
Vendored
+31
@@ -0,0 +1,31 @@
|
|||||||
|
// FIR_IDENTICAL
|
||||||
|
// See KT-54823
|
||||||
|
|
||||||
|
@RequiresOptIn
|
||||||
|
annotation class Marker
|
||||||
|
|
||||||
|
interface VeryBase<T> {
|
||||||
|
fun foo(base: VeryBase<*>) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Marker
|
||||||
|
abstract class Base<T> : VeryBase<T> {
|
||||||
|
fun bar(base: Base<*>) {}
|
||||||
|
|
||||||
|
fun baz() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
@OptIn(Marker::class)
|
||||||
|
open class Intermediate : Base<String>()
|
||||||
|
|
||||||
|
class Derived : Intermediate()
|
||||||
|
|
||||||
|
fun main() {
|
||||||
|
val d = Derived()
|
||||||
|
// Should be Ok (declared in VeryBase without marker)
|
||||||
|
d.foo(d)
|
||||||
|
// Should be Ok (declared in Base with marker, but called on a receiver of type Derived without marker)
|
||||||
|
d.baz()
|
||||||
|
// Should be Error (has a parameter of type Base with marker)
|
||||||
|
d.<!OPT_IN_USAGE_ERROR!>bar<!>(d)
|
||||||
|
}
|
||||||
Vendored
+47
@@ -0,0 +1,47 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public fun main(): kotlin.Unit
|
||||||
|
|
||||||
|
@Marker public abstract class Base</*0*/ T> : VeryBase<T> {
|
||||||
|
public constructor Base</*0*/ T>()
|
||||||
|
public final fun bar(/*0*/ base: Base<*>): kotlin.Unit
|
||||||
|
public final fun baz(): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun foo(/*0*/ base: VeryBase<*>): 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 Derived : Intermediate {
|
||||||
|
public constructor Derived()
|
||||||
|
public final override /*1*/ /*fake_override*/ fun bar(/*0*/ base: Base<*>): kotlin.Unit
|
||||||
|
public final override /*1*/ /*fake_override*/ fun baz(): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun foo(/*0*/ base: VeryBase<*>): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
@kotlin.OptIn(markerClass = {Marker::class}) public open class Intermediate : Base<kotlin.String> {
|
||||||
|
public constructor Intermediate()
|
||||||
|
public final override /*1*/ /*fake_override*/ fun bar(/*0*/ base: Base<*>): kotlin.Unit
|
||||||
|
public final override /*1*/ /*fake_override*/ fun baz(): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun foo(/*0*/ base: VeryBase<*>): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
@kotlin.RequiresOptIn public final annotation class Marker : kotlin.Annotation {
|
||||||
|
public constructor Marker()
|
||||||
|
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 interface VeryBase</*0*/ T> {
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open fun foo(/*0*/ base: VeryBase<*>): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
Generated
+6
@@ -37940,6 +37940,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
|||||||
runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/bodyUsagesAndInline.kt");
|
runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/bodyUsagesAndInline.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("callOfBaseFunctionFromGeneric.kt")
|
||||||
|
public void testCallOfBaseFunctionFromGeneric() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/callOfBaseFunctionFromGeneric.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("classMembers.kt")
|
@TestMetadata("classMembers.kt")
|
||||||
public void testClassMembers() throws Exception {
|
public void testClassMembers() throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user