-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: info if overriding member is not needed (#759)
Closes #25 ### Summary of Changes Show an info if an overriding member is identical to the overridden one. In this case, it can be removed.
- Loading branch information
1 parent
a698a6a
commit 23b340e
Showing
4 changed files
with
97 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 30 additions & 50 deletions
80
...ources/validation/inheritance/overriding method must match overridden method/main.sdstest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,75 +1,55 @@ | ||
package tests.validation.inheritance.overridingMethodMustMatchOverriddenMethod | ||
|
||
class MySuperClass { | ||
attr myInstanceAttribute: Int | ||
static attr myStaticAttribute: Int | ||
attr myInstanceAttribute: Number | ||
static attr myStaticAttribute: Number | ||
|
||
fun myInstanceMethod(a: Int = 0) -> r: Int | ||
static fun myStaticMethod(a: Int = 0) -> r: Int | ||
fun myInstanceMethod(a: Number = 0) -> r: Number | ||
static fun myStaticMethod(a: Number = 0) -> r: Number | ||
} | ||
|
||
class MyClass1 sub MySuperClass { | ||
// $TEST$ no error r"Overriding member does not match the overridden member:[\s\S]*" | ||
// $TEST$ no error r"Overriding member does not match the overridden member:.*" | ||
attr »myInstanceAttribute«: Int | ||
// $TEST$ no error r"Overriding member does not match the overridden member:[\s\S]*" | ||
// $TEST$ no error r"Overriding member does not match the overridden member:.*" | ||
static attr »myStaticAttribute«: Int | ||
|
||
// $TEST$ no error r"Overriding member does not match the overridden member:[\s\S]*" | ||
attr »myInstanceAttribute«: String | ||
// $TEST$ no error r"Overriding member does not match the overridden member:[\s\S]*" | ||
static attr »myStaticAttribute«: String | ||
// $TEST$ no error r"Overriding member does not match the overridden member:.*" | ||
attr »myInstanceAttribute«: Any | ||
// $TEST$ no error r"Overriding member does not match the overridden member:.*" | ||
static attr »myStaticAttribute«: Any | ||
|
||
// $TEST$ no error r"Overriding member does not match the overridden member:[\s\S]*" | ||
// $TEST$ no error r"Overriding member does not match the overridden member:.*" | ||
attr »myOwnInstanceAttribute«: Int | ||
// $TEST$ no error r"Overriding member does not match the overridden member:[\s\S]*" | ||
// $TEST$ no error r"Overriding member does not match the overridden member:.*" | ||
static attr »myOwnStaticAttribute«: Int | ||
|
||
|
||
// $TEST$ no error r"Overriding member does not match the overridden member:[\s\S]*" | ||
fun »myInstanceMethod«(a: Int = 0) -> r: Int | ||
// $TEST$ no error r"Overriding member does not match the overridden member:[\s\S]*" | ||
static fun »myStaticMethod«(a: Int = 0) -> r: Int | ||
// $TEST$ no error r"Overriding member does not match the overridden member:.*" | ||
fun »myInstanceMethod«(a: Any = 0) -> r: Int | ||
// $TEST$ no error r"Overriding member does not match the overridden member:.*" | ||
static fun »myStaticMethod«(a: Any = 0) -> r: Int | ||
|
||
// $TEST$ no error r"Overriding member does not match the overridden member:[\s\S]*" | ||
// $TEST$ no error r"Overriding member does not match the overridden member:.*" | ||
fun »myInstanceMethod«() -> r: Int | ||
// $TEST$ no error r"Overriding member does not match the overridden member:[\s\S]*" | ||
// $TEST$ no error r"Overriding member does not match the overridden member:.*" | ||
static fun »myStaticMethod«() -> r: Int | ||
|
||
// $TEST$ no error r"Overriding member does not match the overridden member:[\s\S]*" | ||
fun »myOwnInstanceMethod«(a: Int = 0) -> r: Int | ||
// $TEST$ no error r"Overriding member does not match the overridden member:[\s\S]*" | ||
static fun »myOwnStaticMethod«(a: Int = 0) -> r: Int | ||
// $TEST$ no error r"Overriding member does not match the overridden member:.*" | ||
fun »myOwnInstanceMethod«(a: Any = 0) -> r: Int | ||
// $TEST$ no error r"Overriding member does not match the overridden member:.*" | ||
static fun »myOwnStaticMethod«(a: Any = 0) -> r: Int | ||
} | ||
|
||
class MyClass2 sub MySuperClass { | ||
// $TEST$ error r"Overriding member does not match the overridden member:[\s\S]*" | ||
attr »myInstanceAttribute«: String | ||
// $TEST$ no error r"Overriding member does not match the overridden member:[\s\S]*" | ||
static attr »myStaticAttribute«: String | ||
// $TEST$ error r"Overriding member does not match the overridden member:.*" | ||
attr »myInstanceAttribute«: Any | ||
// $TEST$ no error r"Overriding member does not match the overridden member:.*" | ||
static attr »myStaticAttribute«: Any | ||
|
||
// $TEST$ no error r"Overriding member does not match the overridden member:[\s\S]*" | ||
attr »myInstanceAttribute«: Int | ||
// $TEST$ no error r"Overriding member does not match the overridden member:[\s\S]*" | ||
static attr »myStaticAttribute«: Int | ||
|
||
// $TEST$ no error r"Overriding member does not match the overridden member:[\s\S]*" | ||
attr »myOwnInstanceAttribute«: Int | ||
// $TEST$ no error r"Overriding member does not match the overridden member:[\s\S]*" | ||
static attr »myOwnStaticAttribute«: Int | ||
|
||
|
||
// $TEST$ error r"Overriding member does not match the overridden member:[\s\S]*" | ||
fun »myInstanceMethod«() -> r: Int | ||
// $TEST$ no error r"Overriding member does not match the overridden member:[\s\S]*" | ||
static fun »myStaticMethod«() -> r: Int | ||
|
||
// $TEST$ no error r"Overriding member does not match the overridden member:[\s\S]*" | ||
fun »myInstanceMethod«(a: Int = 0) -> r: Int | ||
// $TEST$ no error r"Overriding member does not match the overridden member:[\s\S]*" | ||
static fun »myStaticMethod«(a: Int = 0) -> r: Int | ||
|
||
// $TEST$ no error r"Overriding member does not match the overridden member:[\s\S]*" | ||
fun »myOwnInstanceMethod«(a: Int = 0) -> r: Int | ||
// $TEST$ no error r"Overriding member does not match the overridden member:[\s\S]*" | ||
static fun »myOwnStaticMethod«(a: Int = 0) -> r: Int | ||
// $TEST$ error r"Overriding member does not match the overridden member:.*" | ||
fun »myInstanceMethod«(a: Number = 0) -> r: Any | ||
// $TEST$ no error r"Overriding member does not match the overridden member:.*" | ||
static fun »myStaticMethod«(a: Number = 0) -> r: Any | ||
} |
55 changes: 55 additions & 0 deletions
55
...alidation/inheritance/overriding method should differ from overridden method/main.sdstest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package tests.validation.inheritance.overridingMethodShouldDifferFromOverriddenMethod | ||
|
||
class MySuperClass { | ||
attr myInstanceAttribute: Number | ||
static attr myStaticAttribute: Number | ||
|
||
fun myInstanceMethod(a: Number = 0) -> r: Number | ||
static fun myStaticMethod(a: Number = 0) -> r: Number | ||
} | ||
|
||
class MyClass1 sub MySuperClass { | ||
// $TEST$ info "Overriding member is identical to overridden member and can be removed." | ||
attr »myInstanceAttribute«: Number | ||
// $TEST$ no info "Overriding member is identical to overridden member and can be removed." | ||
static attr »myStaticAttribute«: Number | ||
|
||
// $TEST$ no info "Overriding member is identical to overridden member and can be removed." | ||
attr »myInstanceAttribute«: Number | ||
// $TEST$ no info "Overriding member is identical to overridden member and can be removed." | ||
static attr »myStaticAttribute«: Number | ||
|
||
// $TEST$ no info "Overriding member is identical to overridden member and can be removed." | ||
attr »myOwnInstanceAttribute«: Number | ||
// $TEST$ no info "Overriding member is identical to overridden member and can be removed." | ||
static attr »myOwnStaticAttribute«: Number | ||
|
||
|
||
// $TEST$ info "Overriding member is identical to overridden member and can be removed." | ||
fun »myInstanceMethod«(a: Number = 0) -> r: Number | ||
// $TEST$ no info "Overriding member is identical to overridden member and can be removed." | ||
static fun »myStaticMethod«(a: Number = 0) -> r: Number | ||
|
||
// $TEST$ no info "Overriding member is identical to overridden member and can be removed." | ||
fun »myInstanceMethod«() -> r: Number | ||
// $TEST$ no info "Overriding member is identical to overridden member and can be removed." | ||
static fun »myStaticMethod«() -> r: Number | ||
|
||
// $TEST$ no info "Overriding member is identical to overridden member and can be removed." | ||
fun »myOwnInstanceMethod«(a: Number = 0) -> r: Number | ||
// $TEST$ no info "Overriding member is identical to overridden member and can be removed." | ||
static fun »myOwnStaticMethod«(a: Number = 0) -> r: Number | ||
} | ||
|
||
class MyClass2 sub MySuperClass { | ||
// $TEST$ no info "Overriding member is identical to overridden member and can be removed." | ||
attr »myInstanceAttribute«: Int | ||
// $TEST$ no info "Overriding member is identical to overridden member and can be removed." | ||
static attr »myStaticAttribute«: Int | ||
|
||
|
||
// $TEST$ no info "Overriding member is identical to overridden member and can be removed." | ||
fun »myInstanceMethod«(a: Number = 0) -> r: Int | ||
// $TEST$ no info "Overriding member is identical to overridden member and can be removed." | ||
static fun »myStaticMethod«(a: Number = 0) -> r: Int | ||
} |