[FE 1.0] Refactoring: replace defensive NonPrivateCallableAdded with Unknown
Motivation: I'm going to drop NonPrivateCallableAdded (KT-62655) in the next commits. But I don't want to change the existing logic when I drop it. That's why I have to introduce the "Unknown" case
This commit is contained in:
@@ -842,6 +842,8 @@ public interface Errors {
|
|||||||
DiagnosticFactory3.create(WARNING, DECLARATION_NAME);
|
DiagnosticFactory3.create(WARNING, DECLARATION_NAME);
|
||||||
DiagnosticFactory1<KtCallableDeclaration, K1ExpectActualMemberDiff<CallableMemberDescriptor, ClassDescriptor>>
|
DiagnosticFactory1<KtCallableDeclaration, K1ExpectActualMemberDiff<CallableMemberDescriptor, ClassDescriptor>>
|
||||||
NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING = DiagnosticFactory1.create(WARNING, DECLARATION_NAME);
|
NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING = DiagnosticFactory1.create(WARNING, DECLARATION_NAME);
|
||||||
|
DiagnosticFactory1<KtCallableDeclaration, K1ExpectActualMemberDiff<CallableMemberDescriptor, ClassDescriptor>>
|
||||||
|
UNKNOWN_PROBLEM_DURING_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING = DiagnosticFactory1.create(WARNING, DECLARATION_NAME);
|
||||||
DiagnosticFactory1<KtCallableDeclaration, K1ExpectActualMemberDiff<CallableMemberDescriptor, ClassDescriptor>>
|
DiagnosticFactory1<KtCallableDeclaration, K1ExpectActualMemberDiff<CallableMemberDescriptor, ClassDescriptor>>
|
||||||
RETURN_TYPE_CHANGED_IN_NON_FINAL_EXPECT_CLASSIFIER_ACTUALIZATION_WARNING = DiagnosticFactory1.create(WARNING, DECLARATION_RETURN_TYPE);
|
RETURN_TYPE_CHANGED_IN_NON_FINAL_EXPECT_CLASSIFIER_ACTUALIZATION_WARNING = DiagnosticFactory1.create(WARNING, DECLARATION_RETURN_TYPE);
|
||||||
DiagnosticFactory1<KtCallableDeclaration, K1ExpectActualMemberDiff<CallableMemberDescriptor, ClassDescriptor>>
|
DiagnosticFactory1<KtCallableDeclaration, K1ExpectActualMemberDiff<CallableMemberDescriptor, ClassDescriptor>>
|
||||||
|
|||||||
+3
@@ -406,6 +406,9 @@ public class DefaultErrorMessages {
|
|||||||
MAP.put(NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING,
|
MAP.put(NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING,
|
||||||
"{0}. This warning will become an error in future releases. Also see https://youtrack.jetbrains.com/issue/KT-22841 for more details",
|
"{0}. This warning will become an error in future releases. Also see https://youtrack.jetbrains.com/issue/KT-22841 for more details",
|
||||||
ExpectActualScopeDiffRenderer.INSTANCE);
|
ExpectActualScopeDiffRenderer.INSTANCE);
|
||||||
|
MAP.put(UNKNOWN_PROBLEM_DURING_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING,
|
||||||
|
"{0}. This warning will become an error in future releases. Also see https://youtrack.jetbrains.com/issue/KT-22841 for more details",
|
||||||
|
ExpectActualScopeDiffRenderer.INSTANCE);
|
||||||
MAP.put(RETURN_TYPE_CHANGED_IN_NON_FINAL_EXPECT_CLASSIFIER_ACTUALIZATION_WARNING,
|
MAP.put(RETURN_TYPE_CHANGED_IN_NON_FINAL_EXPECT_CLASSIFIER_ACTUALIZATION_WARNING,
|
||||||
"{0}. This warning will become an error in future releases. Also see https://youtrack.jetbrains.com/issue/KT-22841 for more details",
|
"{0}. This warning will become an error in future releases. Also see https://youtrack.jetbrains.com/issue/KT-22841 for more details",
|
||||||
ExpectActualScopeDiffRenderer.INSTANCE);
|
ExpectActualScopeDiffRenderer.INSTANCE);
|
||||||
|
|||||||
+5
-3
@@ -175,9 +175,9 @@ private fun calculateExpectActualScopeDiff(
|
|||||||
// If toMemberDiffKind returns null then some Kotlin invariants described in toMemberDiffKind no longer hold.
|
// If toMemberDiffKind returns null then some Kotlin invariants described in toMemberDiffKind no longer hold.
|
||||||
// We can't throw exception here because it would crash the compilation.
|
// We can't throw exception here because it would crash the compilation.
|
||||||
// Those broken invariants just needs to be reported by other checkers.
|
// Those broken invariants just needs to be reported by other checkers.
|
||||||
// But it's better to report some error (ExpectActualMemberDiff.Kind.NonPrivateCallableAdded in our case) to
|
// But it's better to report K1ExpectActualMemberDiff.Kind.Unknown to make sure that we don't have missed
|
||||||
// make sure that we don't have missed compilation errors if the invariants change
|
// compilation errors if the invariants change
|
||||||
?: K1ExpectActualMemberDiff.Kind.NonPrivateCallableAdded
|
?: K1ExpectActualMemberDiff.Kind.Unknown
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -227,6 +227,8 @@ private fun BindingTrace.reportIfPossible(diff: K1ExpectActualMemberDiff<Callabl
|
|||||||
Errors.VARARG_CHANGED_IN_NON_FINAL_EXPECT_CLASSIFIER_ACTUALIZATION_WARNING.on(psi, diff)
|
Errors.VARARG_CHANGED_IN_NON_FINAL_EXPECT_CLASSIFIER_ACTUALIZATION_WARNING.on(psi, diff)
|
||||||
K1ExpectActualMemberDiff.Kind.TypeParameterNamesChangedInOverride ->
|
K1ExpectActualMemberDiff.Kind.TypeParameterNamesChangedInOverride ->
|
||||||
Errors.TYPE_PARAMETER_NAMES_CHANGED_IN_NON_FINAL_EXPECT_CLASSIFIER_ACTUALIZATION_WARNING.on(psi, diff)
|
Errors.TYPE_PARAMETER_NAMES_CHANGED_IN_NON_FINAL_EXPECT_CLASSIFIER_ACTUALIZATION_WARNING.on(psi, diff)
|
||||||
|
K1ExpectActualMemberDiff.Kind.Unknown ->
|
||||||
|
Errors.UNKNOWN_PROBLEM_DURING_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING.on(psi, diff)
|
||||||
}
|
}
|
||||||
report(diagnostic)
|
report(diagnostic)
|
||||||
}
|
}
|
||||||
|
|||||||
+4
@@ -53,6 +53,10 @@ data class K1ExpectActualMemberDiff<out M, out C>(val kind: Kind, val actualMemb
|
|||||||
"{0}: the type parameter names of this member must be the same in the expect class and the actual class. " +
|
"{0}: the type parameter names of this member must be the same in the expect class and the actual class. " +
|
||||||
"This error happens because the expect class ''{1}'' is non-final"
|
"This error happens because the expect class ''{1}'' is non-final"
|
||||||
),
|
),
|
||||||
|
Unknown(
|
||||||
|
"{0}: normally, this error should never happen. Please report to https://kotl.in/issue. " +
|
||||||
|
"This error happens because the expect class ''{1}'' is non-final"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
@@ -53,6 +53,10 @@ data class ExpectActualMemberDiff<out M, out C>(val kind: Kind, val actualMember
|
|||||||
"{0}: the type parameter names of this member must be the same in the expect class and the actual class. " +
|
"{0}: the type parameter names of this member must be the same in the expect class and the actual class. " +
|
||||||
"This error happens because the expect class ''{1}'' is non-final"
|
"This error happens because the expect class ''{1}'' is non-final"
|
||||||
),
|
),
|
||||||
|
Unknown(
|
||||||
|
"{0}: normally, this error should never happen. Please report to https://kotl.in/issue. " +
|
||||||
|
"This error happens because the expect class ''{1}'' is non-final"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user