Skip to content

Commit bbd6d53

Browse files
[ConstraintSystem] Move implementation of isRepresentativeFor to cpp instead of inline in the header
1 parent f7234a3 commit bbd6d53

File tree

2 files changed

+26
-23
lines changed

2 files changed

+26
-23
lines changed

lib/Sema/ConstraintSystem.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -899,6 +899,31 @@ Type ConstraintSystem::getFixedTypeRecursive(Type type,
899899
return type;
900900
}
901901

902+
TypeVariableType *ConstraintSystem::isRepresentativeFor(
903+
TypeVariableType *typeVar, ConstraintLocator::PathElementKind kind) const {
904+
// We only attempt to look for this if type variable is
905+
// a representative.
906+
if (getRepresentative(typeVar) != typeVar)
907+
return nullptr;
908+
909+
auto &CG = getConstraintGraph();
910+
auto result = CG.lookupNode(typeVar);
911+
auto equivalence = result.first.getEquivalenceClass();
912+
auto member = llvm::find_if(equivalence, [=](TypeVariableType *eq) {
913+
auto *loc = eq->getImpl().getLocator();
914+
if (!loc)
915+
return false;
916+
917+
auto path = loc->getPath();
918+
return !path.empty() && path.back().getKind() == kind;
919+
});
920+
921+
if (member == equivalence.end())
922+
return nullptr;
923+
924+
return *member;
925+
}
926+
902927
/// Does a var or subscript produce an l-value?
903928
///
904929
/// \param baseType - the type of the base on which this object

lib/Sema/ConstraintSystem.h

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3076,29 +3076,7 @@ class ConstraintSystem {
30763076
/// If true returns the type variable which it is the representative for.
30773077
TypeVariableType *
30783078
isRepresentativeFor(TypeVariableType *typeVar,
3079-
ConstraintLocator::PathElementKind kind) const {
3080-
// We only attempt to look for this if type variable is
3081-
// a representative.
3082-
if (getRepresentative(typeVar) != typeVar)
3083-
return nullptr;
3084-
3085-
auto &CG = getConstraintGraph();
3086-
auto result = CG.lookupNode(typeVar);
3087-
auto equivalence = result.first.getEquivalenceClass();
3088-
auto member = llvm::find_if(equivalence, [=](TypeVariableType *eq) {
3089-
auto *loc = eq->getImpl().getLocator();
3090-
if (!loc)
3091-
return false;
3092-
3093-
auto path = loc->getPath();
3094-
return !path.empty() && path.back().getKind() == kind;
3095-
});
3096-
3097-
if (member == equivalence.end())
3098-
return nullptr;
3099-
3100-
return *member;
3101-
}
3079+
ConstraintLocator::PathElementKind kind) const;
31023080

31033081
/// Gets the VarDecl associateed with resolvedOverload, and the type of the
31043082
/// storage wrapper if the decl has an associated storage wrapper.

0 commit comments

Comments
 (0)