-
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: error if function pointers are used (#629)
Closes #565 Closes partially #543 ### Summary of Changes To provide a cleaner graphical view, this PR makes the use of function pointers (to functions/segments) an error. Lambdas can be used instead. --------- Co-authored-by: megalinter-bot <129584137+megalinter-bot@users.noreply.github.com>
- Loading branch information
1 parent
b99ab25
commit 01933b9
Showing
3 changed files
with
109 additions
and
3 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
68 changes: 68 additions & 0 deletions
68
tests/resources/validation/other/expressions/references/function pointer/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,68 @@ | ||
package tests.validation.other.expressions.references.target | ||
|
||
class MyClass { | ||
fun myInstanceMethod() | ||
static fun myStaticMethod() | ||
} | ||
|
||
fun myFunction1() | ||
fun myFunction2(p: Any) | ||
|
||
segment mySegment1() {} | ||
|
||
segment mySegment2() { | ||
// $TEST$ error "Function pointers are not allowed to provide a cleaner graphical view. Use a lambda instead." | ||
MyClass().»myInstanceMethod«; | ||
// $TEST$ error "Function pointers are not allowed to provide a cleaner graphical view. Use a lambda instead." | ||
MyClass().»myInstanceMethod«.a; | ||
// $TEST$ error "Function pointers are not allowed to provide a cleaner graphical view. Use a lambda instead." | ||
MyClass().»myInstanceMethod«.a(); | ||
// $TEST$ error "Function pointers are not allowed to provide a cleaner graphical view. Use a lambda instead." | ||
myFunction2(MyClass().»myInstanceMethod«); | ||
// $TEST$ no error "Function pointers are not allowed to provide a cleaner graphical view. Use a lambda instead." | ||
MyClass().»myInstanceMethod«(); | ||
|
||
// $TEST$ error "Function pointers are not allowed to provide a cleaner graphical view. Use a lambda instead." | ||
MyClass.»myStaticMethod«; | ||
// $TEST$ error "Function pointers are not allowed to provide a cleaner graphical view. Use a lambda instead." | ||
MyClass.»myStaticMethod«.a; | ||
// $TEST$ error "Function pointers are not allowed to provide a cleaner graphical view. Use a lambda instead." | ||
MyClass.»myStaticMethod«.a(); | ||
// $TEST$ error "Function pointers are not allowed to provide a cleaner graphical view. Use a lambda instead." | ||
myFunction2(MyClass.»myStaticMethod«); | ||
// $TEST$ no error "Function pointers are not allowed to provide a cleaner graphical view. Use a lambda instead." | ||
MyClass.»myStaticMethod«(); | ||
|
||
// $TEST$ error "Function pointers are not allowed to provide a cleaner graphical view. Use a lambda instead." | ||
»myFunction1«; | ||
// $TEST$ error "Function pointers are not allowed to provide a cleaner graphical view. Use a lambda instead." | ||
»myFunction1«.a; | ||
// $TEST$ error "Function pointers are not allowed to provide a cleaner graphical view. Use a lambda instead." | ||
»myFunction1«.a(); | ||
// $TEST$ error "Function pointers are not allowed to provide a cleaner graphical view. Use a lambda instead." | ||
myFunction2(»myFunction1«); | ||
// $TEST$ no error "Function pointers are not allowed to provide a cleaner graphical view. Use a lambda instead." | ||
»myFunction1«(); | ||
|
||
// $TEST$ error "Function pointers are not allowed to provide a cleaner graphical view. Use a lambda instead." | ||
»mySegment1«; | ||
// $TEST$ error "Function pointers are not allowed to provide a cleaner graphical view. Use a lambda instead." | ||
»mySegment1«.a; | ||
// $TEST$ error "Function pointers are not allowed to provide a cleaner graphical view. Use a lambda instead." | ||
»mySegment1«.a(); | ||
// $TEST$ error "Function pointers are not allowed to provide a cleaner graphical view. Use a lambda instead." | ||
myFunction2(»mySegment1«); | ||
// $TEST$ no error "Function pointers are not allowed to provide a cleaner graphical view. Use a lambda instead." | ||
»mySegment1«(); | ||
|
||
// $TEST$ no error "Function pointers are not allowed to provide a cleaner graphical view. Use a lambda instead." | ||
»unresolved«; | ||
// $TEST$ no error "Function pointers are not allowed to provide a cleaner graphical view. Use a lambda instead." | ||
»unresolved«.a; | ||
// $TEST$ no error "Function pointers are not allowed to provide a cleaner graphical view. Use a lambda instead." | ||
»unresolved«.a(); | ||
// $TEST$ no error "Function pointers are not allowed to provide a cleaner graphical view. Use a lambda instead." | ||
myFunction2(»unresolved«); | ||
// $TEST$ no error "Function pointers are not allowed to provide a cleaner graphical view. Use a lambda instead." | ||
»unresolved«(); | ||
} |