Skip to content

Commit d023147

Browse files
authored
Merge pull request #62514 from LucianoPAlmeida/contextual-ambiguous
[CS] Increase the score for implicit global actor function conversion
2 parents d6ed370 + 187cf81 commit d023147

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)