-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Remove validateDeclForNameLookup
and related logic
#24957
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a268e0c
da6cf5e
d2e3df4
92bec03
da4a38c
95a8d08
7476430
d81a5d6
87be387
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -645,10 +645,11 @@ Type TypeChecker::resolveTypeInContext( | |
} | ||
} | ||
} | ||
|
||
// Finally, substitute the base type into the member type. | ||
return substMemberTypeWithBase(fromDC->getParentModule(), typeDecl, | ||
selfType, resolution.usesArchetypes()); | ||
selfType, resolution.usesArchetypes(), | ||
resolution.getStage()); | ||
} | ||
|
||
static TypeResolutionOptions | ||
|
@@ -978,9 +979,18 @@ static Type resolveTypeDecl(TypeDecl *typeDecl, SourceLoc loc, | |
auto &diags = ctx.Diags; | ||
auto lazyResolver = ctx.getLazyResolver(); | ||
|
||
Type type = Type(); | ||
|
||
// Use only the structural type of an alias decl in structural mode | ||
auto aliasDecl = dyn_cast<TypeAliasDecl>(typeDecl); | ||
if (resolution.getStage() == TypeResolutionStage::Structural && | ||
aliasDecl && !aliasDecl->getGenericParams() && | ||
!aliasDecl->getUnderlyingTypeLoc().wasValidated()) { | ||
type = aliasDecl->getStructuralType(); | ||
|
||
// Don't validate nominal type declarations during extension binding. | ||
if (!options.is(TypeResolverContext::ExtensionBinding) || | ||
!isa<NominalTypeDecl>(typeDecl)) { | ||
} else if (!options.is(TypeResolverContext::ExtensionBinding) || | ||
!isa<NominalTypeDecl>(typeDecl)) { | ||
// Validate the declaration. | ||
if (lazyResolver) | ||
lazyResolver->resolveDeclSignature(typeDecl); | ||
|
@@ -997,9 +1007,10 @@ static Type resolveTypeDecl(TypeDecl *typeDecl, SourceLoc loc, | |
|
||
// Resolve the type declaration to a specific type. How this occurs | ||
// depends on the current context and where the type was found. | ||
Type type = | ||
TypeChecker::resolveTypeInContext(typeDecl, foundDC, resolution, options, | ||
generic); | ||
if (!type) | ||
type = | ||
TypeChecker::resolveTypeInContext(typeDecl, foundDC, resolution, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should getting the structural type be pushed down into resolveTypeInContext(), since it has access to the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We probably could, but we also need to avoid the call to the previous |
||
options, generic); | ||
|
||
if (type->is<UnboundGenericType>() && !generic && | ||
!options.is(TypeResolverContext::TypeAliasDecl) && | ||
|
@@ -3362,7 +3373,8 @@ Type TypeResolver::buildProtocolType( | |
Type TypeChecker::substMemberTypeWithBase(ModuleDecl *module, | ||
TypeDecl *member, | ||
Type baseTy, | ||
bool useArchetypes) { | ||
bool useArchetypes, | ||
TypeResolutionStage stage) { | ||
Type sugaredBaseTy = baseTy; | ||
|
||
// For type members of a base class, make sure we use the right | ||
|
@@ -3410,20 +3422,12 @@ Type TypeChecker::substMemberTypeWithBase(ModuleDecl *module, | |
aliasDecl, baseTy, | ||
aliasDecl->getASTContext()); | ||
} | ||
|
||
// FIXME: If this is a protocol typealias and we haven't built the | ||
// protocol's generic environment yet, do so now, to ensure the | ||
// typealias's underlying type has fully resolved dependent | ||
// member types. | ||
if (auto *protoDecl = dyn_cast<ProtocolDecl>(aliasDecl->getDeclContext())) { | ||
ASTContext &ctx = protoDecl->getASTContext(); | ||
ctx.getLazyResolver()->resolveProtocolEnvironment(protoDecl); | ||
} | ||
} | ||
|
||
Type resultType; | ||
auto memberType = aliasDecl ? aliasDecl->getUnderlyingTypeLoc().getType() | ||
auto memberType = aliasDecl ? aliasDecl->getStructuralType() | ||
: member->getDeclaredInterfaceType(); | ||
|
||
SubstitutionMap subs; | ||
if (baseTy) { | ||
// Cope with the presence of unbound generic types, which are ill-formed | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a similar check in getStructuralType() in GenericSignatureBuilder.cpp. Maybe TypeAliasDecl::getStructuralType() should automatically return the checked underlying type if its available.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've applied the suggested change to TypeAliasDecl::getStructuralType. I'll leave this check here because we still want to execute TypeChecker::resolveTypeInContext if the type was previously validated, it provides better diagnostics.