Skip to content

[vs2017] Adapt some variadic template aliases to not trip MSVC 2017. #37284

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions include/swift/ABI/Metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -2906,8 +2906,13 @@ class TargetGenericEnvironment
uint16_t, GenericParamDescriptor, GenericRequirementDescriptor>;
friend TrailingObjects;

#if !defined(_MSC_VER) || _MSC_VER >= 1920
template<typename T>
using OverloadToken = typename TrailingObjects::template OverloadToken<T>;
#else
// MSVC 2017 trips parsing an using of an using, of a variadic template
#define OverloadToken typename TrailingObjects::template OverloadToken
#endif

size_t numTrailingObjects(OverloadToken<uint16_t>) const {
return Flags.getNumGenericParameterLevels();
Expand All @@ -2921,6 +2926,10 @@ class TargetGenericEnvironment
return Flags.getNumGenericRequirements();
}

#if defined(_MSC_VER) && _MSC_VER < 1920
#undef OverloadToken
#endif

GenericEnvironmentFlags Flags;

public:
Expand Down Expand Up @@ -2982,8 +2991,13 @@ class TrailingGenericContextObjects<TargetSelf<Runtime>,
FollowingTrailingObjects...>;
friend TrailingObjects;

#if !defined(_MSC_VER) || _MSC_VER >= 1920
template<typename T>
using OverloadToken = typename TrailingObjects::template OverloadToken<T>;
#else
// MSVC 2017 trips parsing an using of an using, of a variadic template
#define OverloadToken typename TrailingObjects::template OverloadToken
#endif

const Self *asSelf() const {
return static_cast<const Self *>(this);
Expand Down Expand Up @@ -3047,6 +3061,11 @@ class TrailingGenericContextObjects<TargetSelf<Runtime>,
size_t numTrailingObjects(OverloadToken<GenericRequirementDescriptor>) const {
return asSelf()->isGeneric() ? getGenericContextHeader().NumRequirements : 0;
}

#if defined(_MSC_VER) && _MSC_VER < 1920
#undef OverloadToken
#endif

};

/// Reference to a generic context.
Expand Down