@@ -89,13 +89,14 @@ static ParamDecl *buildInOutArgument(SourceLoc loc, DeclContext *DC,
89
89
}
90
90
91
91
static Type getTypeOfStorage (AbstractStorageDecl *storage,
92
- TypeChecker &TC,
93
92
bool wantInterfaceType) {
94
- if (auto var = dyn_cast<VarDecl>(storage))
95
- return TC.getTypeOfRValue (var, wantInterfaceType);
93
+ if (auto var = dyn_cast<VarDecl>(storage)) {
94
+ auto type = (wantInterfaceType
95
+ ? var->getInterfaceType ()
96
+ : var->getType ());
97
+ return type->getReferenceStorageReferent ();
98
+ }
96
99
97
- // None of the transformations done by getTypeOfRValue are
98
- // necessary for subscripts.
99
100
auto subscript = cast<SubscriptDecl>(storage);
100
101
auto type = subscript->getElementInterfaceType ();
101
102
if (!wantInterfaceType)
@@ -156,7 +157,7 @@ static FuncDecl *createGetterPrototype(AbstractStorageDecl *storage,
156
157
staticLoc = var->getLoc ();
157
158
}
158
159
159
- auto storageInterfaceType = getTypeOfStorage (storage, TC, true );
160
+ auto storageInterfaceType = getTypeOfStorage (storage, true );
160
161
161
162
auto getter = FuncDecl::create (
162
163
TC.Context , staticLoc, StaticSpellingKind::None, loc, Identifier (), loc,
@@ -199,8 +200,8 @@ static FuncDecl *createSetterPrototype(AbstractStorageDecl *storage,
199
200
}
200
201
201
202
// Add a "(value : T, indices...)" argument list.
202
- auto storageType = getTypeOfStorage (storage, TC, false );
203
- auto storageInterfaceType = getTypeOfStorage (storage, TC, true );
203
+ auto storageType = getTypeOfStorage (storage, false );
204
+ auto storageInterfaceType = getTypeOfStorage (storage, true );
204
205
valueDecl = buildLetArgument (storage->getLoc (),
205
206
storage->getDeclContext (), " value" ,
206
207
storageType,
@@ -615,7 +616,7 @@ static Expr *synthesizeCopyWithZoneCall(Expr *Val, VarDecl *VD,
615
616
616
617
// We support @NSCopying on class types (which conform to NSCopying),
617
618
// protocols which conform, and option types thereof.
618
- Type UnderlyingType = TC. getTypeOfRValue (VD, /* want interface type */ false );
619
+ Type UnderlyingType = VD-> getType ()-> getReferenceStorageReferent ( );
619
620
620
621
bool isOptional = false ;
621
622
if (Type optionalEltTy = UnderlyingType->getAnyOptionalObjectType ()) {
@@ -1930,8 +1931,10 @@ ConstructorDecl *swift::createImplicitConstructor(TypeChecker &tc,
1930
1931
1931
1932
accessLevel = std::min (accessLevel, var->getFormalAccess ());
1932
1933
1933
- auto varType = tc.getTypeOfRValue (var, false );
1934
- auto varInterfaceType = tc.getTypeOfRValue (var, true );
1934
+ auto varType = var->getType ()
1935
+ ->getReferenceStorageReferent ();
1936
+ auto varInterfaceType = var->getInterfaceType ()
1937
+ ->getReferenceStorageReferent ();
1935
1938
1936
1939
// If var is a lazy property, its value is provided for the underlying
1937
1940
// storage. We thus take an optional of the properties type. We only
0 commit comments