Skip to content

Commit c305b57

Browse files
authored
Merge pull request #37407 from hborla/wrapped-parameter-serialization
[Property Wrappers] Fix a crash in merge-modules with wrapped parameters.
2 parents e87f237 + df43914 commit c305b57

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

lib/Sema/TypeCheckPropertyWrapper.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,11 @@ PropertyWrapperBackingPropertyTypeRequest::evaluate(
622622
if (!type)
623623
return Type();
624624

625+
// If the declaration came from a module file, there's no need to
626+
// compute the auxiliary variables.
627+
if (!var->getDeclContext()->getParentSourceFile())
628+
return type;
629+
625630
// Set the interface type of each synthesized declaration.
626631
auto auxiliaryVars = var->getPropertyWrapperAuxiliaryVariables();
627632
auxiliaryVars.backingVar->setInterfaceType(type);
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-swift-frontend -emit-module-path %t/WrappedParameter.swiftmodule -emit-module-source-info-path %t/WrappedParameter.swiftsourceinfo -module-name WrappedParameter -enable-testing %s
3+
// RUN: %target-swift-frontend -merge-modules -emit-module %t/WrappedParameter.swiftmodule -module-name WrappedParameter -o %t/WrappedParameter.swiftmodule
4+
5+
// Make sure wrapped parameters don't crash in merge-modules when
6+
// they were compiled with -emit-module-source-info and -enable-testing.
7+
8+
@propertyWrapper
9+
struct ProjectionWrapper<Value> {
10+
var wrappedValue: Value
11+
12+
var projectedValue: Self { self }
13+
14+
public init(projectedValue: Self) {
15+
self = projectedValue
16+
}
17+
}
18+
19+
func test(@ProjectionWrapper value: Int) {}

0 commit comments

Comments
 (0)