diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java index 6938a40bd34..97757b3ac81 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java @@ -99,8 +99,10 @@ public interface Errors { DiagnosticFactory1 REDUNDANT_PROJECTION = DiagnosticFactory1.create(WARNING, VARIANCE_IN_PROJECTION); DiagnosticFactory1 TYPE_VARIANCE_CONFLICT = DiagnosticFactory1.create(ERROR, DECLARATION_SIGNATURE_OR_DEFAULT); - DiagnosticFactory1 FINITE_BOUNDS_VIOLATION = DiagnosticFactory1.create(ERROR); - DiagnosticFactory1 EXPANSIVE_INHERITANCE = DiagnosticFactory1.create(ERROR); + DiagnosticFactory0 FINITE_BOUNDS_VIOLATION = DiagnosticFactory0.create(ERROR); + DiagnosticFactory1 FINITE_BOUNDS_VIOLATION_IN_JAVA = DiagnosticFactory1.create(WARNING); + DiagnosticFactory0 EXPANSIVE_INHERITANCE = DiagnosticFactory0.create(ERROR); + DiagnosticFactory1 EXPANSIVE_INHERITANCE_IN_JAVA = DiagnosticFactory1.create(WARNING); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java index 27d037bc791..1486a57def9 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java @@ -501,8 +501,10 @@ public class DefaultErrorMessages { } }); - MAP.put(FINITE_BOUNDS_VIOLATION, "{0}", STRING); - MAP.put(EXPANSIVE_INHERITANCE, "{0}", STRING); + MAP.put(FINITE_BOUNDS_VIOLATION, "Type argument is not within its bounds (violation of Finite Bound Restriction)"); + MAP.put(FINITE_BOUNDS_VIOLATION_IN_JAVA, "Violation of Finite Bound Restriction for {0}", STRING); + MAP.put(EXPANSIVE_INHERITANCE, "Type argument is not within its bounds (violation of Non-Expansive Inheritance Restriction)"); + MAP.put(EXPANSIVE_INHERITANCE_IN_JAVA, "Violation of Non-Expansive Inheritance Restriction for {0}", STRING); MAP.put(REDUNDANT_PROJECTION, "Projection is redundant: the corresponding type parameter of {0} has the same variance", NAME); MAP.put(CONFLICTING_PROJECTION, "Projection is conflicting with variance of the corresponding type parameter of {0}. Remove the projection or replace it with ''*''", NAME); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/FiniteBoundRestrictionChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/FiniteBoundRestrictionChecker.kt index f67279fbbb6..2a6cd4d7873 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/FiniteBoundRestrictionChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/FiniteBoundRestrictionChecker.kt @@ -51,15 +51,15 @@ public object FiniteBoundRestrictionChecker { for (typeParameter in typeConstructor.parameters) { if (typeParameter in problemNodes) { val element = DescriptorToSourceUtils.descriptorToDeclaration(typeParameter) ?: declaration - diagnosticHolder.report(Errors.FINITE_BOUNDS_VIOLATION.on(element, "Type argument is not within its bounds (violation of Finite Bound Restriction)")) + diagnosticHolder.report(Errors.FINITE_BOUNDS_VIOLATION.on(element)) return } } if (problemNodes.any { it.source != SourceElement.NO_SOURCE }) return - val superTypeFqNames = problemNodes.map { it.containingDeclaration }.map { it.fqNameUnsafe.asString() }.toSortedSet() - diagnosticHolder.report(Errors.FINITE_BOUNDS_VIOLATION.on(declaration, "Violation of Finite Bound Restriction for supertypes: " + superTypeFqNames.joinToString(", "))) + val typeFqNames = problemNodes.map { it.containingDeclaration }.map { it.fqNameUnsafe.asString() }.toSortedSet() + diagnosticHolder.report(Errors.FINITE_BOUNDS_VIOLATION_IN_JAVA.on(declaration, typeFqNames.joinToString(", "))) } private class GraphBuilder(val typeConstructor: TypeConstructor) { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/NonExpansiveInheritanceRestrictionChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/NonExpansiveInheritanceRestrictionChecker.kt index b74617e78e6..47af045ed5f 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/NonExpansiveInheritanceRestrictionChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/NonExpansiveInheritanceRestrictionChecker.kt @@ -52,15 +52,15 @@ public object NonExpansiveInheritanceRestrictionChecker { for (typeParameter in typeConstructor.parameters) { if (typeParameter in problemNodes) { val element = DescriptorToSourceUtils.descriptorToDeclaration(typeParameter) ?: declaration - diagnosticHolder.report(Errors.EXPANSIVE_INHERITANCE.on(element, "Type argument is not within its bounds (violation of Non-Expansive Inheritance Restriction")) + diagnosticHolder.report(Errors.EXPANSIVE_INHERITANCE.on(element)) return } } if (problemNodes.any { it.source != SourceElement.NO_SOURCE }) return - val superTypeFqNames = problemNodes.map { it.containingDeclaration }.map { it.fqNameUnsafe.asString() }.toSortedSet() - diagnosticHolder.report(Errors.EXPANSIVE_INHERITANCE.on(declaration, "Violation of Non-Expansive Inheritance Restriction for supertypes: " + superTypeFqNames.joinToString(", "))) + val typeFqNames = problemNodes.map { it.containingDeclaration }.map { it.fqNameUnsafe.asString() }.toSortedSet() + diagnosticHolder.report(Errors.EXPANSIVE_INHERITANCE_IN_JAVA.on(declaration, typeFqNames.joinToString(", "))) } private class GraphBuilder(val typeConstructor: TypeConstructor) { diff --git a/compiler/testData/diagnostics/tests/declarationChecks/finiteBoundRestriction/JavaSuperType.kt b/compiler/testData/diagnostics/tests/declarationChecks/finiteBoundRestriction/JavaSuperType.kt index 8a144d2649b..4975f00c566 100644 --- a/compiler/testData/diagnostics/tests/declarationChecks/finiteBoundRestriction/JavaSuperType.kt +++ b/compiler/testData/diagnostics/tests/declarationChecks/finiteBoundRestriction/JavaSuperType.kt @@ -2,4 +2,4 @@ public class A {} // FILE: 1.kt -class B> \ No newline at end of file +class B> \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/declarationChecks/nonExpansiveInheritanceRestriction/JavaWithKotlin2.kt b/compiler/testData/diagnostics/tests/declarationChecks/nonExpansiveInheritanceRestriction/JavaWithKotlin2.kt index a5174b63a56..112724526b5 100644 --- a/compiler/testData/diagnostics/tests/declarationChecks/nonExpansiveInheritanceRestriction/JavaWithKotlin2.kt +++ b/compiler/testData/diagnostics/tests/declarationChecks/nonExpansiveInheritanceRestriction/JavaWithKotlin2.kt @@ -13,4 +13,4 @@ public interface C extends D> {} public interface P extends Q, C>> {} // FILE: 1.kt -interface P1 : P \ No newline at end of file +interface P1 : P \ No newline at end of file