Sema: Fix leading dot with protocol composition or parameterized protocol contextual type

- Fixes https://github.com/swiftlang/swift/issues/60552.
- Fixes rdar://problem/99699879.
This commit is contained in:
Slava Pestov
2025-07-03 00:18:33 -04:00
parent d27ce6465d
commit 561ecd8826
2 changed files with 32 additions and 1 deletions

View File

@@ -1679,7 +1679,7 @@ namespace {
// \endcode
//
// Here `P.foo` would be replaced with `S.foo`
if (!isExistentialMetatype && baseTy->is<ProtocolType>() &&
if (!isExistentialMetatype && baseTy->isConstraintType() &&
member->isStatic()) {
auto selfParam =
overload.adjustedOpenedFullType->castTo<FunctionType>()->getParams()[0];

View File

@@ -0,0 +1,31 @@
// RUN: %target-swift-emit-silgen %s
// rdar://150858005
protocol P {}
protocol Q {}
struct MyP: P, Q {}
extension P where Self == MyP {
static var myP: Self { return MyP() }
}
func test() {
let _: any P & Q = .myP
}
// rdar://148708774
protocol Wrapper<Wrapped> {
associatedtype Wrapped
}
struct IntWrapper: Wrapper {
typealias Wrapped = Int
}
extension Wrapper where Self == IntWrapper {
static var int: Self { fatalError() }
}
let crashes: any Wrapper<Int> = .int
let ok1: some Wrapper<Int> = .int
let ok2: any Wrapper = .int