Skip to content

Commit 4c0fd1d

Browse files
adonovangopherbot
authored andcommitted
gopls/internal/golang: implementation: fix nil panic
+ test Fixes golang/go#74305 Change-Id: I1093255b448332743726f1e35bbe48689d17b522 Reviewed-on: https://go-review.googlesource.com/c/tools/+/682955 Auto-Submit: Alan Donovan <[email protected]> Reviewed-by: Robert Findley <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Commit-Queue: Alan Donovan <[email protected]>
1 parent 19adb40 commit 4c0fd1d

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

gopls/internal/golang/implementation.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1117,7 +1117,9 @@ func beneathFuncDef(cur inspector.Cursor) bool {
11171117
// Tested via ../test/marker/testdata/implementation/signature.txt.
11181118
func dynamicFuncCallType(info *types.Info, call *ast.CallExpr) types.Type {
11191119
if typesinternal.ClassifyCall(info, call) == typesinternal.CallDynamic {
1120-
return info.Types[call.Fun].Type.Underlying()
1120+
if tv, ok := info.Types[call.Fun]; ok {
1121+
return tv.Type.Underlying()
1122+
}
11211123
}
11221124
return nil
11231125
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Regression test for a crash, #74305.
2+
3+
-- go.mod --
4+
module example.com
5+
6+
go 1.18
7+
8+
-- a/a.go --
9+
package a
10+
11+
var _ = undefined() //@ diag("undefined", re"undefined"), implementation("(", err="not a dynamic function call")

0 commit comments

Comments
 (0)