gopls/internal/golang: fall back when ( is not a dynamic function call
When implementation is requested at the "(" paren of a call, implFuncs first checks whether the call is dynamic. For calls that are not dynamic function calls (for example, method calls), that check fails.
Instead of returning a hard error, return errNotHandled so the request falls back to the regular method-set implementation path.
This restores the fallback behavior that regressed in 25a90befcdf96d15f13dd947b7395c8531dc67de.
Fixes golang/go#77784
diff --git a/gopls/internal/golang/implementation.go b/gopls/internal/golang/implementation.go
index 9b47dea..eac0f7f 100644
--- a/gopls/internal/golang/implementation.go
+++ b/gopls/internal/golang/implementation.go
@@ -940,7 +940,7 @@
if inToken(n.Lparen, "(", start, end) {
t := dynamicFuncCallType(info, n)
if t == nil {
- return nil, fmt.Errorf("not a dynamic function call")
+ return nil, errNotHandled
}
// Case 2b: dynamic call of function value.
// Report declarations of corresponding concrete functions.
diff --git a/gopls/internal/test/marker/testdata/implementation/issue74305.txt b/gopls/internal/test/marker/testdata/implementation/issue74305.txt
index 916a6d3..473fb28 100644
--- a/gopls/internal/test/marker/testdata/implementation/issue74305.txt
+++ b/gopls/internal/test/marker/testdata/implementation/issue74305.txt
@@ -8,4 +8,4 @@
-- a/a.go --
package a
-var _ = undefined() //@ diag("undefined", re"undefined"), implementation("(", err="not a dynamic function call")
+var _ = undefined() //@ diag("undefined", re"undefined"), implementation("(", err="no identifier found")
diff --git a/gopls/internal/test/marker/testdata/implementation/signature.txt b/gopls/internal/test/marker/testdata/implementation/signature.txt
index 054e169..daa02f9 100644
--- a/gopls/internal/test/marker/testdata/implementation/signature.txt
+++ b/gopls/internal/test/marker/testdata/implementation/signature.txt
@@ -69,12 +69,11 @@
struct{x Nullary}{}.x() //@ loc(fieldCall, "("), implementation("(", nullaryFunc)
// Calls that are not dynamic function calls:
- _ = len("") //@ implementation("(", err="not a dynamic function call")
- _ = int(0) //@ implementation("(", err="not a dynamic function call")
- _ = error.Error(nil) //@ implementation("(", err="not a dynamic function call")
- _ = err.Error() //@ implementation("(", err="not a dynamic function call")
- _ = f4(0) //@ implementation("(", err="not a dynamic function call"), loc(f4Call, "(")
+ _ = len("") //@ implementation("(", err="no identifier found")
+ _ = int(0) //@ implementation("(", err="no identifier found")
+ _ = error.Error(nil) //@ implementation("(", err="no identifier found")
+ _ = err.Error() //@ implementation("(", err="no identifier found")
+ _ = f4(0) //@ implementation("(", err="no identifier found"), loc(f4Call, "(")
}
-
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
I spotted some possible problems with your PR:
1. You have a long 205 character line in the commit message body. Please add line breaks to long lines that should be wrapped. Lines in the commit message body should be wrapped at ~76 characters unless needed for things like URLs or tables. (Note: GitHub might render long lines as soft-wrapped, so double-check in the Gerrit commit message shown above.)
Please address any problems by updating the GitHub PR.
When complete, mark this comment as 'Done' and click the [blue 'Reply' button](https://go.dev/wiki/GerritBot#i-left-a-reply-to-a-comment-in-gerrit-but-no-one-but-me-can-see-it) above. These findings are based on heuristics; if a finding does not apply, briefly reply here saying so.
To update the commit title or commit message body shown here in Gerrit, you must edit the GitHub PR title and PR description (the first comment) in the GitHub web interface using the 'Edit' button or 'Edit' menu entry there. Note: pushing a new commit to the PR will not automatically update the commit message used by Gerrit.
For more details, see:
(In general for Gerrit code reviews, the change author is expected to [log in to Gerrit](https://go-review.googlesource.com/login/) with a Gmail or other Google account and then close out each piece of feedback by marking it as 'Done' if implemented as suggested or otherwise reply to each review comment. See the [Review](https://go.dev/doc/contribute#review) section of the Contributing Guide for details.)
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Congratulations on opening your first change. Thank you for your contribution!
Next steps:
A maintainer will review your change and provide feedback. See
https://go.dev/doc/contribute#review for more info and tips to get your
patch through code review.
Most changes in the Go project go through a few rounds of revision. This can be
surprising to people new to the project. The careful, iterative review process
is our way of helping mentor contributors and ensuring that their contributions
have a lasting impact.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |