@@ -1283,7 +1283,7 @@ WitnessChecker::lookupValueWitnessesViaImplementsAttr(
1283
1283
ValueDecl *req, SmallVector<ValueDecl *, 4 > &witnesses) {
1284
1284
1285
1285
auto name = req->createNameRef ();
1286
- auto *nominal = Adoptee-> getAnyNominal ();
1286
+ auto *nominal = DC-> getSelfNominalTypeDecl ();
1287
1287
1288
1288
NLOptions subOptions = (NL_ProtocolMembers | NL_IncludeAttributeImplements);
1289
1289
@@ -1338,7 +1338,7 @@ WitnessChecker::lookupValueWitnesses(ValueDecl *req, bool *ignoringNames) {
1338
1338
}
1339
1339
1340
1340
if (doQualifiedLookup) {
1341
- auto *nominal = Adoptee-> getAnyNominal ();
1341
+ auto *nominal = DC-> getSelfNominalTypeDecl ();
1342
1342
nominal->synthesizeSemanticMembersIfNeeded (reqName.getFullName ());
1343
1343
1344
1344
// Unqualified lookup would have already found candidates from protocol
@@ -1551,7 +1551,7 @@ AccessScope WitnessChecker::getRequiredAccessScope() {
1551
1551
1552
1552
bool witnessesMustBeUsableFromInline = false ;
1553
1553
if (Adoptee) {
1554
- const NominalTypeDecl *adoptingNominal = Adoptee-> getAnyNominal ();
1554
+ const NominalTypeDecl *adoptingNominal = DC-> getSelfNominalTypeDecl ();
1555
1555
1556
1556
// Compute the intersection of the conforming type's access scope
1557
1557
// and the protocol's access scope.
@@ -2012,7 +2012,6 @@ checkIndividualConformance(NormalProtocolConformance *conformance,
2012
2012
2013
2013
// Dig out some of the fields from the conformance.
2014
2014
Type T = conformance->getType ();
2015
- auto canT = T->getCanonicalType ();
2016
2015
DeclContext *DC = conformance->getDeclContext ();
2017
2016
auto Proto = conformance->getProtocol ();
2018
2017
auto ProtoType = Proto->getDeclaredInterfaceType ();
@@ -2030,7 +2029,7 @@ checkIndividualConformance(NormalProtocolConformance *conformance,
2030
2029
}
2031
2030
2032
2031
// If the protocol requires a class, non-classes are a non-starter.
2033
- if (Proto->requiresClass () && !canT-> getClassOrBoundGenericClass ()) {
2032
+ if (Proto->requiresClass () && !DC-> getSelfClassDecl ()) {
2034
2033
C.Diags .diagnose (ComplainLoc,
2035
2034
diag::non_class_cannot_conform_to_class_protocol, T,
2036
2035
ProtoType);
@@ -2060,7 +2059,7 @@ checkIndividualConformance(NormalProtocolConformance *conformance,
2060
2059
2061
2060
if (Proto->isObjC ()) {
2062
2061
// Foreign classes cannot conform to objc protocols.
2063
- if (auto clazz = canT-> getClassOrBoundGenericClass ()) {
2062
+ if (auto clazz = DC-> getSelfClassDecl ()) {
2064
2063
Optional<decltype (diag::cf_class_cannot_conform_to_objc_protocol)>
2065
2064
diagKind;
2066
2065
switch (clazz->getForeignClassKind ()) {
@@ -2114,7 +2113,7 @@ checkIndividualConformance(NormalProtocolConformance *conformance,
2114
2113
// Not every protocol/type is compatible with conditional conformances.
2115
2114
auto conditionalReqs = conformance->getConditionalRequirementsIfAvailable ();
2116
2115
if (conditionalReqs && !conditionalReqs->empty ()) {
2117
- auto nestedType = canT ;
2116
+ auto nestedType = DC-> getSelfNominalTypeDecl ()-> getDeclaredInterfaceType () ;
2118
2117
// Obj-C generics cannot be looked up at runtime, so we don't support
2119
2118
// conditional conformances involving them. Check the full stack of nested
2120
2119
// types for any obj-c ones.
@@ -2129,7 +2128,7 @@ checkIndividualConformance(NormalProtocolConformance *conformance,
2129
2128
}
2130
2129
}
2131
2130
2132
- nestedType = nestedType. getNominalParent ();
2131
+ nestedType = nestedType-> getNominalParent ();
2133
2132
}
2134
2133
2135
2134
// If the protocol to which we are conditionally conforming is not a marker
@@ -3212,7 +3211,7 @@ bool ConformanceChecker::checkObjCTypeErasedGenerics(
3212
3211
if (!ctx.LangOpts .EnableObjCInterop && type->hasError ())
3213
3212
return false ;
3214
3213
3215
- auto classDecl = Adoptee-> getClassOrBoundGenericClass ();
3214
+ auto classDecl = DC-> getSelfClassDecl ();
3216
3215
if (!classDecl) return false ;
3217
3216
3218
3217
if (!classDecl->isTypeErasedGenericClass ()) return false ;
@@ -3784,7 +3783,7 @@ diagnoseMissingWitnesses(MissingWitnessDiagnosisKind Kind) {
3784
3783
for (auto &Missing : LocalMissing) {
3785
3784
auto requirement = Missing.requirement ;
3786
3785
auto matches = Missing.matches ;
3787
- auto nominal = Adoptee-> getAnyNominal ();
3786
+ auto nominal = DC-> getSelfNominalTypeDecl ();
3788
3787
3789
3788
diagnoseOrDefer (requirement, true ,
3790
3789
[requirement, matches, nominal](NormalProtocolConformance *conformance) {
@@ -4014,7 +4013,7 @@ getAdopteeSelfSameTypeConstraint(ClassDecl *selfClass, ValueDecl *witness) {
4014
4013
4015
4014
void ConformanceChecker::checkNonFinalClassWitness (ValueDecl *requirement,
4016
4015
ValueDecl *witness) {
4017
- auto *classDecl = Adoptee-> getClassOrBoundGenericClass ();
4016
+ auto *classDecl = DC-> getSelfClassDecl ();
4018
4017
4019
4018
// If we have an initializer requirement and the conforming type
4020
4019
// is a non-final class, the witness must be 'required'.
@@ -4161,7 +4160,7 @@ void ConformanceChecker::checkNonFinalClassWitness(ValueDecl *requirement,
4161
4160
ResolveWitnessResult
4162
4161
ConformanceChecker::resolveWitnessViaLookup (ValueDecl *requirement) {
4163
4162
assert (!isa<AssociatedTypeDecl>(requirement) && " Use resolveTypeWitnessVia*" );
4164
- auto *nominal = Adoptee-> getAnyNominal ();
4163
+ auto *nominal = DC-> getSelfNominalTypeDecl ();
4165
4164
4166
4165
// Resolve all associated types before trying to resolve this witness.
4167
4166
resolveTypeWitnesses ();
@@ -4435,7 +4434,7 @@ ConformanceChecker::resolveWitnessViaLookup(ValueDecl *requirement) {
4435
4434
break ;
4436
4435
}
4437
4436
4438
- if (auto *classDecl = Adoptee-> getClassOrBoundGenericClass ()) {
4437
+ if (auto *classDecl = DC-> getSelfClassDecl ()) {
4439
4438
if (!classDecl->isSemanticallyFinal ()) {
4440
4439
checkNonFinalClassWitness (requirement, witness);
4441
4440
}
@@ -4519,7 +4518,7 @@ ResolveWitnessResult ConformanceChecker::resolveWitnessViaDerivation(
4519
4518
4520
4519
// Find the declaration that derives the protocol conformance.
4521
4520
NominalTypeDecl *derivingTypeDecl = nullptr ;
4522
- auto *nominal = Adoptee-> getAnyNominal ();
4521
+ auto *nominal = DC-> getSelfNominalTypeDecl ();
4523
4522
if (DerivedConformance::derivesProtocolConformance (DC, nominal, Proto))
4524
4523
derivingTypeDecl = nominal;
4525
4524
@@ -4694,7 +4693,7 @@ ResolveWitnessResult ConformanceChecker::resolveTypeWitnessViaLookup(
4694
4693
// Look for a member type with the same name as the associated type.
4695
4694
SmallVector<ValueDecl *, 4 > candidates;
4696
4695
4697
- DC->lookupQualified (Adoptee-> getAnyNominal (),
4696
+ DC->lookupQualified (DC-> getSelfNominalTypeDecl (),
4698
4697
assocType->createNameRef (),
4699
4698
subOptions, candidates);
4700
4699
@@ -4734,7 +4733,7 @@ ResolveWitnessResult ConformanceChecker::resolveTypeWitnessViaLookup(
4734
4733
if (typeAliasDecl->getUnderlyingType ()->isNever ()) {
4735
4734
if (typeAliasDecl->getParentModule ()->getName ().is (" SwiftUI" )) {
4736
4735
if (typeAliasDecl->getDeclContext ()->getSelfNominalTypeDecl () ==
4737
- Adoptee-> getAnyNominal ()) {
4736
+ DC-> getSelfNominalTypeDecl ()) {
4738
4737
const auto reqs =
4739
4738
typeAliasDecl->getGenericSignature ().requirementsNotSatisfiedBy (
4740
4739
DC->getGenericSignatureOfContext ());
@@ -4980,7 +4979,7 @@ void ConformanceChecker::ensureRequirementsAreSatisfied() {
4980
4979
// an error, we can handle it as part of the above checkGenericArguments()
4981
4980
// call by passing in a superclass-bound archetype for the 'self' type
4982
4981
// instead of the concrete class type itself.
4983
- if (auto *classDecl = Adoptee-> getClassOrBoundGenericClass ()) {
4982
+ if (auto *classDecl = DC-> getSelfClassDecl ()) {
4984
4983
if (!classDecl->isSemanticallyFinal ()) {
4985
4984
if (auto req = hasInvariantSelfRequirement (proto, reqSig)) {
4986
4985
diagnoseInvariantSelfRequirement (Loc, Adoptee, proto, *req, diags);
@@ -5399,7 +5398,7 @@ void ConformanceChecker::checkConformance(MissingWitnessDiagnosisKind Kind) {
5399
5398
// Note that we check the module name to smooth over the difference
5400
5399
// between an imported Objective-C module and its overlay.
5401
5400
if (Proto->isSpecificProtocol (KnownProtocolKind::ObjectiveCBridgeable)) {
5402
- auto nominal = Adoptee-> getAnyNominal ();
5401
+ auto nominal = DC-> getSelfNominalTypeDecl ();
5403
5402
if (!getASTContext ().isTypeBridgedInExternalModule (nominal)) {
5404
5403
auto clangLoader = getASTContext ().getClangModuleLoader ();
5405
5404
if (nominal->getParentModule () != DC->getParentModule () &&
0 commit comments