Skip to content

Commit 76dfbf9

Browse files
authored
Merge pull request swiftlang#62871 from kavon/5.8-main-actor-conversions-combo
[5.8🍒] Resolve ambiguity error for global-actor function conversions
2 parents 5a0eb50 + c0f3418 commit 76dfbf9

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3005,6 +3005,13 @@ ConstraintSystem::matchFunctionTypes(FunctionType *func1, FunctionType *func2,
30053005
return getTypeMatchFailure(locator);
30063006
} else if (kind < ConstraintKind::Subtype) {
30073007
return getTypeMatchFailure(locator);
3008+
} else {
3009+
// It is possible to convert from a function without a global actor to a
3010+
// similar function type that does have a global actor. But, since there
3011+
// is a function conversion going on here, let's increase the score to
3012+
// avoid ambiguity when solver can also match a global actor matching
3013+
// function type.
3014+
increaseScore(SK_FunctionConversion);
30083015
}
30093016
}
30103017

test/Concurrency/global_actor_function_types.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,3 +153,10 @@ func test() {
153153
onSomeGlobalActor()
154154
}
155155
}
156+
157+
// https://github.com/apple/swift/issues/61436
158+
let x: @MainActor () -> Void
159+
160+
let y: () -> Void = {}
161+
162+
x = true ? y : y // Ok

0 commit comments

Comments
 (0)