swift icon indicating copy to clipboard operation
swift copied to clipboard

[AST] Fix best import kind when value decl is a typealias of an existential type

Open li3zhen1 opened this issue 10 months ago • 6 comments

Resolves #72724 .

Fixed behaviors:

/Users/lizhen/Projects/swift-projects/build/Ninja-DebugAssert/swift-macosx-arm64/bin/swift-frontend ./moduleB.swift -I . -L . -l./moduleA -typecheck
./moduleB.swift:3:17: error: type alias 'TypeAlias' (aka 'any Protocol') cannot be imported as 'protocol'
1 │
2 │ // Module B
3 │ import protocol ModuleA.TypeAlias 
  │                 ╰─ error: type alias 'TypeAlias' (aka 'any Protocol') cannot be imported as 'protocol'
4 │ import typealias ModuleA.TypeAlias

/Users/lizhen/Projects/swift-debug/./ModuleA.swift:3:18: note: 'TypeAlias' declared here
1 │ // Module A
2 │ public protocol Protocol {}
3 │ public typealias TypeAlias = any Protocol
  │                  ╰─ note: 'TypeAlias' declared here
4 │

li3zhen1 avatar Mar 31 '24 22:03 li3zhen1