Skip to content

Commit 141a0b0

Browse files
committed
SILGen: Remove assertion that rejected context-free nested functions in generic contexts when referenced as C function pointers.
A ConcreteDeclRef to a nested function will include substitutions for its enclosing generic parameters, even if they aren't captured by use locally within the function. The assertion here is probably unnecessary since inconsistencies here should be caught by assertions elsewhere. Fixes SR-5023 | rdar://problem/32426540.
1 parent 351ffab commit 141a0b0

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

lib/SILGen/SILGenExpr.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,8 +1483,6 @@ ManagedValue emitCFunctionPointer(SILGenFunction &gen,
14831483
// in the metatype.
14841484
assert(!declRef.getDecl()->getDeclContext()->isTypeContext()
14851485
&& "c pointers to static methods not implemented");
1486-
assert(declRef.getSubstitutions().empty()
1487-
&& "c pointers to generics not implemented");
14881486
loc = declRef.getDecl();
14891487
};
14901488

test/SILGen/c_function_pointers.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,9 @@ struct StructWithInitializers {
6363
init(a: ()) {}
6464
init(b: ()) {}
6565
}
66+
67+
func pointers_to_nested_local_functions_in_generics<T>(x: T) -> Int{
68+
func foo(y: Int) -> Int { return y }
69+
70+
return calls(foo, 0)
71+
}

0 commit comments

Comments
 (0)