Skip to content

Commit 187cf81

Browse files
[CS] Increase the score for implicit global actor function conversion
1 parent 45cd83d commit 187cf81

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
@@ -3020,6 +3020,13 @@ ConstraintSystem::matchFunctionTypes(FunctionType *func1, FunctionType *func2,
30203020
return getTypeMatchFailure(locator);
30213021
} else if (kind < ConstraintKind::Subtype) {
30223022
return getTypeMatchFailure(locator);
3023+
} else {
3024+
// It is possible to convert from a function without a global actor to a
3025+
// similar function type that does have a global actor. But, since there
3026+
// is a function conversion going on here, let's increase the score to
3027+
// avoid ambiguity when solver can also match a global actor matching
3028+
// function type.
3029+
increaseScore(SK_FunctionConversion);
30233030
}
30243031
}
30253032

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)