Skip to content

Commit d082b3c

Browse files
author
Mani Zeygham
committed
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 25a90be. Fixes golang/go#77784
1 parent dd752d6 commit d082b3c

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

gopls/internal/golang/implementation.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -940,7 +940,7 @@ func implFuncs(pkg *cache.Package, curSel inspector.Cursor, start, end token.Pos
940940
if inToken(n.Lparen, "(", start, end) {
941941
t := dynamicFuncCallType(info, n)
942942
if t == nil {
943-
return nil, fmt.Errorf("not a dynamic function call")
943+
return nil, errNotHandled
944944
}
945945
// Case 2b: dynamic call of function value.
946946
// Report declarations of corresponding concrete functions.

gopls/internal/test/marker/testdata/implementation/issue74305.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ go 1.18
88
-- a/a.go --
99
package a
1010

11-
var _ = undefined() //@ diag("undefined", re"undefined"), implementation("(", err="not a dynamic function call")
11+
var _ = undefined() //@ diag("undefined", re"undefined"), implementation("(", err="no identifier found")

gopls/internal/test/marker/testdata/implementation/signature.txt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,11 @@ func _(
6969
struct{x Nullary}{}.x() //@ loc(fieldCall, "("), implementation("(", nullaryFunc)
7070

7171
// Calls that are not dynamic function calls:
72-
_ = len("") //@ implementation("(", err="not a dynamic function call")
73-
_ = int(0) //@ implementation("(", err="not a dynamic function call")
74-
_ = error.Error(nil) //@ implementation("(", err="not a dynamic function call")
75-
_ = err.Error() //@ implementation("(", err="not a dynamic function call")
76-
_ = f4(0) //@ implementation("(", err="not a dynamic function call"), loc(f4Call, "(")
72+
_ = len("") //@ implementation("(", err="no identifier found")
73+
_ = int(0) //@ implementation("(", err="no identifier found")
74+
_ = error.Error(nil) //@ implementation("(", err="no identifier found")
75+
_ = err.Error() //@ implementation("(", err="no identifier found")
76+
_ = f4(0) //@ implementation("(", err="no identifier found"), loc(f4Call, "(")
7777
}
7878

7979

80-

0 commit comments

Comments
 (0)