Skip to content

Commit dfd21ba

Browse files
authored
Merge pull request #82130 from xedin/rdar-151943924-6.2
[6.2][TypeCheckEffects] Fix `AbstractFunction::getType` to look through al…
2 parents f861c2f + f8a3c3b commit dfd21ba

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

lib/Sema/TypeCheckEffects.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ class AbstractFunction {
386386
Type getType() const {
387387
switch (getKind()) {
388388
case Kind::Opaque:
389-
return getOpaqueFunction()->getType()->lookThroughSingleOptionalType();
389+
return getOpaqueFunction()->getType()->lookThroughAllOptionalTypes();
390390
case Kind::Function: {
391391
auto *AFD = getFunction();
392392
if (AFD->hasImplicitSelfDecl() && AppliedSelf)
@@ -395,8 +395,7 @@ class AbstractFunction {
395395
}
396396
case Kind::Closure: return getClosure()->getType();
397397
case Kind::Parameter:
398-
return getParameter()->getInterfaceType()
399-
->lookThroughSingleOptionalType();
398+
return getParameter()->getInterfaceType()->lookThroughAllOptionalTypes();
400399
}
401400
llvm_unreachable("bad kind");
402401
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// RUN: %target-typecheck-verify-swift
2+
3+
@propertyWrapper
4+
struct Weak<Value> {
5+
var wrappedValue: Value? { fatalError() }
6+
}
7+
8+
struct WeakStorage<Item: Hashable> {
9+
@Weak var action: ((Set<Item>) -> Void)??
10+
}
11+
12+
final class Test {
13+
var storage: WeakStorage<AnyHashable> = .init()
14+
15+
func test(items: Set<AnyHashable>) {
16+
storage.action??(items)
17+
}
18+
}

0 commit comments

Comments
 (0)