Repository navigation
implementations: fall back to a method-set fingerprint when types.Implements fails across test-variant universes - #312
Open
alokkumary2j wants to merge 1 commit into
Conversation
…lements fails loader.addImportsToPkgs keeps the white-box test variant `p [p.test]` of a package that has an in-package _test.go, so implementation extraction sees that variant's *types.Named while a cross-package implementer was checked against the plain `p`. types.Implements then fails for any interface method whose signature names a type declared in `p`, and the is_implementation relationship is silently dropped. When types.Implements fails, compare method-set identity (each interface method's Id + signature fingerprint present in the type's method set). Types with type parameters stay on types.Implements only, so the fallback can only add edges. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem.
loader.addImportsToPkgskeys packages by PkgPath and keeps the variant with MORE files, i.e. the white-box testvariant
p [p.test]wheneverphas an in-package_test.go. Implementation extraction therefore sees only the test variant's*types.Namedfor types ofp. An implementer in another packageqwas type-checked against the PLAINp, sotypes.Implements(Impl, p.Iface)fails for any interface method whose signature names a type declared inp(two distinct*types.Namedfor the samep.Opts). Result:is_implementationedges silently missing for every cross-package implementerof such an interface in any package that has an in-package test file.
Measured (prometheus @ 21fd457,
GOWORK=off, scip-go v0.2.7):discovery.Configimplementers (cross-pkg)NeedDepsadded to the loader mode--skip-testsConfig36,Iterator19,AppenderV214, ...). Debug trace:missing=NewDiscoverer ... wrongType=truewhile the method-name mask passes.Fix (~40 lines). When
types.Implementsfails, compare gopls-methodsets identity: every interface method'sId + signature fingerprintmust be present in the candidate type's method set. Types with type parameters (tricky fingerprints)stay on
types.Implementsonly, so the fallback can only ADD edges where the type checker was fooled by the universe split.Minimal repro.
scip-go-> nois_implementationrelationship fromq.Impltop.Svc(deletep/p_test.goand it appears).With the patch the edge is emitted.
Patch:
scip-go-v0.2.7-fingerprint-fallback.patch(touchesinternal/implementations/{extractor,implementations}.go).Still present on v0.2.9 (
173cadc): the minimal repro above emits nois_implementationrelationship unpatched and emitsq.Impl# -> p.Svc#(andImpl#Run(). -> Svc#Run.) patched. The patch applies cleanly tomain, andgo test ./...passes.🤖 Generated with Claude Code