Skip to content

Commit ebe3aba

Browse files
authored
Merge pull request #12593 from xedin/rdar-35142121
[ConstraintSolver] Avoid unnecessarily increasing score when matching function types
2 parents dcb0673 + 66e13bc commit ebe3aba

File tree

5 files changed

+20
-4
lines changed

5 files changed

+20
-4
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,8 +1150,6 @@ ConstraintSystem::matchFunctionTypes(FunctionType *func1, FunctionType *func2,
11501150

11511151
TypeMatchOptions subflags = getDefaultDecompositionOptions(flags);
11521152

1153-
increaseScore(ScoreKind::SK_FunctionConversion);
1154-
11551153
// Add a very narrow exception to SE-0110 by allowing functions that
11561154
// take multiple arguments to be passed as an argument in places
11571155
// that expect a function that takes a single tuple (of the same

test/Constraints/function_conversion.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,9 @@ a(c.d)
3636
func b<T>(_: (T) -> () -> ()) {}
3737

3838
b(c.e)
39+
40+
func bar(_: () -> ()) {}
41+
func bar(_: () throws -> ()) {}
42+
func bar_empty() {}
43+
44+
bar(bar_empty)

test/Constraints/rdar35142121.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: %target-swift-frontend -emit-sil -verify %s | %FileCheck %s
2+
3+
func foo<T>(_ a: T) -> Int {
4+
return 0
5+
}
6+
7+
func foo(_ a: (Int) -> (Int)) -> Int {
8+
return 42
9+
}
10+
11+
// CHECK: function_ref @_T012rdar351421213fooS3icF : $@convention(thin) (@owned @noescape @callee_owned (Int) -> Int) -> Int
12+
let _ = foo({ (a: Int) -> Int in a + 1 })

validation-test/Sema/type_checker_perf/slow/rdar33292740.swift.gyb renamed to validation-test/Sema/type_checker_perf/fast/rdar33292740.swift.gyb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %scale-test --invert-result --begin 2 --end 7 --step 1 --select incrementScopeCounter %s
1+
// RUN: %scale-test --begin 2 --end 10 --step 1 --select incrementScopeCounter %s
22
// REQUIRES: OS=macosx
33
// REQUIRES: asserts
44

validation-test/Sema/type_checker_perf/slow/nil_coalescing.swift.gyb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %scale-test --invert-result --begin 1 --end 6 --step 1 --select incrementScopeCounter %s
1+
// RUN: %scale-test --invert-result --begin 1 --end 5 --step 1 --select incrementScopeCounter %s
22
// REQUIRES: OS=macosx
33
// REQUIRES: asserts
44

0 commit comments

Comments
 (0)