Skip to content

Commit fe1d3ca

Browse files
authored
Merge pull request #18268 from DougGregor/request-layout-call-result
2 parents ca5eacf + 76eb767 commit fe1d3ca

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

lib/Sema/CSApply.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7498,6 +7498,11 @@ Expr *ExprRewriter::finishApply(ApplyExpr *apply, Type openedType,
74987498
cs.setType(apply, fnType->getResult());
74997499
apply->setIsSuper(isSuper);
75007500

7501+
// We need the layout of nominal types returned from a function call.
7502+
if (auto nominalResult = fnType->getResult()->getAnyNominal()) {
7503+
tc.requestNominalLayout(nominalResult);
7504+
}
7505+
75017506
cs.setExprTypes(apply);
75027507
Expr *result = tc.substituteInputSugarTypeForResult(apply);
75037508
cs.cacheExprTypes(result);
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
func foo<T, U: C<T>>(_ t: T, _ u: U) {
2+
// Calling a function that returns a C<T> requests its layout
3+
_ = bar(t, u)
4+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// RUN: %target-typecheck-verify-swift -module-name test -primary-file %S/Inputs/require-layout-call-result-primary.swift
2+
3+
4+
class C<T> {
5+
dynamic func broken() { } // expected-error{{'dynamic'}}
6+
}
7+
8+
func bar<T, U: C<T>>(_ t: T, _ u: U) -> C<T> { return u }

0 commit comments

Comments
 (0)