Skip to content

Commit 042939e

Browse files
[ConstraintSystem] Move some property wrappers implementation form header to cpp file
1 parent 21f5032 commit 042939e

File tree

2 files changed

+56
-47
lines changed

2 files changed

+56
-47
lines changed

lib/Sema/ConstraintSystem.cpp

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -928,6 +928,59 @@ TypeVariableType *ConstraintSystem::isRepresentativeFor(
928928
return *member;
929929
}
930930

931+
Optional<std::pair<VarDecl *, Type>>
932+
ConstraintSystem::getStorageWrapperInformation(SelectedOverload resolvedOverload) {
933+
if (resolvedOverload.choice.isDecl()) {
934+
if (auto *decl = dyn_cast<VarDecl>(resolvedOverload.choice.getDecl())) {
935+
if (decl->hasAttachedPropertyWrapper()) {
936+
if (auto storageWrapper = decl->getPropertyWrapperStorageWrapper()) {
937+
Type type = storageWrapper->getInterfaceType();
938+
if (Type baseType = resolvedOverload.choice.getBaseType()) {
939+
type = baseType->getTypeOfMember(DC->getParentModule(),
940+
storageWrapper, type);
941+
}
942+
return std::make_pair(decl, type);
943+
}
944+
}
945+
}
946+
}
947+
return None;
948+
}
949+
950+
Optional<std::pair<VarDecl *, Type>>
951+
ConstraintSystem::getPropertyWrapperInformation(SelectedOverload resolvedOverload) {
952+
if (resolvedOverload.choice.isDecl()) {
953+
if (auto *decl = dyn_cast<VarDecl>(resolvedOverload.choice.getDecl())) {
954+
if (decl->hasAttachedPropertyWrapper()) {
955+
auto wrapperTy = decl->getPropertyWrapperBackingPropertyType();
956+
if (Type baseType = resolvedOverload.choice.getBaseType()) {
957+
wrapperTy = baseType->getTypeOfMember(DC->getParentModule(),
958+
decl, wrapperTy);
959+
}
960+
return std::make_pair(decl, wrapperTy);
961+
}
962+
}
963+
}
964+
return None;
965+
}
966+
967+
Optional<std::pair<VarDecl *, Type>>
968+
ConstraintSystem::getWrappedPropertyInformation(SelectedOverload resolvedOverload) {
969+
if (resolvedOverload.choice.isDecl()) {
970+
if (auto *decl = dyn_cast<VarDecl>(resolvedOverload.choice.getDecl())) {
971+
if (auto wrapped = decl->getOriginalWrappedProperty()) {
972+
Type type = wrapped->getInterfaceType();
973+
if (Type baseType = resolvedOverload.choice.getBaseType()) {
974+
type = baseType->getTypeOfMember(DC->getParentModule(),
975+
wrapped, type);
976+
}
977+
return std::make_pair(decl, type);
978+
}
979+
}
980+
}
981+
return None;
982+
}
983+
931984
/// Does a var or subscript produce an l-value?
932985
///
933986
/// \param baseType - the type of the base on which this object

lib/Sema/ConstraintSystem.h

Lines changed: 3 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -3080,62 +3080,18 @@ class ConstraintSystem {
30803080
/// Gets the VarDecl associateed with resolvedOverload, and the type of the
30813081
/// storage wrapper if the decl has an associated storage wrapper.
30823082
Optional<std::pair<VarDecl *, Type>>
3083-
getStorageWrapperInformation(SelectedOverload resolvedOverload) {
3084-
if (resolvedOverload.choice.isDecl()) {
3085-
if (auto *decl = dyn_cast<VarDecl>(resolvedOverload.choice.getDecl())) {
3086-
if (decl->hasAttachedPropertyWrapper()) {
3087-
if (auto storageWrapper = decl->getPropertyWrapperStorageWrapper()) {
3088-
Type type = storageWrapper->getInterfaceType();
3089-
if (Type baseType = resolvedOverload.choice.getBaseType()) {
3090-
type = baseType->getTypeOfMember(DC->getParentModule(),
3091-
storageWrapper, type);
3092-
}
3093-
return std::make_pair(decl, type);
3094-
}
3095-
}
3096-
}
3097-
}
3098-
return None;
3099-
}
3083+
getStorageWrapperInformation(SelectedOverload resolvedOverload);
31003084

31013085
/// Gets the VarDecl associateed with resolvedOverload, and the type of the
31023086
/// backing storage if the decl has an associated property wrapper.
31033087
Optional<std::pair<VarDecl *, Type>>
3104-
getPropertyWrapperInformation(SelectedOverload resolvedOverload) {
3105-
if (resolvedOverload.choice.isDecl()) {
3106-
if (auto *decl = dyn_cast<VarDecl>(resolvedOverload.choice.getDecl())) {
3107-
if (decl->hasAttachedPropertyWrapper()) {
3108-
auto wrapperTy = decl->getPropertyWrapperBackingPropertyType();
3109-
if (Type baseType = resolvedOverload.choice.getBaseType()) {
3110-
wrapperTy = baseType->getTypeOfMember(DC->getParentModule(),
3111-
decl, wrapperTy);
3112-
}
3113-
return std::make_pair(decl, wrapperTy);
3114-
}
3115-
}
3116-
}
3117-
return None;
3118-
}
3088+
getPropertyWrapperInformation(SelectedOverload resolvedOverload);
31193089

31203090
/// Gets the VarDecl, and the type of the type property that it wraps if
31213091
/// resolved overload has a decl which is the backing storage for a
31223092
/// property wrapper.
31233093
Optional<std::pair<VarDecl *, Type>>
3124-
getWrappedPropertyInformation(SelectedOverload resolvedOverload) {
3125-
if (resolvedOverload.choice.isDecl()) {
3126-
if (auto *decl = dyn_cast<VarDecl>(resolvedOverload.choice.getDecl())) {
3127-
if (auto wrapped = decl->getOriginalWrappedProperty()) {
3128-
Type type = wrapped->getInterfaceType();
3129-
if (Type baseType = resolvedOverload.choice.getBaseType()) {
3130-
type = baseType->getTypeOfMember(DC->getParentModule(),
3131-
wrapped, type);
3132-
}
3133-
return std::make_pair(decl, type);
3134-
}
3135-
}
3136-
}
3137-
return None;
3138-
}
3094+
getWrappedPropertyInformation(SelectedOverload resolvedOverload);
31393095

31403096
/// Merge the equivalence sets of the two type variables.
31413097
///

0 commit comments

Comments
 (0)