mirror of
https://github.com/safishamsi/graphify.git
synced 2026-10-13 15:40:05 +00:00
test(csharp): assert bare this?.M() null-conditional call resolves
#3976 made recv?.M() resolve through the receiver-typed path but only
tested field receivers. Add a test that `this?.Save()` inside a class
resolves to the enclosing class's Save() like `this.Save()`, and not to
an unrelated class's Save().
Fixes #4077
(cherry picked from commit 6ce8348026)
This commit is contained in:
1 parent
5c5ce7fb53
commit
d07c91cba9
1 file changed
+18
@@ -320,6 +320,24 @@ def test_null_conditional_this_field_receiver_resolves(tmp_path):
|
||||
assert (commit, cache_save) not in calls
|
||||
|
||||
|
||||
def test_null_conditional_bare_this_receiver_resolves(tmp_path):
|
||||
"""`this?.Save()` resolves like `this.Save()` (#4077)."""
|
||||
calls, r = _calls(tmp_path, {
|
||||
"S.cs": (
|
||||
"public class Other { public bool Save() => false; }\n"
|
||||
"public class Repo {\n"
|
||||
" public bool Save() => true;\n"
|
||||
" public bool? Commit() { return this?.Save(); }\n"
|
||||
"}\n"
|
||||
)
|
||||
})
|
||||
commit = _find(r, ".Commit()", "commit")
|
||||
repo_save = _find(r, ".Save()", "repo")
|
||||
other_save = _find(r, ".Save()", "other")
|
||||
assert (commit, repo_save) in calls, "this?.Save() must resolve like this.Save()"
|
||||
assert (commit, other_save) not in calls
|
||||
|
||||
|
||||
def test_null_conditional_cross_file_receiver_resolves(tmp_path):
|
||||
calls, r = _calls(tmp_path, {
|
||||
"Server.cs": (
|
||||
|
||||
Reference in new issue
Block a user