-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[QoI] Improve diagnostics for misaligned archetypes with the same name in calls #11281
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 |
/cc @slavapestov I'm not sure if that's the right way of handling decls for generic/dependent type... |
lib/Sema/CSDiag.cpp
Outdated
@@ -1876,23 +1879,66 @@ bool CalleeCandidateInfo::diagnoseGenericParameterErrors(Expr *badArgExpr) { | |||
argType, archetypesMap)) | |||
return false; | |||
|
|||
auto getDecls = |
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.
Just return a Decl* and not this
lib/Sema/CSDiag.cpp
Outdated
Decl *parent = nullptr; | ||
ValueDecl *decl = nullptr; | ||
|
||
std::tie(decl, parent) = genericParam; |
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.
You can compute the parent here
lib/Sema/CSDiag.cpp
Outdated
auto paramType = env->mapTypeOutOfContext(archetype); | ||
|
||
if (auto *GTPT = paramType->getAs<GenericTypeParamType>()) { | ||
auto *decl = GTPT->getDecl(); |
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.
decl might be null, just bail out in that case
lib/Sema/CSDiag.cpp
Outdated
auto *parent = dc->getInnermostDeclarationDeclContext(); | ||
return Optional<GenericDeclWithParent>({decl, parent}); | ||
} else if (auto *DMT = paramType->getAs<DependentMemberType>()) { | ||
auto *decl = DMT->getAssocType(); |
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.
decl might be null, just bail out in that case
lib/Sema/CSDiag.cpp
Outdated
auto *dc = decl->getDeclContext(); | ||
auto *parent = dc->getInnermostDeclarationDeclContext(); | ||
return Optional<GenericDeclWithParent>({decl, parent}); | ||
} else if (auto *DMT = paramType->getAs<DependentMemberType>()) { |
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 violates LLVM style. There is no point in putting in an else if you are returning here. Just use the early return.
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.
Got it, thanks!
…e in calls Resolves: rdar://problem/24329052.
Alright, all comments addressed, thanks guys! |
@swift-ci please smoke test and merge |
Resolves: rdar://problem/24329052.