Skip to content

Commit 82ca1ca

Browse files
committed
Sema: Score function conversions.
Break an ambiguity when overloads for e.g. [() -> ()] and [() throws -> ()] exist.
1 parent 21c15d8 commit 82ca1ca

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

Diff for: lib/Sema/CSSimplify.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,8 @@ ConstraintSystem::matchFunctionTypes(FunctionType *func1, FunctionType *func2,
913913

914914
unsigned subFlags = flags | TMF_GenerateConstraints;
915915

916+
increaseScore(ScoreKind::SK_FunctionConversion);
917+
916918
// Input types can be contravariant (or equal).
917919
SolutionKind result = matchTypes(func2->getInput(), func1->getInput(),
918920
subKind, subFlags,

Diff for: test/Constraints/collection-of-function.swift

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// RUN: %target-swift-frontend -parse -verify %s
2+
3+
func foo(_:[() -> ()]){}
4+
func foo(_:[() throws -> ()]){}
5+
6+
func x() {}
7+
8+
var bs = [x]
9+
10+
foo(bs)

0 commit comments

Comments
 (0)