Skip to content

[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

Merged
merged 1 commit into from
Aug 1, 2017

Conversation

xedin
Copy link
Contributor

@xedin xedin commented Aug 1, 2017

Resolves: rdar://problem/24329052.

@xedin
Copy link
Contributor Author

xedin commented Aug 1, 2017

@swift-ci please smoke test

@xedin
Copy link
Contributor Author

xedin commented Aug 1, 2017

/cc @slavapestov I'm not sure if that's the right way of handling decls for generic/dependent type...

@@ -1876,23 +1879,66 @@ bool CalleeCandidateInfo::diagnoseGenericParameterErrors(Expr *badArgExpr) {
argType, archetypesMap))
return false;

auto getDecls =
Copy link
Contributor

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

Decl *parent = nullptr;
ValueDecl *decl = nullptr;

std::tie(decl, parent) = genericParam;
Copy link
Contributor

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

auto paramType = env->mapTypeOutOfContext(archetype);

if (auto *GTPT = paramType->getAs<GenericTypeParamType>()) {
auto *decl = GTPT->getDecl();
Copy link
Contributor

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

auto *parent = dc->getInnermostDeclarationDeclContext();
return Optional<GenericDeclWithParent>({decl, parent});
} else if (auto *DMT = paramType->getAs<DependentMemberType>()) {
auto *decl = DMT->getAssocType();
Copy link
Contributor

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

auto *dc = decl->getDeclContext();
auto *parent = dc->getInnermostDeclarationDeclContext();
return Optional<GenericDeclWithParent>({decl, parent});
} else if (auto *DMT = paramType->getAs<DependentMemberType>()) {
Copy link
Contributor

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.

Copy link
Contributor Author

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.
@xedin
Copy link
Contributor Author

xedin commented Aug 1, 2017

Alright, all comments addressed, thanks guys!

@xedin
Copy link
Contributor Author

xedin commented Aug 1, 2017

@swift-ci please smoke test and merge

@swift-ci swift-ci merged commit 995a0e7 into swiftlang:master Aug 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants