Skip to content

Commit 6a597d4

Browse files
authored
Merge pull request #33945 from jckarter/serialized-capture-opaque-type-subst-assert
SILGen: Relax assertion that incorrectly tripped on lowered opaque capture types.
2 parents 4d0ab13 + 023066c commit 6a597d4

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

lib/SILGen/SILGenThunk.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,14 @@ SILGenFunction::emitGlobalFunctionRef(SILLocation loc, SILDeclRef constant,
124124
}
125125

126126
auto f = SGM.getFunction(constant, NotForDefinition);
127-
assert(f->getLoweredFunctionTypeInContext(B.getTypeExpansionContext()) ==
128-
constantInfo.SILFnType);
127+
#ifndef NDEBUG
128+
auto constantFnTypeInContext =
129+
SGM.Types.getLoweredType(constantInfo.SILFnType,
130+
B.getTypeExpansionContext())
131+
.castTo<SILFunctionType>();
132+
assert(f->getLoweredFunctionTypeInContext(B.getTypeExpansionContext())
133+
== constantFnTypeInContext);
134+
#endif
129135
if (callPreviousDynamicReplaceableImpl)
130136
return B.createPreviousDynamicFunctionRef(loc, f);
131137
else
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: %target-swift-frontend -disable-availability-checking -emit-silgen -verify %s
2+
3+
public func foo() -> some Any { return 1 }
4+
5+
public struct XY<X, Y> { public init(x: X, y: Y) { fatalError() } }
6+
7+
@inlinable
8+
public func bar() -> () -> Any {
9+
let xy = XY(x: 1, y: foo())
10+
11+
return { xy }
12+
}

0 commit comments

Comments
 (0)