Skip to content

Commit 561ecd8

Browse files
committed
Sema: Fix leading dot with protocol composition or parameterized protocol contextual type
- Fixes #60552. - Fixes rdar://problem/99699879.
1 parent d27ce64 commit 561ecd8

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

lib/Sema/CSApply.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1679,7 +1679,7 @@ namespace {
16791679
// \endcode
16801680
//
16811681
// Here `P.foo` would be replaced with `S.foo`
1682-
if (!isExistentialMetatype && baseTy->is<ProtocolType>() &&
1682+
if (!isExistentialMetatype && baseTy->isConstraintType() &&
16831683
member->isStatic()) {
16841684
auto selfParam =
16851685
overload.adjustedOpenedFullType->castTo<FunctionType>()->getParams()[0];

test/Constraints/issue-60552.swift

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// RUN: %target-swift-emit-silgen %s
2+
3+
// rdar://150858005
4+
protocol P {}
5+
protocol Q {}
6+
7+
struct MyP: P, Q {}
8+
9+
extension P where Self == MyP {
10+
static var myP: Self { return MyP() }
11+
}
12+
13+
func test() {
14+
let _: any P & Q = .myP
15+
}
16+
17+
// rdar://148708774
18+
protocol Wrapper<Wrapped> {
19+
associatedtype Wrapped
20+
}
21+
struct IntWrapper: Wrapper {
22+
typealias Wrapped = Int
23+
}
24+
25+
extension Wrapper where Self == IntWrapper {
26+
static var int: Self { fatalError() }
27+
}
28+
29+
let crashes: any Wrapper<Int> = .int
30+
let ok1: some Wrapper<Int> = .int
31+
let ok2: any Wrapper = .int

0 commit comments

Comments
 (0)