[Property Wrappers] Use the outermost wrapper attribute type as the

contextual type for property wrapper initialization
This commit is contained in:
Holly Borla
2020-04-13 17:13:22 -07:00
parent 829f2588b3
commit df7735e545
2 changed files with 16 additions and 0 deletions

View File

@@ -4219,6 +4219,7 @@ void SolutionApplicationTarget::maybeApplyPropertyWrapper() {
// the initializer type later.
expression.wrappedVar = singleVar;
expression.expression = backingInitializer;
expression.convertType = outermostWrapperAttr->getTypeLoc();
}
SolutionApplicationTarget SolutionApplicationTarget::forInitialization(

View File

@@ -19,3 +19,18 @@ let _: A<Int>.C = 0
// expected-error@-1 {{'A<Int>.C' (aka 'Int') requires the types 'Int' and 'Int32' be equivalent}}
let _: A<Int>.B.E = 0
// expected-error@-1 {{'A<Int>.B' requires the types 'Int' and 'Int32' be equivalent}}
protocol P {}
@propertyWrapper
struct Wrapper<T: P> { // 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
}