-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Kill validateDeclForNameLookup Harder #27172
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
2ab5ea8
278ead3
dceb357
5e34169
d5c014b
c254f4d
6b7fbc9
4f6951c
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 |
---|---|---|
|
@@ -3785,10 +3785,13 @@ PotentialArchetype *GenericSignatureBuilder::realizePotentialArchetype( | |
|
||
static Type getStructuralType(TypeDecl *typeDecl) { | ||
if (auto typealias = dyn_cast<TypeAliasDecl>(typeDecl)) { | ||
if (auto resolved = typealias->getUnderlyingTypeLoc().getType()) | ||
return resolved; | ||
|
||
return typealias->getStructuralType(); | ||
// When we're computing requirement signatures, the structural type | ||
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. It looks like the indentation here might be a bit funky |
||
// suffices. Otherwise we'll potentially try to validate incomplete | ||
// requirements. | ||
auto *proto = dyn_cast_or_null<ProtocolDecl>(typealias->getDeclContext()->getAsDecl()); | ||
if (proto && proto->isComputingRequirementSignature()) | ||
return typealias->getStructuralType(); | ||
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. Here too |
||
return typealias->getUnderlyingType(); | ||
} | ||
|
||
return typeDecl->getDeclaredInterfaceType(); | ||
|
@@ -4196,11 +4199,10 @@ ConstraintResult GenericSignatureBuilder::expandConformanceRequirement( | |
out << start; | ||
out << type->getFullName() << " == "; | ||
if (auto typealias = dyn_cast<TypeAliasDecl>(type)) { | ||
if (auto underlyingTypeRepr = | ||
typealias->getUnderlyingTypeLoc().getTypeRepr()) | ||
if (auto underlyingTypeRepr = typealias->getUnderlyingTypeRepr()) | ||
underlyingTypeRepr->print(out); | ||
else | ||
typealias->getUnderlyingTypeLoc().getType().print(out); | ||
typealias->getUnderlyingType().print(out); | ||
} else { | ||
type->print(out); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1813,7 +1813,7 @@ resolveTypeDeclsToNominal(Evaluator &evaluator, | |
// Recognize Swift.AnyObject directly. | ||
if (typealias->getName().is("AnyObject")) { | ||
// TypeRepr version: Builtin.AnyObject | ||
if (auto typeRepr = typealias->getUnderlyingTypeLoc().getTypeRepr()) { | ||
if (auto typeRepr = typealias->getUnderlyingTypeRepr()) { | ||
if (auto compound = dyn_cast<CompoundIdentTypeRepr>(typeRepr)) { | ||
auto components = compound->getComponents(); | ||
if (components.size() == 2 && | ||
|
@@ -1825,9 +1825,10 @@ resolveTypeDeclsToNominal(Evaluator &evaluator, | |
} | ||
|
||
// Type version: an empty class-bound existential. | ||
if (auto type = typealias->getUnderlyingTypeLoc().getType()) { | ||
if (type->isAnyObject()) | ||
anyObject = true; | ||
if (typealias->hasInterfaceType()) { | ||
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. The hasInterfaceType() check should not be necessary? 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. Requesting the underlying type potentially calls back into validation. This is also justified because the interface type separation changes mean that |
||
if (auto type = typealias->getUnderlyingType()) | ||
if (type->isAnyObject()) | ||
anyObject = true; | ||
} | ||
} | ||
|
||
|
@@ -2091,15 +2092,15 @@ DirectlyReferencedTypeDecls UnderlyingTypeDeclsReferencedRequest::evaluate( | |
Evaluator &evaluator, | ||
TypeAliasDecl *typealias) const { | ||
// Prefer syntactic information when we have it. | ||
if (auto typeRepr = typealias->getUnderlyingTypeLoc().getTypeRepr()) { | ||
if (auto typeRepr = typealias->getUnderlyingTypeRepr()) { | ||
return directReferencesForTypeRepr(evaluator, typealias->getASTContext(), | ||
typeRepr, typealias); | ||
} | ||
|
||
// Fall back to semantic types. | ||
// FIXME: In the long run, we shouldn't need this. Non-syntactic results | ||
// should be cached. | ||
if (auto type = typealias->getUnderlyingTypeLoc().getType()) { | ||
if (auto type = typealias->getUnderlyingType()) { | ||
return directReferencesForType(type); | ||
} | ||
|
||
|
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 kicks off a request :(
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'm going to add an RAII type to catch all of these.