K2 opt-in: drop redundant recursive check for overridables
This commit is contained in:
committed by
Space Team
parent
cd81f22bd3
commit
a77750a257
+6
@@ -37964,6 +37964,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/noRetentionAfter.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("overridableCheck.kt")
|
||||
public void testOverridableCheck() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/overridableCheck.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("override.kt")
|
||||
public void testOverride() throws Exception {
|
||||
|
||||
+6
@@ -37964,6 +37964,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/noRetentionAfter.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("overridableCheck.kt")
|
||||
public void testOverridableCheck() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/overridableCheck.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("override.kt")
|
||||
public void testOverride() throws Exception {
|
||||
|
||||
+6
@@ -37964,6 +37964,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/noRetentionAfter.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("overridableCheck.kt")
|
||||
public void testOverridableCheck() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/overridableCheck.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("override.kt")
|
||||
public void testOverride() throws Exception {
|
||||
|
||||
+1
-28
@@ -13,15 +13,11 @@ import org.jetbrains.kotlin.fir.analysis.checkers.*
|
||||
import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.declarations.utils.isLocal
|
||||
import org.jetbrains.kotlin.fir.expressions.FirConstExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccessExpression
|
||||
import org.jetbrains.kotlin.fir.resolve.fullyExpandedType
|
||||
import org.jetbrains.kotlin.fir.resolve.toFirRegularClassSymbol
|
||||
import org.jetbrains.kotlin.fir.resolve.toSymbol
|
||||
import org.jetbrains.kotlin.fir.scopes.ProcessorAction
|
||||
import org.jetbrains.kotlin.fir.scopes.processDirectlyOverriddenFunctions
|
||||
import org.jetbrains.kotlin.fir.scopes.processDirectlyOverriddenProperties
|
||||
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.SymbolInternals
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.*
|
||||
@@ -158,7 +154,7 @@ object FirOptInUsageBaseChecker {
|
||||
context, result, visited, fromSetter = false, dispatchReceiverType = null, fromSupertype = false
|
||||
)
|
||||
} else {
|
||||
fir.loadOverridableSpecificExperimentalities(session, context, parentClassSymbol, visited, result)
|
||||
fir.loadOverridableSpecificExperimentalities(session, context, visited, result)
|
||||
}
|
||||
dispatchReceiverType?.addExperimentalities(context, result, visited)
|
||||
if (fromSetter && this is FirPropertySymbol) {
|
||||
@@ -197,35 +193,12 @@ object FirOptInUsageBaseChecker {
|
||||
return result
|
||||
}
|
||||
|
||||
@OptIn(SymbolInternals::class)
|
||||
private fun FirCallableDeclaration.loadOverridableSpecificExperimentalities(
|
||||
session: FirSession,
|
||||
context: CheckerContext,
|
||||
parentClassSymbol: FirRegularClassSymbol?,
|
||||
visited: MutableSet<FirDeclaration>,
|
||||
result: SmartSet<Experimentality>
|
||||
) {
|
||||
if (isSubstitutionOrIntersectionOverride) {
|
||||
parentClassSymbol?.lazyResolveToPhase(FirResolvePhase.STATUS)
|
||||
val parentClassScope = parentClassSymbol?.unsubstitutedScope(context)
|
||||
if (this is FirSimpleFunction) {
|
||||
parentClassScope?.processDirectlyOverriddenFunctions(symbol) { overriddenSymbol ->
|
||||
val overriddenFir = overriddenSymbol.fir
|
||||
if (visited.add(overriddenFir)) {
|
||||
overriddenFir.loadOverridableSpecificExperimentalities(session, context, parentClassSymbol, visited, result)
|
||||
}
|
||||
ProcessorAction.NEXT
|
||||
}
|
||||
} else if (this is FirProperty) {
|
||||
parentClassScope?.processDirectlyOverriddenProperties(symbol) { overriddenSymbol ->
|
||||
val overriddenFir = overriddenSymbol.fir
|
||||
if (visited.add(overriddenFir)) {
|
||||
overriddenFir.loadOverridableSpecificExperimentalities(session, context, parentClassSymbol, visited, result)
|
||||
}
|
||||
ProcessorAction.NEXT
|
||||
}
|
||||
}
|
||||
}
|
||||
// Without coneTypeSafe v fails in MT test (FirRenderer.kt)
|
||||
returnTypeRef.coneTypeSafe<ConeKotlinType>().addExperimentalities(context, result, visited)
|
||||
receiverParameter?.typeRef?.coneType.addExperimentalities(context, result, visited)
|
||||
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
@RequiresOptIn
|
||||
@Target(AnnotationTarget.TYPEALIAS, AnnotationTarget.FUNCTION)
|
||||
annotation class Marker
|
||||
|
||||
class Wrapper<T>
|
||||
|
||||
@Marker
|
||||
typealias TA<T> = Wrapper<T>
|
||||
|
||||
open class Base<T> {
|
||||
@Marker
|
||||
open fun foo(): T? = null
|
||||
|
||||
open fun bar(): <!OPT_IN_USAGE_ERROR!>TA<T><!>? = null
|
||||
}
|
||||
|
||||
class Derived : Base<String>()
|
||||
|
||||
fun test(d: Derived) {
|
||||
d.<!OPT_IN_USAGE_ERROR!>foo<!>()
|
||||
d.<!OPT_IN_USAGE_ERROR!>bar<!>()
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
@RequiresOptIn
|
||||
@Target(AnnotationTarget.TYPEALIAS, AnnotationTarget.FUNCTION)
|
||||
annotation class Marker
|
||||
|
||||
class Wrapper<T>
|
||||
|
||||
@Marker
|
||||
typealias TA<T> = Wrapper<T>
|
||||
|
||||
open class Base<T> {
|
||||
@Marker
|
||||
open fun foo(): T? = null
|
||||
|
||||
open fun bar(): <!OPT_IN_USAGE_ERROR!>TA<!><T>? = null
|
||||
}
|
||||
|
||||
class Derived : Base<String>()
|
||||
|
||||
fun test(d: Derived) {
|
||||
d.<!OPT_IN_USAGE_ERROR!>foo<!>()
|
||||
d.<!OPT_IN_USAGE_ERROR!>bar<!>()
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package
|
||||
|
||||
public fun test(/*0*/ d: Derived): kotlin.Unit
|
||||
|
||||
public open class Base</*0*/ T> {
|
||||
public constructor Base</*0*/ T>()
|
||||
public open fun bar(): TA<T>? /* = Wrapper<T>? */
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
@Marker public open fun foo(): T?
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class Derived : Base<kotlin.String> {
|
||||
public constructor Derived()
|
||||
public open override /*1*/ /*fake_override*/ fun bar(): TA<kotlin.String>? /* = Wrapper<kotlin.String>? */
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
@Marker public open override /*1*/ /*fake_override*/ fun foo(): kotlin.String?
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
@kotlin.RequiresOptIn @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPEALIAS, AnnotationTarget.FUNCTION}) 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 final class Wrapper</*0*/ T> {
|
||||
public constructor Wrapper</*0*/ T>()
|
||||
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
|
||||
}
|
||||
@Marker public typealias TA</*0*/ T> = Wrapper<T>
|
||||
Generated
+6
@@ -38054,6 +38054,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/noRetentionAfter.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("overridableCheck.kt")
|
||||
public void testOverridableCheck() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/overridableCheck.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("override.kt")
|
||||
public void testOverride() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user