Skip to content

Commit be2867f

Browse files
committed
[SE-0258] Fix crash-on-invalid involving some wrappers with wrapperValue
Fixes rdar://problem/51193573.
1 parent 80aad10 commit be2867f

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

lib/Sema/CodeSynthesis.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1734,7 +1734,7 @@ PropertyWrapperBackingPropertyInfoRequest::evaluate(Evaluator &evaluator,
17341734
VarDecl *var) const {
17351735
// Determine the type of the backing property.
17361736
auto wrapperType = var->getPropertyWrapperBackingPropertyType();
1737-
if (!wrapperType)
1737+
if (!wrapperType || wrapperType->hasError())
17381738
return PropertyWrapperBackingPropertyInfo();
17391739

17401740
auto wrapperInfo = var->getAttachedPropertyWrapperTypeInfo();

test/decl/var/property_wrappers.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -714,3 +714,20 @@ struct TestPD {
714714
@PD(a: "foo") var foo: Int = 42 // expected-error{{property 'foo' with attached wrapper cannot initialize both the wrapper type and the property}}
715715
// expected-error@-1{{missing argument for parameter 'initialValue' in call}}
716716
}
717+
718+
protocol P { }
719+
720+
@_propertyWrapper
721+
struct WrapperRequiresP<T: P> {
722+
var value: T
723+
var wrapperValue: T { return value }
724+
}
725+
726+
struct UsesWrapperRequiringP {
727+
// expected-note@-1{{in declaration of}}
728+
729+
@WrapperRequiresP var x.: UsesWrapperRequiringP
730+
// expected-error@-1{{expected member name following '.'}}
731+
// expected-error@-2{{expected declaration}}
732+
// expected-error@-3{{type annotation missing in pattern}}
733+
}

0 commit comments

Comments
 (0)