mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Don't check the inheritance clauses of extensions as part of validating the type they extend.
This makes the type checking slightly lazier for declarations, but is otherwise NFC. Swift SVN r20686
This commit is contained in:
@@ -638,6 +638,9 @@ findExplicitConformance(NominalTypeDecl *nominal, ProtocolDecl *protocol,
|
|||||||
|
|
||||||
// Visit the extensions of this type.
|
// Visit the extensions of this type.
|
||||||
for (auto ext : currentNominal->getExtensions()) {
|
for (auto ext : currentNominal->getExtensions()) {
|
||||||
|
if (resolver)
|
||||||
|
resolver->resolveExtension(ext);
|
||||||
|
|
||||||
if (isProtocolInList(ext, ext->getProtocols(), ext->getConformances())) {
|
if (isProtocolInList(ext, ext->getProtocols(), ext->getConformances())) {
|
||||||
// Break outer loop as well.
|
// Break outer loop as well.
|
||||||
stack.clear();
|
stack.clear();
|
||||||
|
|||||||
@@ -1210,6 +1210,9 @@ bool DeclContext::lookupQualified(Type type,
|
|||||||
|
|
||||||
// Add protocols from the extensions of the current type.
|
// Add protocols from the extensions of the current type.
|
||||||
for (auto ext : current->getExtensions()) {
|
for (auto ext : current->getExtensions()) {
|
||||||
|
if (typeResolver)
|
||||||
|
typeResolver->resolveExtension(ext);
|
||||||
|
|
||||||
addProtocols(ext->getProtocols());
|
addProtocols(ext->getProtocols());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5403,6 +5403,16 @@ void TypeChecker::typeCheckDecl(Decl *D, bool isFirstPass) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TypeChecker::validateDecl(ValueDecl *D, bool resolveTypeParams) {
|
void TypeChecker::validateDecl(ValueDecl *D, bool resolveTypeParams) {
|
||||||
|
// Validate the context. We don't do this for generic parameters, because
|
||||||
|
// those are validated as part of their context.
|
||||||
|
if (D->getKind() != DeclKind::GenericTypeParam) {
|
||||||
|
auto dc = D->getDeclContext();
|
||||||
|
if (auto nominal = dyn_cast<NominalTypeDecl>(dc))
|
||||||
|
validateDecl(nominal, false);
|
||||||
|
else if (auto ext = dyn_cast<ExtensionDecl>(dc))
|
||||||
|
validateExtension(ext);
|
||||||
|
}
|
||||||
|
|
||||||
switch (D->getKind()) {
|
switch (D->getKind()) {
|
||||||
case DeclKind::Import:
|
case DeclKind::Import:
|
||||||
case DeclKind::Extension:
|
case DeclKind::Extension:
|
||||||
@@ -5480,9 +5490,6 @@ void TypeChecker::validateDecl(ValueDecl *D, bool resolveTypeParams) {
|
|||||||
case DeclKind::Struct:
|
case DeclKind::Struct:
|
||||||
case DeclKind::Class: {
|
case DeclKind::Class: {
|
||||||
auto nominal = cast<NominalTypeDecl>(D);
|
auto nominal = cast<NominalTypeDecl>(D);
|
||||||
for (auto ext : nominal->getExtensions())
|
|
||||||
checkInheritanceClause(ext);
|
|
||||||
|
|
||||||
if (nominal->hasType())
|
if (nominal->hasType())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -528,6 +528,7 @@ public:
|
|||||||
|
|
||||||
virtual void resolveExtension(ExtensionDecl *ext) override {
|
virtual void resolveExtension(ExtensionDecl *ext) override {
|
||||||
validateExtension(ext);
|
validateExtension(ext);
|
||||||
|
checkInheritanceClause(ext);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void resolveImplicitConstructors(NominalTypeDecl *nominal) override {
|
virtual void resolveImplicitConstructors(NominalTypeDecl *nominal) override {
|
||||||
|
|||||||
Reference in New Issue
Block a user