Skip to content

Commit

Permalink
[FE 1.0] Refactoring: replace defensive NonPrivateCallableAdded with …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
nikitabobko authored and qodana-bot committed Oct 20, 2023
1 parent 4408d89 commit 40cf415
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,8 @@ public interface Errors {
DiagnosticFactory3.create(WARNING, DECLARATION_NAME);
DiagnosticFactory1<KtCallableDeclaration, ExpectActualMemberDiff<CallableMemberDescriptor, ClassDescriptor>>
NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING = DiagnosticFactory1.create(WARNING, DECLARATION_NAME);
DiagnosticFactory1<KtCallableDeclaration, ExpectActualMemberDiff<CallableMemberDescriptor, ClassDescriptor>>
UNKNOWN_PROBLEM_DURING_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING = DiagnosticFactory1.create(WARNING, DECLARATION_NAME);
DiagnosticFactory1<KtCallableDeclaration, ExpectActualMemberDiff<CallableMemberDescriptor, ClassDescriptor>>
RETURN_TYPE_CHANGED_IN_NON_FINAL_EXPECT_CLASSIFIER_ACTUALIZATION_WARNING = DiagnosticFactory1.create(WARNING, DECLARATION_RETURN_TYPE);
DiagnosticFactory1<KtCallableDeclaration, ExpectActualMemberDiff<CallableMemberDescriptor, ClassDescriptor>>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,9 @@ public static DiagnosticRenderer getRendererForDiagnostic(@NotNull UnboundDiagno
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",
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,
"{0}. This warning will become an error in future releases. Also see https://youtrack.jetbrains.com/issue/KT-22841 for more details",
ExpectActualScopeDiffRenderer.INSTANCE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,9 @@ private fun calculateExpectActualScopeDiff(
// 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.
// 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
// make sure that we don't have missed compilation errors if the invariants change
?: ExpectActualMemberDiff.Kind.NonPrivateCallableAdded
// But it's better to report ExpectActualMemberDiff.Kind.Unknown to make sure that we don't have missed
// compilation errors if the invariants change
?: ExpectActualMemberDiff.Kind.Unknown
}
}
}
Expand Down Expand Up @@ -223,6 +223,8 @@ private fun BindingTrace.reportIfPossible(diff: ExpectActualMemberDiff<CallableM
Errors.VARARG_CHANGED_IN_NON_FINAL_EXPECT_CLASSIFIER_ACTUALIZATION_WARNING.on(psi, diff)
ExpectActualMemberDiff.Kind.TypeParameterNamesChangedInOverride ->
Errors.TYPE_PARAMETER_NAMES_CHANGED_IN_NON_FINAL_EXPECT_CLASSIFIER_ACTUALIZATION_WARNING.on(psi, diff)
ExpectActualMemberDiff.Kind.Unknown ->
Errors.UNKNOWN_PROBLEM_DURING_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING.on(psi, diff)
}
report(diagnostic)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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. " +
"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"
)
}
}

Expand Down

0 comments on commit 40cf415

Please sign in to comment.