Fix diagnostic messages for properties.

Fix IDE tests.
Update quick fixes in IDE
(TODO: review new inheritance-related diagnostics with regards to quick fixes)
This commit is contained in:
Dmitry Petrov
2015-12-09 13:03:48 +03:00
parent 94bea54db3
commit 70c200d265
11 changed files with 61 additions and 31 deletions
@@ -99,13 +99,19 @@ public class IdeErrorMessages {
MAP.put(RETURN_TYPE_MISMATCH_ON_INHERITANCE, "<html>Return types of inherited members are incompatible:<br/>{0},<br/>{1}</html>",
DescriptorRenderer.HTML, DescriptorRenderer.HTML);
MAP.put(PROPERTY_TYPE_MISMATCH_ON_OVERRIDE, "<html>Var-property type is ''{0}'', which is not a type of overridden<br/>" +
MAP.put(PROPERTY_TYPE_MISMATCH_ON_OVERRIDE, "<html>Property type is ''{0}'', which is not a subtype type of overridden<br/>" +
"{1}</html>", HTML_RENDER_RETURN_TYPE, DescriptorRenderer.HTML);
MAP.put(PROPERTY_TYPE_MISMATCH_ON_INHERITANCE, "<html>Property types of inherited members are incompatible:<br/>{0},<br/>{1}</html>",
MAP.put(VAR_TYPE_MISMATCH_ON_OVERRIDE, "<html>Var-property type is ''{0}'', which is not a type of overridden<br/>" +
"{1}</html>", HTML_RENDER_RETURN_TYPE, DescriptorRenderer.HTML);
MAP.put(PROPERTY_TYPE_MISMATCH_ON_INHERITANCE, "<html>Types of inherited properties are incompatible:<br/>{0},<br/>{1}</html>",
DescriptorRenderer.HTML, DescriptorRenderer.HTML);
MAP.put(VAR_TYPE_MISMATCH_ON_INHERITANCE, "<html>Types of inherited var-properties do not match:<br/>{0},<br/>{1}</html>",
DescriptorRenderer.HTML, DescriptorRenderer.HTML);
MAP.put(VAR_OVERRIDDEN_BY_VAL, "<html>Val-property cannot override var-property<br />" +
"{1}</html>", DescriptorRenderer.HTML, DescriptorRenderer.HTML);
MAP.put(VAR_OVERRIDDEN_BY_VAL_BY_DELEGATION, "<html>Val-property cannot override var-property<br />" +
"{1}</html>", DescriptorRenderer.HTML, DescriptorRenderer.HTML);
MAP.put(ABSTRACT_MEMBER_NOT_IMPLEMENTED, "<html>{0} must be declared abstract or implement abstract member<br/>" +
"{1}</html>", RENDER_CLASS_OR_OBJECT,
@@ -215,6 +215,7 @@ public class QuickFixRegistrar : QuickFixContributor {
val changeVariableTypeFix = ChangeVariableTypeFix.createFactoryForPropertyOrReturnTypeMismatchOnOverride()
RETURN_TYPE_MISMATCH_ON_OVERRIDE.registerFactory(changeVariableTypeFix)
PROPERTY_TYPE_MISMATCH_ON_OVERRIDE.registerFactory(changeVariableTypeFix)
VAR_TYPE_MISMATCH_ON_OVERRIDE.registerFactory(changeVariableTypeFix)
COMPONENT_FUNCTION_RETURN_TYPE_MISMATCH.registerFactory(ChangeVariableTypeFix.createFactoryForComponentFunctionReturnTypeMismatch())
val changeFunctionReturnTypeFix = ChangeFunctionReturnTypeFix.createFactoryForChangingReturnTypeToUnit()
+3 -4
View File
@@ -1,12 +1,11 @@
interface Base {
fun foo(): Int
var bar: Int
val qux: Int
}
class Derived : Base {
override fun foo(): <error descr="[RETURN_TYPE_MISMATCH_ON_OVERRIDE] Return type of 'foo' is not a subtype of the return type of the overridden member 'public abstract fun foo(): kotlin.Int defined in Base'">String</error> = ""
override var bar: <error descr="[PROPERTY_TYPE_MISMATCH_ON_OVERRIDE] Type of 'bar' doesn't match the type of the overridden var-property 'public abstract var bar: kotlin.Int defined in Base'">String</error> = ""
override var bar: <error descr="[VAR_TYPE_MISMATCH_ON_OVERRIDE] Type of 'bar' doesn't match the type of the overridden var-property 'public abstract var bar: kotlin.Int defined in Base'">String</error> = ""
override val qux: <error descr="[PROPERTY_TYPE_MISMATCH_ON_OVERRIDE] Type of 'qux' is not a subtype of the overridden property 'public abstract val qux: kotlin.Int defined in Base'">String</error> = ""
}
@@ -1,6 +1,6 @@
// "Change 'A.x' type to '(Int) -> Int'" "false"
// ACTION: Change 'C.x' type to '(String) -> Int'
// ERROR: Return type of 'x' is not a subtype of the return type of the overridden member 'public abstract val x: (kotlin.String) -> kotlin.Int defined in A'
// ERROR: Type of 'x' is not a subtype of the overridden property 'public abstract val x: (kotlin.String) -> kotlin.Int defined in A'
interface A {
val x: (String) -> Int
}
@@ -1,6 +1,6 @@
// "Change 'B.x' type to '(String) -> [ERROR : Ay]'" "false"
// ACTION: Change 'A.x' type to '(Int) -> Int'
// ERROR: Return type of 'x' is not a subtype of the return type of the overridden member 'public abstract val x: (kotlin.String) -> [ERROR : Ay] defined in A'
// ERROR: Type of 'x' is not a subtype of the overridden property 'public abstract val x: (kotlin.String) -> [ERROR : Ay] defined in A'
// ERROR: Unresolved reference: Ay
interface A {
val x: (String) -> Ay