Skip to content

Commit 40cf415

Browse files
nikitabobkoSpace Team
authored and
Space Team
committed
[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
1 parent 4408d89 commit 40cf415

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -845,6 +845,8 @@ public interface Errors {
845845
DiagnosticFactory3.create(WARNING, DECLARATION_NAME);
846846
DiagnosticFactory1<KtCallableDeclaration, ExpectActualMemberDiff<CallableMemberDescriptor, ClassDescriptor>>
847847
NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING = DiagnosticFactory1.create(WARNING, DECLARATION_NAME);
848+
DiagnosticFactory1<KtCallableDeclaration, ExpectActualMemberDiff<CallableMemberDescriptor, ClassDescriptor>>
849+
UNKNOWN_PROBLEM_DURING_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING = DiagnosticFactory1.create(WARNING, DECLARATION_NAME);
848850
DiagnosticFactory1<KtCallableDeclaration, ExpectActualMemberDiff<CallableMemberDescriptor, ClassDescriptor>>
849851
RETURN_TYPE_CHANGED_IN_NON_FINAL_EXPECT_CLASSIFIER_ACTUALIZATION_WARNING = DiagnosticFactory1.create(WARNING, DECLARATION_RETURN_TYPE);
850852
DiagnosticFactory1<KtCallableDeclaration, ExpectActualMemberDiff<CallableMemberDescriptor, ClassDescriptor>>

compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,9 @@ public static DiagnosticRenderer getRendererForDiagnostic(@NotNull UnboundDiagno
406406
MAP.put(NON_ACTUAL_MEMBER_DECLARED_IN_EXPECT_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING,
407407
"{0}. This warning will become an error in future releases. Also see https://youtrack.jetbrains.com/issue/KT-22841 for more details",
408408
ExpectActualScopeDiffRenderer.INSTANCE);
409+
MAP.put(UNKNOWN_PROBLEM_DURING_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING,
410+
"{0}. This warning will become an error in future releases. Also see https://youtrack.jetbrains.com/issue/KT-22841 for more details",
411+
ExpectActualScopeDiffRenderer.INSTANCE);
409412
MAP.put(RETURN_TYPE_CHANGED_IN_NON_FINAL_EXPECT_CLASSIFIER_ACTUALIZATION_WARNING,
410413
"{0}. This warning will become an error in future releases. Also see https://youtrack.jetbrains.com/issue/KT-22841 for more details",
411414
ExpectActualScopeDiffRenderer.INSTANCE);

compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/ActualClassifierMustHasTheSameMembersAsNonFinalExpectClassifierChecker.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,9 @@ private fun calculateExpectActualScopeDiff(
171171
// If toMemberDiffKind returns null then some Kotlin invariants described in toMemberDiffKind no longer hold.
172172
// We can't throw exception here because it would crash the compilation.
173173
// Those broken invariants just needs to be reported by other checkers.
174-
// But it's better to report some error (ExpectActualMemberDiff.Kind.NonPrivateCallableAdded in our case) to
175-
// make sure that we don't have missed compilation errors if the invariants change
176-
?: ExpectActualMemberDiff.Kind.NonPrivateCallableAdded
174+
// But it's better to report ExpectActualMemberDiff.Kind.Unknown to make sure that we don't have missed
175+
// compilation errors if the invariants change
176+
?: ExpectActualMemberDiff.Kind.Unknown
177177
}
178178
}
179179
}
@@ -223,6 +223,8 @@ private fun BindingTrace.reportIfPossible(diff: ExpectActualMemberDiff<CallableM
223223
Errors.VARARG_CHANGED_IN_NON_FINAL_EXPECT_CLASSIFIER_ACTUALIZATION_WARNING.on(psi, diff)
224224
ExpectActualMemberDiff.Kind.TypeParameterNamesChangedInOverride ->
225225
Errors.TYPE_PARAMETER_NAMES_CHANGED_IN_NON_FINAL_EXPECT_CLASSIFIER_ACTUALIZATION_WARNING.on(psi, diff)
226+
ExpectActualMemberDiff.Kind.Unknown ->
227+
Errors.UNKNOWN_PROBLEM_DURING_NON_FINAL_CLASSIFIER_ACTUALIZATION_WARNING.on(psi, diff)
226228
}
227229
report(diagnostic)
228230
}

core/compiler.common/src/org/jetbrains/kotlin/resolve/multiplatform/ExpectActualMemberDiff.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ data class ExpectActualMemberDiff<out M, out C>(val kind: Kind, val actualMember
5353
"{0}: the type parameter names of this member must be the same in the expect class and the actual class. " +
5454
"This error happens because the expect class ''{1}'' is non-final"
5555
),
56+
Unknown(
57+
"{0}: normally, this error should never happen. Please report to https://kotl.in/issue. " +
58+
"This error happens because the expect class ''{1}'' is non-final"
59+
)
5660
}
5761
}
5862

0 commit comments

Comments
 (0)