Skip to content

Commit a7fc49c

Browse files
committed
fix: restore local loader artifact safety gate
1 parent 7bf31e8 commit a7fc49c

3 files changed

Lines changed: 2 additions & 50 deletions

File tree

internal/loader/artifact_cache.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,9 @@ func isProviderSetTypeForLoader(t types.Type) bool {
153153
if obj == nil || obj.Pkg() == nil {
154154
return false
155155
}
156-
return isWireImportPath(obj.Pkg().Path()) && obj.Name() == "ProviderSet"
157-
}
158-
159-
func isWireImportPath(path string) bool {
160-
switch path {
156+
switch obj.Pkg().Path() {
161157
case "github.com/goforj/wire", "github.com/google/wire":
162-
return true
158+
return obj.Name() == "ProviderSet"
163159
default:
164160
return false
165161
}

internal/loader/custom.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -546,18 +546,6 @@ func (l *customTypedGraphLoader) localSemanticArtifactSupported(meta *packageMet
546546
return art.Supported
547547
}
548548

549-
func localPackageNeedsSemanticArtifacts(meta *packageMeta) bool {
550-
if meta == nil {
551-
return false
552-
}
553-
for _, path := range meta.Imports {
554-
if isWireImportPath(path) {
555-
return true
556-
}
557-
}
558-
return false
559-
}
560-
561549
func (l *customTypedGraphLoader) artifactPolicy(meta *packageMeta, isTarget, isLocal bool) artifactPolicy {
562550
if !loaderArtifactEnabled(l.env) || isTarget {
563551
return artifactPolicy{}
@@ -567,10 +555,6 @@ func (l *customTypedGraphLoader) artifactPolicy(meta *packageMeta, isTarget, isL
567555
policy.read = true
568556
return policy
569557
}
570-
if !localPackageNeedsSemanticArtifacts(meta) {
571-
policy.read = true
572-
return policy
573-
}
574558
policy.read = l.localSemanticArtifactSupported(meta)
575559
return policy
576560
}

internal/loader/loader_test.go

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2386,34 +2386,6 @@ func TestLoaderArtifactKeyExternalWithoutExportChangesWhenSourceChanges(t *testi
23862386
}
23872387
}
23882388

2389-
func TestArtifactPolicyLocalReadOnlyNeedsSemanticForWirePackages(t *testing.T) {
2390-
t.Parallel()
2391-
2392-
loader := &customTypedGraphLoader{
2393-
env: []string{"WIRE_LOADER_ARTIFACTS=1"},
2394-
localSemanticOK: map[string]bool{"example.com/app": false},
2395-
}
2396-
2397-
nonWireMeta := &packageMeta{
2398-
ImportPath: "example.com/app",
2399-
Imports: []string{"fmt", "example.com/dep"},
2400-
}
2401-
wireMeta := &packageMeta{
2402-
ImportPath: "example.com/app",
2403-
Imports: []string{"github.com/goforj/wire"},
2404-
}
2405-
2406-
if got := loader.artifactPolicy(nonWireMeta, false, true); !got.read || !got.write {
2407-
t.Fatalf("artifactPolicy(non-wire local) = %+v, want read+write", got)
2408-
}
2409-
if got := loader.artifactPolicy(wireMeta, false, true); got.read || !got.write {
2410-
t.Fatalf("artifactPolicy(wire local without semantic support) = %+v, want write-only", got)
2411-
}
2412-
if got := loader.artifactPolicy(wireMeta, false, false); !got.read || !got.write {
2413-
t.Fatalf("artifactPolicy(wire external) = %+v, want read+write", got)
2414-
}
2415-
}
2416-
24172389
func TestRunGoListIncludesExportDataForReplacedModule(t *testing.T) {
24182390
root := t.TempDir()
24192391
depRoot := filepath.Join(root, "depmod")

0 commit comments

Comments
 (0)