Skip to content

Commit

Permalink
SIL: Add test case for <rdar://problem/24470533>
Browse files Browse the repository at this point in the history
This is one of the reductions from
<https://bugs.swift.org/browse/SR-661>.
  • Loading branch information
slavapestov committed Feb 19, 2016
1 parent f0a960b commit 527c814
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test/SILGen/generic_closures.swift
Expand Up @@ -144,3 +144,18 @@ func shmassert(@autoclosure f: () -> Bool) {}
func capture_generic_param<A: Fooable>(x: A) {
shmassert(A.foo())
}

// Make sure we use the correct convention when capturing class-constrained
// member types: <rdar://problem/24470533>
class Class {}

protocol HasClassAssoc { associatedtype Assoc : Class }

// CHECK-LABEL: sil hidden @_TF16generic_closures34captures_class_constrained_genericuRxS_13HasClassAssocrFTx1fFwx5AssocwxS1__T_
// CHECK: bb0(%0 : $*T, %1 : $@callee_owned (@owned T.Assoc) -> @owned T.Assoc):
// CHECK: [[GENERIC_FN:%.*]] = function_ref @_TFF16generic_closures34captures_class_constrained_genericuRxS_13HasClassAssocrFTx1fFwx5AssocwxS1__T_U_FT_FQQ_5AssocS2_
// CHECK: [[CONCRETE_FN:%.*]] = partial_apply [[GENERIC_FN]]<T, T.Assoc>(%1)

func captures_class_constrained_generic<T : HasClassAssoc>(x: T, f: T.Assoc -> T.Assoc) {
let _: () -> T.Assoc -> T.Assoc = { f }
}

1 comment on commit 527c814

@slavapestov
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I should've added -- this is a bug specific in 2.2, and was fixed in 3.0 with some other cleanups to AbstractionPattern. So the full fix is going into swift-2.2-branch, but I'm just adding a regression test to master.

Please sign in to comment.