-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Closed as not planned
Closed as not planned
Copy link
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.conformancesFeature → protocol: protocol conformancesFeature → protocol: protocol conformancesexpressionsFeature: expressionsFeature: expressionsindexingArea → source tooling: AST indexingArea → source tooling: AST indexingmultiple modulesFlag: An issue whose reproduction requires multiple modulesFlag: An issue whose reproduction requires multiple modulesprotocolFeature → type declarations: Protocol declarationsFeature → type declarations: Protocol declarationssource toolingArea: IDE support, SourceKit, and other source toolingArea: IDE support, SourceKit, and other source toolingswift 5.7unexpected behaviorBug: Unexpected behavior or incorrect outputBug: Unexpected behavior or incorrect output
Description
With this code:
// Module0
public struct Foo {
public init() {}
}
public protocol Bar {}
// Module1
import Module0
extension Foo: Bar {}
// Module2
import Module0
public func baz(_: Bar) {}
// Module3
import Module0
import Module1
import Module2
func qux() {
baz(Foo())
}
The index data for Module3 does not contain any references to Module1, even though the conformance defined in Module1 is required for the code to compile. This is easiest to visualize with indexutil-annotate:
// Module3
/*
module=Module0=usr is c:@M@Module0
v */
import Module0
/*
module=Module1=usr is c:@M@Module1
v */
import Module1
/*
module=Module2=usr is c:@M@Module2
v */
import Module2
/*
function=qux()=usr is s:7Module33quxyyF
v */
func qux() {
/*
function=baz(_:)=usr is s:7Module23bazyy7Module03Bar_pF
| struct=Foo=usr is s:7Module03FooV
| constructor=init()=usr is s:7Module03FooVACycfc
v v */
baz(Foo())
}
Steps to reproduce
Using this project: protocolext.zip and indexutil-annotate
:
swift build
indexutil-annotate .build/debug/index/store/ Sources/Module3/Module3.swift
You can also inspect the record naively with strings
to see there are no other string references to Module1
:
% strings $(find .build/debug/index/store/v5/records -name "Module3.swift*")
IDXR
Module0c:@M@Module0
Module1c:@M@Module1
Module2c:@M@Module2
qux()s:7Module33quxyyF
baz(_:)s:7Module23bazyy7Module03Bar_pF
Foos:7Module03FooV
init()s:7Module03FooVACycfc
Expected behavior
I think ideally there would be something in the index data showing that Module1 is depended on by this unit. I'm not sure exactly what it would point to.
Environment
- Swift compiler version info 5.7.2
- Xcode version info 14.2.14C18
Metadata
Metadata
Assignees
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.conformancesFeature → protocol: protocol conformancesFeature → protocol: protocol conformancesexpressionsFeature: expressionsFeature: expressionsindexingArea → source tooling: AST indexingArea → source tooling: AST indexingmultiple modulesFlag: An issue whose reproduction requires multiple modulesFlag: An issue whose reproduction requires multiple modulesprotocolFeature → type declarations: Protocol declarationsFeature → type declarations: Protocol declarationssource toolingArea: IDE support, SourceKit, and other source toolingArea: IDE support, SourceKit, and other source toolingswift 5.7unexpected behaviorBug: Unexpected behavior or incorrect outputBug: Unexpected behavior or incorrect output