Skip to content

Commit fbb1537

Browse files
committed
IDE: Use methods on TypeBase instead of going through canSatisfy()
1 parent 27d3331 commit fbb1537

File tree

4 files changed

+10
-28
lines changed

4 files changed

+10
-28
lines changed

include/swift/Sema/IDETypeChecking.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,6 @@ namespace swift {
4747
/// \returns true on convertible, false on not.
4848
bool isConvertibleTo(Type T1, Type T2, bool openArchetypes, DeclContext &DC);
4949

50-
bool isEqual(Type T1, Type T2, DeclContext &DC);
51-
52-
bool canPossiblyEqual(Type T1, Type T2, DeclContext &DC);
53-
5450
void collectDefaultImplementationForProtocolMembers(ProtocolDecl *PD,
5551
llvm::SmallDenseMap<ValueDecl*, ValueDecl*> &DefaultMap);
5652

include/swift/Sema/IDETypeCheckingRequests.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,6 @@ class IsDeclApplicableRequest:
8787
// Type relation checking
8888
//----------------------------------------------------------------------------//
8989
enum class TypeRelation: uint8_t {
90-
EqualTo,
91-
PossiblyEqualTo,
9290
ConvertTo,
9391
};
9492

@@ -158,8 +156,6 @@ struct TypeRelationCheckInput {
158156
out << " is ";
159157
switch(owner.Relation) {
160158
#define CASE(NAME) case TypeRelation::NAME: out << #NAME << " "; break;
161-
CASE(EqualTo)
162-
CASE(PossiblyEqualTo)
163159
CASE(ConvertTo)
164160
#undef CASE
165161
}

lib/IDE/IDETypeChecking.cpp

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,6 @@ struct SynthesizedExtensionAnalyzer::Implementation {
325325

326326
switch (Kind) {
327327
case RequirementKind::Conformance:
328-
case RequirementKind::Superclass:
329328
// FIXME: This could be more accurate; check
330329
// conformance instead of subtyping
331330
if (!isConvertibleTo(First, Second, /*openArchetypes=*/true, *DC))
@@ -335,8 +334,17 @@ struct SynthesizedExtensionAnalyzer::Implementation {
335334
MergeInfo.addRequirement(GenericSig, First, Second, Kind);
336335
break;
337336

337+
case RequirementKind::Superclass:
338+
if (!Second->isBindableToSuperclassOf(First)) {
339+
return true;
340+
} else if (!Second->isExactSuperclassOf(Second)) {
341+
MergeInfo.addRequirement(GenericSig, First, Second, Kind);
342+
}
343+
break;
344+
338345
case RequirementKind::SameType:
339-
if (!canPossiblyEqual(First, Second, *DC)) {
346+
if (!First->isBindableTo(Second) &&
347+
!Second->isBindableTo(First)) {
340348
return true;
341349
} else if (!First->isEqual(Second)) {
342350
MergeInfo.addRequirement(GenericSig, First, Second, Kind);
@@ -753,19 +761,6 @@ bool swift::isMemberDeclApplied(const DeclContext *DC, Type BaseTy,
753761
IsDeclApplicableRequest(DeclApplicabilityOwner(DC, BaseTy, VD)), false);
754762
}
755763

756-
bool swift::canPossiblyEqual(Type T1, Type T2, DeclContext &DC) {
757-
return evaluateOrDefault(DC.getASTContext().evaluator,
758-
TypeRelationCheckRequest(TypeRelationCheckInput(&DC, T1, T2,
759-
TypeRelation::PossiblyEqualTo, true)), false);
760-
}
761-
762-
763-
bool swift::isEqual(Type T1, Type T2, DeclContext &DC) {
764-
return evaluateOrDefault(DC.getASTContext().evaluator,
765-
TypeRelationCheckRequest(TypeRelationCheckInput(&DC, T1, T2,
766-
TypeRelation::EqualTo, true)), false);
767-
}
768-
769764
bool swift::isConvertibleTo(Type T1, Type T2, bool openArchetypes,
770765
DeclContext &DC) {
771766
return evaluateOrDefault(DC.getASTContext().evaluator,

lib/Sema/IDETypeCheckingRequests.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,6 @@ TypeRelationCheckRequest::evaluate(Evaluator &evaluator,
104104
TypeRelationCheckInput Owner) const {
105105
Optional<constraints::ConstraintKind> CKind;
106106
switch (Owner.Relation) {
107-
case TypeRelation::EqualTo:
108-
return Owner.Pair.FirstTy->isEqual(Owner.Pair.SecondTy);
109-
case TypeRelation::PossiblyEqualTo:
110-
CKind = constraints::ConstraintKind::Bind;
111-
break;
112107
case TypeRelation::ConvertTo:
113108
CKind = constraints::ConstraintKind::Conversion;
114109
break;

0 commit comments

Comments
 (0)