mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[AST/Sema] Remove TypeWrapper feature functionality
This commit is contained in:
@@ -1690,51 +1690,6 @@ namespace {
|
||||
return fnTy->castTo<FunctionType>()->getResult();
|
||||
};
|
||||
|
||||
auto isAssignmentDestination = [&](ConstraintLocatorBuilder locator) {
|
||||
if (auto *anchor = getAsExpr(locator.getAnchor())) {
|
||||
if (auto *assignment =
|
||||
getAsExpr<AssignExpr>(cs.getParentExpr(anchor)))
|
||||
return assignment->getDest() == anchor;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
// If this is a reference to an immutable type wrapper
|
||||
// managed property used as an assignment destination
|
||||
// i.e. `self.<name> = ...` in an initializer context,
|
||||
// let's rewrite member access from `self` to `_storage`
|
||||
// injected by the compiler to support type wrapper
|
||||
// initialization.
|
||||
//
|
||||
// Note that this is safe to do only for immutable
|
||||
// properties because they do no support re-assignment.
|
||||
if (isa<ConstructorDecl>(cs.DC) && varDecl->isLet() &&
|
||||
varDecl->isAccessedViaTypeWrapper() &&
|
||||
isAssignmentDestination(memberLocator)) {
|
||||
auto *ctor = cast<ConstructorDecl>(cs.DC);
|
||||
auto *storageVar = ctor->getLocalTypeWrapperStorageVar();
|
||||
auto *storageVarTy =
|
||||
storageVar->getInterfaceType()->castTo<TupleType>();
|
||||
|
||||
base =
|
||||
new (context) DeclRefExpr(storageVar, DeclNameLoc(base->getLoc()),
|
||||
/*implicit=*/true);
|
||||
base->setType(
|
||||
LValueType::get(ctor->mapTypeIntoContext(storageVarTy)));
|
||||
|
||||
cs.cacheType(base);
|
||||
|
||||
Expr *memberRefExpr = new (context) TupleElementExpr(
|
||||
base, /*DotLoc=*/SourceLoc(),
|
||||
storageVarTy->getNamedElementId(varDecl->getName()),
|
||||
memberLoc.getBaseNameLoc(), resultType(refTy));
|
||||
memberRefExpr->setImplicit();
|
||||
|
||||
cs.cacheType(memberRefExpr);
|
||||
|
||||
return forceUnwrapIfExpected(memberRefExpr, memberLocator);
|
||||
}
|
||||
|
||||
if (isUnboundInstanceMember) {
|
||||
assert(memberLocator.getBaseLocator() &&
|
||||
cs.UnevaluatedRootExprs.count(
|
||||
|
||||
Reference in New Issue
Block a user