diff --git a/lib/Sema/ConstraintSystem.cpp b/lib/Sema/ConstraintSystem.cpp index d9c203dead0..b23a05e9ec4 100644 --- a/lib/Sema/ConstraintSystem.cpp +++ b/lib/Sema/ConstraintSystem.cpp @@ -4219,6 +4219,7 @@ void SolutionApplicationTarget::maybeApplyPropertyWrapper() { // the initializer type later. expression.wrappedVar = singleVar; expression.expression = backingInitializer; + expression.convertType = outermostWrapperAttr->getTypeLoc(); } SolutionApplicationTarget SolutionApplicationTarget::forInitialization( diff --git a/test/Constraints/requirement_failures_in_contextual_type.swift b/test/Constraints/requirement_failures_in_contextual_type.swift index d7896b494bc..31eb477fa71 100644 --- a/test/Constraints/requirement_failures_in_contextual_type.swift +++ b/test/Constraints/requirement_failures_in_contextual_type.swift @@ -19,3 +19,18 @@ let _: A.C = 0 // expected-error@-1 {{'A.C' (aka 'Int') requires the types 'Int' and 'Int32' be equivalent}} let _: A.B.E = 0 // expected-error@-1 {{'A.B' requires the types 'Int' and 'Int32' be equivalent}} + + +protocol P {} + +@propertyWrapper +struct Wrapper { // expected-note {{where 'T' = 'Int'}} + var wrappedValue: T +} + +class C { + static let i = 1 + + @Wrapper // expected-error{{generic struct 'Wrapper' requires that 'Int' conform to 'P'}} + var value = C.i +}