Open
Description
Description
Code that otherwise works fine fails when fileprivate
names in separate files are made to collide.
Steps to reproduce
Check out the fileprivate-bug
tag from the Val project and build. Many errors ensue, e.g.:
/Users/dave/src/val/Sources/IR/Analysis/Module+Ownership.swift:12:77: error: cannot convert value of type 'TypedProgram' to expected argument type 'AbstractContext<Domain>'
var machine = AbstractInterpreter(analyzing: f, in: self, entryContext: entryContext(of: f))
^
/Users/dave/src/val/Sources/IR/Analysis/Module+Ownership.swift:12:19: error: generic parameter 'Domain' could not be inferred
var machine = AbstractInterpreter(analyzing: f, in: self, entryContext: entryContext(of: f))
^
/Users/dave/src/val/Sources/IR/Analysis/AbstractInterpreter.swift:3:28: note: 'Domain' declared as parameter to type 'AbstractInterpreter'
struct AbstractInterpreter<Domain: AbstractDomain> {
^
/Users/dave/src/val/Sources/IR/Analysis/Module+Ownership.swift:12:19: note: explicitly specify the generic arguments to fix this issue
var machine = AbstractInterpreter(analyzing: f, in: self, entryContext: entryContext(of: f))
^
Then revert the tip commit and build again. It will build fine. The tip commit merely changes the names of fileprivate
types so that the same name is used for different types in two separate files.
Note that this may be an interaction with generics: if you go back two more commits from the failing one you get to a state where the names collide but Module
is no longer generic, and everything compiles fine.
Expected behavior
The aforementioned tag should build and pass tests.
Environment
- Swift compiler version info swift-driver version: 1.75.2 Apple Swift version 5.8.1 (swiftlang-5.8.0.124.5 clang-1403.0.22.11.100)
- Xcode version info Xcode 14.3.1
Build version 14E300c - Deployment target: