-
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
Conversation
@swift-ci Please smoke test |
@swift-ci Please test source compatibility |
I believe you can remove |
7a49ec1
to
b3f375c
Compare
@swift-ci Please smoke test |
@swift-ci Please test source compatibility |
b3f375c
to
6f0b915
Compare
@swift-ci Please test source compatibility |
@swift-ci Please smoke test |
6f0b915
to
9d76ff7
Compare
@swift-ci Please test source compatibility |
9d76ff7
to
761cd67
Compare
@swift-ci Please test source compatibility |
@swift-ci Please smoke test |
6b4d88f
to
c715c51
Compare
@swift-ci Please smoke test |
@swift-ci Please test source compatibility |
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.
A few suggestions you might want to look at. The only important one is the removal of the requestNominalLayout() call.
auto aliasDecl = dyn_cast<TypeAliasDecl>(typeDecl); | ||
if (resolution.getStage() == TypeResolutionStage::Structural && | ||
aliasDecl && !aliasDecl->getGenericParams() && | ||
!aliasDecl->getUnderlyingTypeLoc().wasValidated()) { |
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.
static Type substMemberTypeWithBase(ModuleDecl *module, TypeDecl *member, | ||
Type baseTy, bool useArchetypes = true); | ||
Type baseTy, bool useArchetypes = true, | ||
TypeResolutionStage stage = TypeResolutionStage::Interface); |
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.
Maybe if you pass in a TypeResolution instead of a TypeResolutionStage, you can combine the useArchetypes and state parameters into one; useArchetypes then just becomes resolution.usesArchetypes().
generic); | ||
if (!type) | ||
type = | ||
TypeChecker::resolveTypeInContext(typeDecl, foundDC, resolution, |
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.
Should getting the structural type be pushed down into resolveTypeInContext(), since it has access to the resolution
object?
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.
We probably could, but we also need to avoid the call to the previous resolveDeclSignature
because it triggers validateDecl
.
c715c51
to
12598ba
Compare
@swift-ci Please smoke test |
@swift-ci Please test source compatibility |
1 similar comment
@swift-ci Please test source compatibility |
68dcec4
to
96e4e97
Compare
@swift-ci Please smoke test |
@swift-ci Please test source compatibility |
1 similar comment
@swift-ci Please test source compatibility |
96e4e97
to
3daaeaf
Compare
@swift-ci Please test source compatibility |
@swift-ci Please smoke test |
lib/Sema/TypeChecker.h
Outdated
@@ -1024,7 +1021,12 @@ class TypeChecker final : public LazyResolver { | |||
void checkDefaultArguments(ParameterList *params, ValueDecl *VD); | |||
|
|||
virtual void resolveDeclSignature(ValueDecl *VD) override { | |||
validateDeclForNameLookup(VD); | |||
auto dc = VD->getDeclContext(); | |||
if (auto nominal = dyn_cast<NominalTypeDecl>(dc)) { |
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.
This should not be necessary?
3daaeaf
to
a9de890
Compare
@swift-ci Please smoke test |
@swift-ci Please test source compatibility |
a9de890
to
367ce21
Compare
@swift-ci Please test source compatibility It passed the source compat suite, now trying again with one less hack. |
@swift-ci Please smoke test |
@swift-ci Please test source compatibility |
367ce21
to
49e9609
Compare
@swift-ci Please smoke test |
@swift-ci Please test source compatibility |
…arly Fixes failures on circular references.
This fixes an issue with protocol compositions using a typealias of anoter protocol composition causing a difference between the flat structural type and the nested underlying TypeRepr.
With the recent change to StructuralTypeRequest where all returned types are wrapped in a TypeAliasType, printing the requirement signature could display requirements such as `Self.P3Assoc == Self.P3Assoc`. This change will make sure that when in debug mode, the underlying type will be displayed instead on the RHS.
49e9609
to
87be387
Compare
@swift-ci Please test source compatibility |
@swift-ci Please smoke test |
validateDeclForNameLookup
was a phase executed beforevalidateDecl
on some decls to avoid cycles. We already moved its work to be lazier, so we don't need this phase anymore. CallingvalidateDecl
is enough as it relies on the new lazy services to avoid cycles.The next goal is to make lazy more of the logic in
validateDecl
so it is evaluated only when it is actually needed.