-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gopls/internal/lsp/source: ignore objectpath error in rename
An error from objectpath.Object previously caused an assertion failure (bug.Reportf); this change deletes the assertion because the error is benign. It is caused by a discrepancy between the set of cases supported by objectpath.For/Object in syntax packages and export data packages: objects in the former may have a path that is not valid in the latter. Added a regression test. The surprising behavior is documented at objectpath, but it seems unsatisfying, and perhaps should be treated as a bug. Suggestions welcome. Fixes golang/go#60789 Change-Id: I3657f6a465c397adc05ea70331a59c8c9963daa7 Reviewed-on: https://go-review.googlesource.com/c/tools/+/507495 Run-TryBot: Alan Donovan <adonovan@google.com> gopls-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
- Loading branch information
Showing
4 changed files
with
77 additions
and
7 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
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
36 changes: 36 additions & 0 deletions
36
gopls/internal/regtest/marker/testdata/rename/issue60789.txt
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,36 @@ | ||
|
||
This test renames an exported method of an unexported type, | ||
which is an edge case for objectpath, since it computes a path | ||
from a syntax package that is no good when applied to an | ||
export data package. | ||
|
||
See issue #60789. | ||
|
||
-- go.mod -- | ||
module example.com | ||
go 1.12 | ||
|
||
-- a/a.go -- | ||
package a | ||
|
||
type unexported int | ||
func (unexported) F() {} //@rename("F", G, fToG) | ||
|
||
var _ = unexported(0).F | ||
|
||
-- b/b.go -- | ||
package b | ||
|
||
// The existence of this package is sufficient to exercise | ||
// the bug even though it cannot reference a.unexported. | ||
|
||
import _ "example.com/a" | ||
|
||
-- @fToG/a/a.go -- | ||
package a | ||
|
||
type unexported int | ||
func (unexported) G() {} //@rename("F", G, fToG) | ||
|
||
var _ = unexported(0).G | ||
|