Skip to content

Commit a823212

Browse files
committed
[ConstraintSystem] Fix isPartialApplication to properly handle static members
Only instance members require double-apply to be fully applied, static members apply the base implicitly.
1 parent bd4ee46 commit a823212

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

lib/Sema/ConstraintSystem.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2469,7 +2469,10 @@ bool ConstraintSystem::isPartialApplication(ConstraintLocator *locator) {
24692469

24702470
auto baseTy =
24712471
simplifyType(getType(UDE->getBase()))->getWithoutSpecifierType();
2472-
return getApplicationLevel(*this, baseTy, UDE) < 2;
2472+
auto level = getApplicationLevel(*this, baseTy, UDE);
2473+
// Static members have base applied implicitly which means that their
2474+
// application level is lower.
2475+
return level < (baseTy->is<MetatypeType>() ? 1 : 2);
24732476
}
24742477

24752478
DeclReferenceType

test/Concurrency/sendable_methods.swift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,3 +206,25 @@ func generic3<T>(_ x: T) async {
206206

207207
await generic3(GenericS<NonSendable>.f)
208208
}
209+
210+
// Make sure that static members are handled properly
211+
do {
212+
struct X<T> {
213+
init(_: T) {
214+
}
215+
216+
static func test(_: T) {}
217+
}
218+
219+
class Test<T> {
220+
init(_: T) {
221+
_ = X(self) // Ok
222+
_ = X.init(self) // Ok
223+
_ = Optional.some(self) // Ok
224+
225+
let _: @Sendable (Int) -> X<Int> = X.init // Ok
226+
let _: @Sendable (Test<Int>) -> Void = X.test // Ok
227+
let _ = X.test(self) // Ok
228+
}
229+
}
230+
}

0 commit comments

Comments
 (0)