Skip to content

Commit 7dacc5e

Browse files
committed
Sema: adoptee->getAnyNominal() => dc->getSelfNominalTypeDecl()
1 parent 1a72ca1 commit 7dacc5e

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

lib/Sema/TypeCheckProtocolInference.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -593,8 +593,10 @@ AssociatedTypeInference::inferTypeWitnessesViaAssociatedType(
593593
// Look for types with the given default name that have appropriate
594594
// @_implements attributes.
595595
SmallVector<ValueDecl *, 4> lookupResults;
596-
dc->lookupQualified(adoptee->getAnyNominal(), defaultName,
597-
adoptee->getAnyNominal()->getStartLoc(),
596+
dc->lookupQualified(dc->getSelfNominalTypeDecl(), defaultName,
597+
isa<ExtensionDecl>(dc)
598+
? cast<ExtensionDecl>(dc)->getStartLoc()
599+
: cast<NominalTypeDecl>(dc)->getStartLoc(),
598600
subOptions, lookupResults);
599601

600602
InferredAssociatedTypesByWitnesses result;
@@ -819,7 +821,7 @@ Type AssociatedTypeInference::computeFixedTypeWitness(
819821

820822
// Look at all of the inherited protocols to determine whether they
821823
// require a fixed type for this associated type.
822-
for (auto conformedProto : adoptee->getAnyNominal()->getAllProtocols()) {
824+
for (auto conformedProto : dc->getSelfNominalTypeDecl()->getAllProtocols()) {
823825
if (conformedProto != assocType->getProtocol() &&
824826
!conformedProto->inheritsFrom(assocType->getProtocol()))
825827
continue;
@@ -888,7 +890,7 @@ AssociatedTypeInference::computeDerivedTypeWitness(
888890
return std::make_pair(Type(), nullptr);
889891

890892
// Can we derive conformances for this protocol and adoptee?
891-
NominalTypeDecl *derivingTypeDecl = adoptee->getAnyNominal();
893+
NominalTypeDecl *derivingTypeDecl = dc->getSelfNominalTypeDecl();
892894
if (!DerivedConformance::derivesProtocolConformance(dc, derivingTypeDecl,
893895
proto))
894896
return std::make_pair(Type(), nullptr);
@@ -942,7 +944,7 @@ void AssociatedTypeInference::collectAbstractTypeWitnesses(
942944
// First, look at all the protocols the adoptee conforms to and feed the
943945
// same-type constraints in their requirement signatures to the system.
944946
for (auto *const conformedProto :
945-
adoptee->getAnyNominal()->getAllProtocols(/*sorted=*/true)) {
947+
dc->getSelfNominalTypeDecl()->getAllProtocols(/*sorted=*/true)) {
946948
// FIXME: The RequirementMachine will assert on re-entrant construction.
947949
// We should find a more principled way of breaking this cycle.
948950
if (ctx.isRecursivelyConstructingRequirementMachine(

0 commit comments

Comments
 (0)