Skip to content

[6.2][TypeCheckEffects] Fix AbstractFunction::getType to look through al… #82130

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions lib/Sema/TypeCheckEffects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ class AbstractFunction {
Type getType() const {
switch (getKind()) {
case Kind::Opaque:
return getOpaqueFunction()->getType()->lookThroughSingleOptionalType();
return getOpaqueFunction()->getType()->lookThroughAllOptionalTypes();
case Kind::Function: {
auto *AFD = getFunction();
if (AFD->hasImplicitSelfDecl() && AppliedSelf)
Expand All @@ -395,8 +395,7 @@ class AbstractFunction {
}
case Kind::Closure: return getClosure()->getType();
case Kind::Parameter:
return getParameter()->getInterfaceType()
->lookThroughSingleOptionalType();
return getParameter()->getInterfaceType()->lookThroughAllOptionalTypes();
}
llvm_unreachable("bad kind");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// RUN: %target-typecheck-verify-swift

@propertyWrapper
struct Weak<Value> {
var wrappedValue: Value? { fatalError() }
}

struct WeakStorage<Item: Hashable> {
@Weak var action: ((Set<Item>) -> Void)??
}

final class Test {
var storage: WeakStorage<AnyHashable> = .init()

func test(items: Set<AnyHashable>) {
storage.action??(items)
}
}