[FIR] Revert FirMultipleDefaultsInheritedFromSupertypesChecker
It's possible to write a fix that would prevent false positives with this checker, but the core intuition behind it is invalid. This checker assumes that it's enough to only check direct overriddens, while in reality even simple `Source` override functions are not allowed to contain default values, so they can't be used to make judgements about them. ^KT-59408 Open ^KT-59408 Open ^KT-61095 Fixed ^KT-61165 Fixed ^KT-61029 Fixed
This commit is contained in:
committed by
Space Team
parent
2ce324f1fc
commit
dc9ed5656e
-14
@@ -2562,20 +2562,6 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirErrors.MULTIPLE_DEFAULTS_INHERITED_FROM_SUPERTYPES) { firDiagnostic ->
|
||||
MultipleDefaultsInheritedFromSupertypesImpl(
|
||||
firSymbolBuilder.buildSymbol(firDiagnostic.a),
|
||||
firDiagnostic as KtPsiDiagnostic,
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirErrors.MULTIPLE_DEFAULTS_INHERITED_FROM_SUPERTYPES_WHEN_NO_EXPLICIT_OVERRIDE) { firDiagnostic ->
|
||||
MultipleDefaultsInheritedFromSupertypesWhenNoExplicitOverrideImpl(
|
||||
firSymbolBuilder.buildSymbol(firDiagnostic.a),
|
||||
firDiagnostic as KtPsiDiagnostic,
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirErrors.TYPEALIAS_EXPANDS_TO_ARRAY_OF_NOTHINGS) { firDiagnostic ->
|
||||
TypealiasExpandsToArrayOfNothingsImpl(
|
||||
firSymbolBuilder.typeBuilder.buildKtType(firDiagnostic.a),
|
||||
|
||||
-10
@@ -1821,16 +1821,6 @@ sealed interface KtFirDiagnostic<PSI : PsiElement> : KtDiagnosticWithPsi<PSI> {
|
||||
val containingClassName: Name
|
||||
}
|
||||
|
||||
interface MultipleDefaultsInheritedFromSupertypes : KtFirDiagnostic<KtElement> {
|
||||
override val diagnosticClass get() = MultipleDefaultsInheritedFromSupertypes::class
|
||||
val valueParameter: KtSymbol
|
||||
}
|
||||
|
||||
interface MultipleDefaultsInheritedFromSupertypesWhenNoExplicitOverride : KtFirDiagnostic<KtElement> {
|
||||
override val diagnosticClass get() = MultipleDefaultsInheritedFromSupertypesWhenNoExplicitOverride::class
|
||||
val valueParameter: KtSymbol
|
||||
}
|
||||
|
||||
interface TypealiasExpandsToArrayOfNothings : KtFirDiagnostic<KtElement> {
|
||||
override val diagnosticClass get() = TypealiasExpandsToArrayOfNothings::class
|
||||
val type: KtType
|
||||
|
||||
-12
@@ -2187,18 +2187,6 @@ internal class CannotChangeAccessPrivilegeImpl(
|
||||
token: KtLifetimeToken,
|
||||
) : KtAbstractFirDiagnostic<KtModifierListOwner>(firDiagnostic, token), KtFirDiagnostic.CannotChangeAccessPrivilege
|
||||
|
||||
internal class MultipleDefaultsInheritedFromSupertypesImpl(
|
||||
override val valueParameter: KtSymbol,
|
||||
firDiagnostic: KtPsiDiagnostic,
|
||||
token: KtLifetimeToken,
|
||||
) : KtAbstractFirDiagnostic<KtElement>(firDiagnostic, token), KtFirDiagnostic.MultipleDefaultsInheritedFromSupertypes
|
||||
|
||||
internal class MultipleDefaultsInheritedFromSupertypesWhenNoExplicitOverrideImpl(
|
||||
override val valueParameter: KtSymbol,
|
||||
firDiagnostic: KtPsiDiagnostic,
|
||||
token: KtLifetimeToken,
|
||||
) : KtAbstractFirDiagnostic<KtElement>(firDiagnostic, token), KtFirDiagnostic.MultipleDefaultsInheritedFromSupertypesWhenNoExplicitOverride
|
||||
|
||||
internal class TypealiasExpandsToArrayOfNothingsImpl(
|
||||
override val type: KtType,
|
||||
firDiagnostic: KtPsiDiagnostic,
|
||||
|
||||
+30
@@ -303,6 +303,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
|
||||
runTest("compiler/testData/diagnostics/tests/Dollar.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("duplicateDirrectOverriddenCallables.kt")
|
||||
public void testDuplicateDirrectOverriddenCallables() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/duplicateDirrectOverriddenCallables.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("emptyLhsClassLiterals.kt")
|
||||
public void testEmptyLhsClassLiterals() throws Exception {
|
||||
@@ -345,6 +351,24 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
|
||||
runTest("compiler/testData/diagnostics/tests/ExternalAndAbstract.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("falseNegativeDuplicateDefaultValues1.kt")
|
||||
public void testFalseNegativeDuplicateDefaultValues1() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/falseNegativeDuplicateDefaultValues1.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("falseNegativeDuplicateDefaultValues2.kt")
|
||||
public void testFalseNegativeDuplicateDefaultValues2() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/falseNegativeDuplicateDefaultValues2.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("falseNegativeDuplicateDefaultValues3.kt")
|
||||
public void testFalseNegativeDuplicateDefaultValues3() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/falseNegativeDuplicateDefaultValues3.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("fileDependencyRecursion.kt")
|
||||
public void testFileDependencyRecursion() throws Exception {
|
||||
@@ -729,6 +753,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
|
||||
runTest("compiler/testData/diagnostics/tests/MultipleBounds.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("multipleDefaultsNoSource.kt")
|
||||
public void testMultipleDefaultsNoSource() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/multipleDefaultsNoSource.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("NamedFunctionTypeParameterInSupertype.kt")
|
||||
public void testNamedFunctionTypeParameterInSupertype() throws Exception {
|
||||
|
||||
+30
@@ -303,6 +303,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
|
||||
runTest("compiler/testData/diagnostics/tests/Dollar.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("duplicateDirrectOverriddenCallables.kt")
|
||||
public void testDuplicateDirrectOverriddenCallables() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/duplicateDirrectOverriddenCallables.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("emptyLhsClassLiterals.kt")
|
||||
public void testEmptyLhsClassLiterals() throws Exception {
|
||||
@@ -345,6 +351,24 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
|
||||
runTest("compiler/testData/diagnostics/tests/ExternalAndAbstract.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("falseNegativeDuplicateDefaultValues1.kt")
|
||||
public void testFalseNegativeDuplicateDefaultValues1() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/falseNegativeDuplicateDefaultValues1.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("falseNegativeDuplicateDefaultValues2.kt")
|
||||
public void testFalseNegativeDuplicateDefaultValues2() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/falseNegativeDuplicateDefaultValues2.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("falseNegativeDuplicateDefaultValues3.kt")
|
||||
public void testFalseNegativeDuplicateDefaultValues3() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/falseNegativeDuplicateDefaultValues3.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("fileDependencyRecursion.kt")
|
||||
public void testFileDependencyRecursion() throws Exception {
|
||||
@@ -729,6 +753,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
|
||||
runTest("compiler/testData/diagnostics/tests/MultipleBounds.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("multipleDefaultsNoSource.kt")
|
||||
public void testMultipleDefaultsNoSource() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/multipleDefaultsNoSource.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("NamedFunctionTypeParameterInSupertype.kt")
|
||||
public void testNamedFunctionTypeParameterInSupertype() throws Exception {
|
||||
|
||||
+30
@@ -303,6 +303,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
|
||||
runTest("compiler/testData/diagnostics/tests/Dollar.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("duplicateDirrectOverriddenCallables.kt")
|
||||
public void testDuplicateDirrectOverriddenCallables() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/duplicateDirrectOverriddenCallables.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("emptyLhsClassLiterals.kt")
|
||||
public void testEmptyLhsClassLiterals() throws Exception {
|
||||
@@ -345,6 +351,24 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
|
||||
runTest("compiler/testData/diagnostics/tests/ExternalAndAbstract.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("falseNegativeDuplicateDefaultValues1.kt")
|
||||
public void testFalseNegativeDuplicateDefaultValues1() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/falseNegativeDuplicateDefaultValues1.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("falseNegativeDuplicateDefaultValues2.kt")
|
||||
public void testFalseNegativeDuplicateDefaultValues2() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/falseNegativeDuplicateDefaultValues2.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("falseNegativeDuplicateDefaultValues3.kt")
|
||||
public void testFalseNegativeDuplicateDefaultValues3() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/falseNegativeDuplicateDefaultValues3.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("fileDependencyRecursion.kt")
|
||||
public void testFileDependencyRecursion() throws Exception {
|
||||
@@ -729,6 +753,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
|
||||
runTest("compiler/testData/diagnostics/tests/MultipleBounds.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("multipleDefaultsNoSource.kt")
|
||||
public void testMultipleDefaultsNoSource() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/multipleDefaultsNoSource.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("NamedFunctionTypeParameterInSupertype.kt")
|
||||
public void testNamedFunctionTypeParameterInSupertype() throws Exception {
|
||||
|
||||
+30
@@ -303,6 +303,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
|
||||
runTest("compiler/testData/diagnostics/tests/Dollar.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("duplicateDirrectOverriddenCallables.kt")
|
||||
public void testDuplicateDirrectOverriddenCallables() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/duplicateDirrectOverriddenCallables.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("emptyLhsClassLiterals.kt")
|
||||
public void testEmptyLhsClassLiterals() throws Exception {
|
||||
@@ -345,6 +351,24 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
|
||||
runTest("compiler/testData/diagnostics/tests/ExternalAndAbstract.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("falseNegativeDuplicateDefaultValues1.kt")
|
||||
public void testFalseNegativeDuplicateDefaultValues1() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/falseNegativeDuplicateDefaultValues1.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("falseNegativeDuplicateDefaultValues2.kt")
|
||||
public void testFalseNegativeDuplicateDefaultValues2() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/falseNegativeDuplicateDefaultValues2.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("falseNegativeDuplicateDefaultValues3.kt")
|
||||
public void testFalseNegativeDuplicateDefaultValues3() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/falseNegativeDuplicateDefaultValues3.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("fileDependencyRecursion.kt")
|
||||
public void testFileDependencyRecursion() throws Exception {
|
||||
@@ -729,6 +753,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
|
||||
runTest("compiler/testData/diagnostics/tests/MultipleBounds.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("multipleDefaultsNoSource.kt")
|
||||
public void testMultipleDefaultsNoSource() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/multipleDefaultsNoSource.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("NamedFunctionTypeParameterInSupertype.kt")
|
||||
public void testNamedFunctionTypeParameterInSupertype() throws Exception {
|
||||
|
||||
-7
@@ -872,13 +872,6 @@ object DIAGNOSTICS_LIST : DiagnosticList("FirErrors") {
|
||||
parameter<Name>("containingClassName")
|
||||
}
|
||||
|
||||
val MULTIPLE_DEFAULTS_INHERITED_FROM_SUPERTYPES by error<KtElement>(PositioningStrategy.DECLARATION_SIGNATURE_OR_DEFAULT) {
|
||||
parameter<FirValueParameterSymbol>("valueParameter")
|
||||
}
|
||||
val MULTIPLE_DEFAULTS_INHERITED_FROM_SUPERTYPES_WHEN_NO_EXPLICIT_OVERRIDE by error<KtElement>(PositioningStrategy.DECLARATION_NAME) {
|
||||
parameter<FirValueParameterSymbol>("valueParameter")
|
||||
}
|
||||
|
||||
val TYPEALIAS_EXPANDS_TO_ARRAY_OF_NOTHINGS by error<KtElement> {
|
||||
parameter<ConeKotlinType>("type")
|
||||
}
|
||||
|
||||
@@ -484,8 +484,6 @@ object FirErrors {
|
||||
val DATA_CLASS_OVERRIDE_DEFAULT_VALUES by error2<KtElement, FirCallableSymbol<*>, FirClassSymbol<*>>(SourceElementPositioningStrategies.DATA_MODIFIER)
|
||||
val CANNOT_WEAKEN_ACCESS_PRIVILEGE by error3<KtModifierListOwner, Visibility, FirCallableSymbol<*>, Name>(SourceElementPositioningStrategies.VISIBILITY_MODIFIER)
|
||||
val CANNOT_CHANGE_ACCESS_PRIVILEGE by error3<KtModifierListOwner, Visibility, FirCallableSymbol<*>, Name>(SourceElementPositioningStrategies.VISIBILITY_MODIFIER)
|
||||
val MULTIPLE_DEFAULTS_INHERITED_FROM_SUPERTYPES by error1<KtElement, FirValueParameterSymbol>(SourceElementPositioningStrategies.DECLARATION_SIGNATURE_OR_DEFAULT)
|
||||
val MULTIPLE_DEFAULTS_INHERITED_FROM_SUPERTYPES_WHEN_NO_EXPLICIT_OVERRIDE by error1<KtElement, FirValueParameterSymbol>(SourceElementPositioningStrategies.DECLARATION_NAME)
|
||||
val TYPEALIAS_EXPANDS_TO_ARRAY_OF_NOTHINGS by error1<KtElement, ConeKotlinType>()
|
||||
val OVERRIDING_FINAL_MEMBER by error2<KtNamedDeclaration, FirCallableSymbol<*>, Name>(SourceElementPositioningStrategies.OVERRIDE_MODIFIER)
|
||||
val RETURN_TYPE_MISMATCH_ON_INHERITANCE by error2<KtClassOrObject, FirCallableSymbol<*>, FirCallableSymbol<*>>(SourceElementPositioningStrategies.DECLARATION_NAME)
|
||||
|
||||
-1
@@ -129,7 +129,6 @@ object CommonDeclarationCheckers : DeclarationCheckers() {
|
||||
FirOuterClassArgumentsRequiredChecker,
|
||||
FirPropertyInitializationChecker,
|
||||
FirDelegateFieldTypeMismatchChecker,
|
||||
FirMultipleDefaultsInheritedFromSupertypesChecker,
|
||||
FirFiniteBoundRestrictionChecker,
|
||||
)
|
||||
|
||||
|
||||
-60
@@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.fir.analysis.checkers.declaration
|
||||
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticReporter
|
||||
import org.jetbrains.kotlin.diagnostics.reportOn
|
||||
import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext
|
||||
import org.jetbrains.kotlin.fir.analysis.checkers.directOverriddenFunctions
|
||||
import org.jetbrains.kotlin.fir.analysis.checkers.unsubstitutedScope
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors
|
||||
import org.jetbrains.kotlin.fir.declarations.FirRegularClass
|
||||
import org.jetbrains.kotlin.fir.isSubstitutionOrIntersectionOverride
|
||||
import org.jetbrains.kotlin.fir.scopes.processAllFunctions
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirIntersectionOverrideFunctionSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.UnsafeCastFunction
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.castAll
|
||||
|
||||
object FirMultipleDefaultsInheritedFromSupertypesChecker : FirRegularClassChecker() {
|
||||
override fun check(declaration: FirRegularClass, context: CheckerContext, reporter: DiagnosticReporter) {
|
||||
declaration.unsubstitutedScope(context).processAllFunctions {
|
||||
checkFunction(declaration, it, context, reporter)
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkFunction(
|
||||
declaration: FirRegularClass,
|
||||
function: FirNamedFunctionSymbol,
|
||||
context: CheckerContext,
|
||||
reporter: DiagnosticReporter,
|
||||
) {
|
||||
@OptIn(UnsafeCastFunction::class)
|
||||
val overriddenFunctions = when (function) {
|
||||
is FirIntersectionOverrideFunctionSymbol -> function.intersections.castAll<FirFunctionSymbol<*>>()
|
||||
else -> function.directOverriddenFunctions(context)
|
||||
}
|
||||
|
||||
for ((index, parameter) in function.valueParameterSymbols.withIndex()) {
|
||||
val basesWithDefaultValues = overriddenFunctions.count { it.valueParameterSymbols[index].hasDefaultValue }
|
||||
|
||||
when {
|
||||
basesWithDefaultValues <= 1 -> {
|
||||
continue
|
||||
}
|
||||
function.isSubstitutionOrIntersectionOverride -> reporter.reportOn(
|
||||
declaration.source, FirErrors.MULTIPLE_DEFAULTS_INHERITED_FROM_SUPERTYPES_WHEN_NO_EXPLICIT_OVERRIDE,
|
||||
parameter, context,
|
||||
)
|
||||
else -> reporter.reportOn(
|
||||
parameter.source, FirErrors.MULTIPLE_DEFAULTS_INHERITED_FROM_SUPERTYPES,
|
||||
parameter, context,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-6
@@ -359,8 +359,6 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.MISSING_VAL_ON_AN
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.MODIFIER_FORM_FOR_NON_BUILT_IN_SUSPEND
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.MODIFIER_FORM_FOR_NON_BUILT_IN_SUSPEND_FUN
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.MULTIPLE_ARGUMENTS_APPLICABLE_FOR_CONTEXT_RECEIVER
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.MULTIPLE_DEFAULTS_INHERITED_FROM_SUPERTYPES
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.MULTIPLE_DEFAULTS_INHERITED_FROM_SUPERTYPES_WHEN_NO_EXPLICIT_OVERRIDE
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.MULTIPLE_VARARG_PARAMETERS
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.MULTI_FIELD_VALUE_CLASS_PRIMARY_CONSTRUCTOR_DEFAULT_PARAMETER
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.MUST_BE_INITIALIZED
|
||||
@@ -1458,10 +1456,6 @@ object FirErrorsDefaultMessages : BaseDiagnosticRendererFactory() {
|
||||
FQ_NAMES_IN_TYPES
|
||||
)
|
||||
|
||||
val multipleDefaultsMessage = "More than one overridden descriptor declares a default value for ''{0}''. As the compiler can not make sure these values agree, this is not allowed."
|
||||
map.put(MULTIPLE_DEFAULTS_INHERITED_FROM_SUPERTYPES, multipleDefaultsMessage, SYMBOL)
|
||||
map.put(MULTIPLE_DEFAULTS_INHERITED_FROM_SUPERTYPES_WHEN_NO_EXPLICIT_OVERRIDE, multipleDefaultsMessage, SYMBOL)
|
||||
|
||||
map.put(TYPEALIAS_EXPANDS_TO_ARRAY_OF_NOTHINGS, "Type alias expanded to malformed type ''{0}''", RENDER_TYPE)
|
||||
|
||||
map.put(OVERRIDING_FINAL_MEMBER, "''{0}'' in ''{1}'' is final and cannot be overridden", DECLARATION_NAME, TO_STRING)
|
||||
|
||||
+1
-2
@@ -1,5 +1,4 @@
|
||||
// IGNORE_BACKEND_K1: JS, JS_IR, JS_IR_ES6
|
||||
// IGNORE_BACKEND_K2: ANY
|
||||
// IGNORE_BACKEND: JS, JS_IR, JS_IR_ES6
|
||||
|
||||
// The code in this test should be prohibited in the frontend, see KT-36188.
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// IGNORE_BACKEND_K1: JS, JS_IR, JS_IR_ES6
|
||||
// IGNORE_BACKEND_K2: ANY
|
||||
// IGNORE_BACKEND: JS, JS_IR, JS_IR_ES6
|
||||
// !JVM_DEFAULT_MODE: all
|
||||
// JVM_TARGET: 1.8
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// IGNORE_BACKEND: JS
|
||||
// IGNORE_BACKEND_K2: ANY
|
||||
|
||||
// Test for KT-36188 bug compatibility between non-IR and IR backends
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// IGNORE_BACKEND: JS
|
||||
// IGNORE_BACKEND_K2: ANY
|
||||
|
||||
// Test for KT-36188 bug compatibility between non-IR and IR backends
|
||||
|
||||
|
||||
+2
-2
@@ -17,10 +17,10 @@ interface B {
|
||||
fun foo(@An a: @An Int = @An 2)
|
||||
}
|
||||
|
||||
<!MULTIPLE_DEFAULTS_INHERITED_FROM_SUPERTYPES_WHEN_NO_EXPLICIT_OVERRIDE("@An() a: @R|An|() Int = ...")!>class AB1<!> : A, B
|
||||
class AB1 : A, B
|
||||
|
||||
@An
|
||||
class AB2 : A, B {
|
||||
@An
|
||||
override fun foo(<!MULTIPLE_DEFAULTS_INHERITED_FROM_SUPERTYPES("@An() a: @R|An|() Int")!>@An a: @An Int<!>) {}
|
||||
override fun foo(@An a: @An Int) {}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// FIR_IDENTICAL
|
||||
// ISSUE: KT-61095
|
||||
|
||||
package org.example
|
||||
|
||||
interface Base<P> {
|
||||
fun child(props: Int = 10)
|
||||
}
|
||||
|
||||
interface Intermediate<P> : Base<P>
|
||||
|
||||
class Implementation<P>() : Intermediate<P>, Base<P> {
|
||||
override fun child(props: Int) {}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// FIR_IDENTICAL
|
||||
// ISSUE: KT-36188
|
||||
|
||||
interface SomeRandomBase<K> {
|
||||
fun child(props: Int = 20)
|
||||
}
|
||||
|
||||
interface SomeRandomOverride<J> : SomeRandomBase<J>
|
||||
|
||||
open class Keker<P> {
|
||||
open fun child(props: Int = 10) {}
|
||||
}
|
||||
|
||||
class Implementation<P>() : Keker<P>(), SomeRandomOverride<P> {
|
||||
override fun child(props: Int) {}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// FIR_IDENTICAL
|
||||
// ISSUE: KT-36188
|
||||
|
||||
interface SomeRandomBase<K> {
|
||||
fun child(props: Int = 20)
|
||||
}
|
||||
|
||||
interface SomeRandomOverride<J> : SomeRandomBase<J> {
|
||||
override fun child(props: Int) {}
|
||||
}
|
||||
|
||||
open class Keker<P> {
|
||||
open fun child(props: Int = 10) {}
|
||||
}
|
||||
|
||||
class Implementation<P>() : Keker<P>(), SomeRandomOverride<P> {
|
||||
override fun child(props: Int) {}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// FIR_IDENTICAL
|
||||
// ISSUE: KT-36188
|
||||
|
||||
interface SomeRandomBase<K> {
|
||||
fun child(props: Int = 20)
|
||||
}
|
||||
|
||||
interface SomeRandomOverride<J> : SomeRandomBase<J> {
|
||||
override abstract fun child(props: Int)
|
||||
}
|
||||
|
||||
open class Keker<P> {
|
||||
open fun child(props: Int = 10) {}
|
||||
}
|
||||
|
||||
class Implementation<P>() : Keker<P>(), SomeRandomOverride<P> {
|
||||
override fun child(props: Int) {}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// ISSUE: KT-61095
|
||||
|
||||
interface X {
|
||||
fun foo(a : Int = 1) {}
|
||||
}
|
||||
|
||||
interface Y {
|
||||
fun foo(a : Int = 1) {}
|
||||
}
|
||||
|
||||
object YImpl : Y
|
||||
|
||||
<!DELEGATED_MEMBER_HIDES_SUPERTYPE_OVERRIDE!>class Z1<!> : X, Y by YImpl {}
|
||||
<!DELEGATED_MEMBER_HIDES_SUPERTYPE_OVERRIDE!>object Z1O<!> : X, Y by YImpl {}
|
||||
@@ -0,0 +1,14 @@
|
||||
// ISSUE: KT-61095
|
||||
|
||||
interface X {
|
||||
fun foo(a : Int = 1) {}
|
||||
}
|
||||
|
||||
interface Y {
|
||||
fun foo(a : Int = 1) {}
|
||||
}
|
||||
|
||||
object YImpl : Y
|
||||
|
||||
<!DELEGATED_MEMBER_HIDES_SUPERTYPE_OVERRIDE, MANY_IMPL_MEMBER_NOT_IMPLEMENTED, MULTIPLE_DEFAULTS_INHERITED_FROM_SUPERTYPES_WHEN_NO_EXPLICIT_OVERRIDE!>class Z1<!> : X, Y by YImpl {}
|
||||
<!DELEGATED_MEMBER_HIDES_SUPERTYPE_OVERRIDE, MANY_IMPL_MEMBER_NOT_IMPLEMENTED, MULTIPLE_DEFAULTS_INHERITED_FROM_SUPERTYPES_WHEN_NO_EXPLICIT_OVERRIDE!>object Z1O<!> : X, Y by YImpl {}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
interface X {
|
||||
fun foo(a : Int = 1)
|
||||
}
|
||||
|
||||
interface Y {
|
||||
fun foo(a : Int = 1)
|
||||
}
|
||||
|
||||
class Z : X, Y {
|
||||
override fun foo(a : Int) {}
|
||||
}
|
||||
|
||||
object ZO : X, Y {
|
||||
override fun foo(a : Int) {}
|
||||
}
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
// FIR_IDENTICAL
|
||||
interface X {
|
||||
fun foo(a : Int = 1)
|
||||
}
|
||||
|
||||
Vendored
-15
@@ -1,15 +0,0 @@
|
||||
interface X {
|
||||
fun foo(a : Int = 1)
|
||||
}
|
||||
|
||||
interface Y {
|
||||
fun foo(a : Int = 1)
|
||||
}
|
||||
|
||||
class Z : X, Y {
|
||||
fun <!VIRTUAL_MEMBER_HIDDEN!>foo<!>(<!MULTIPLE_DEFAULTS_INHERITED_FROM_SUPERTYPES!>a : Int<!>) {}
|
||||
}
|
||||
|
||||
object ZO : X, Y {
|
||||
fun <!VIRTUAL_MEMBER_HIDDEN!>foo<!>(<!MULTIPLE_DEFAULTS_INHERITED_FROM_SUPERTYPES!>a : Int<!>) {}
|
||||
}
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
interface X {
|
||||
fun foo(a : Int = 1)
|
||||
}
|
||||
|
||||
+1
-1
@@ -11,4 +11,4 @@ interface C {
|
||||
}
|
||||
|
||||
// TODO DIFFERENT_NAMES_FOR_THE_SAME_PARAMETER_IN_SUPERTYPES reported twice
|
||||
<!MULTIPLE_DEFAULTS_INHERITED_FROM_SUPERTYPES_WHEN_NO_EXPLICIT_OVERRIDE!>class Z<!> : A, B(), C
|
||||
class Z : A, B(), C
|
||||
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
interface X {
|
||||
fun foo(a : Int = 1)
|
||||
}
|
||||
|
||||
interface Y {
|
||||
fun foo(a : Int = 1)
|
||||
}
|
||||
|
||||
<!ABSTRACT_MEMBER_NOT_IMPLEMENTED!>class Z1<!> : X, Y {} // BUG
|
||||
<!ABSTRACT_MEMBER_NOT_IMPLEMENTED!>object Z1O<!> : X, Y {} // BUG
|
||||
Vendored
-1
@@ -1,4 +1,3 @@
|
||||
// FIR_IDENTICAL
|
||||
interface X {
|
||||
fun foo(a : Int = 1)
|
||||
}
|
||||
|
||||
Generated
+30
@@ -303,6 +303,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
runTest("compiler/testData/diagnostics/tests/Dollar.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("duplicateDirrectOverriddenCallables.kt")
|
||||
public void testDuplicateDirrectOverriddenCallables() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/duplicateDirrectOverriddenCallables.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("emptyLhsClassLiterals.kt")
|
||||
public void testEmptyLhsClassLiterals() throws Exception {
|
||||
@@ -345,6 +351,24 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
runTest("compiler/testData/diagnostics/tests/ExternalAndAbstract.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("falseNegativeDuplicateDefaultValues1.kt")
|
||||
public void testFalseNegativeDuplicateDefaultValues1() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/falseNegativeDuplicateDefaultValues1.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("falseNegativeDuplicateDefaultValues2.kt")
|
||||
public void testFalseNegativeDuplicateDefaultValues2() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/falseNegativeDuplicateDefaultValues2.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("falseNegativeDuplicateDefaultValues3.kt")
|
||||
public void testFalseNegativeDuplicateDefaultValues3() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/falseNegativeDuplicateDefaultValues3.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("fileDependencyRecursion.kt")
|
||||
public void testFileDependencyRecursion() throws Exception {
|
||||
@@ -729,6 +753,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
runTest("compiler/testData/diagnostics/tests/MultipleBounds.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("multipleDefaultsNoSource.kt")
|
||||
public void testMultipleDefaultsNoSource() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/multipleDefaultsNoSource.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("NamedFunctionTypeParameterInSupertype.kt")
|
||||
public void testNamedFunctionTypeParameterInSupertype() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user