Branch: refs/heads/main
Revision: 309c919
Author: vasslitvinov
Link: Improve the ordering of non-matching resolution candidates by vasslitvinov · Pull Request #19684 · chapel-lang/chapel · GitHub
Log Message:
Merge pull request #19684 from vasslitvinov/prefer-candidates
Improve the ordering of non-matching resolution candidates
Resolves #18565
This changes the order and sometimes the number of resolution candidates
that the compiler prints upon an "unresolved call" error message as
"note: this candidate did not match" and "note: other candidates are".
-
Print all the candidates if there are 4 or fewer.
There should no longer be "note: there is also 1 other candidate".
Instead the compiler just shows that 1 other candidate. -
Print the candidates with the same method-ness as the unresolved call
BEFORE the other-methodness candidates.
Ex. if the call is a method call, print the candidates that are methods
before those that are standalone functions.
Note that this is not perfect in the current compiler, which treats
as "method calls" some calls written without an explicit receiver. -
Towards #18565, print the candidate methods with the same receiver type
as the call (if it is a method call) BEFORE those with different
receiver types.
The last bullet is implemented by adding another "reason" for rejecting
a resolution candidate: RESOLUTION_CANDIDATE_DIFFERENT_RECEIVER_TYPES
which is ordered after most other reasons.
Potential future improvement: order the candidates whose receiver type
is a supertype of the receiver type of the call BEFORE the other
different-receiver-type candidates.
As before, the compiler explains the first non-matching candidate in detail
with "note: this candidate did not match: ..." and "note: because ...".
It can be a different candidate now than it would have been before this PR.
While there:
- Add .bad: test/classes/nilability/cycle-generic.bad
- Add .future for #19697: test/errhandling/parallel/taskerrors-write.chpl
r: @dlongnecke-cray
Modified Files:
A test/classes/nilability/cycle-generic.bad
A test/errhandling/parallel/taskerrors-write.bad
A test/errhandling/parallel/taskerrors-write.chpl
A test/errhandling/parallel/taskerrors-write.future
A test/errhandling/parallel/taskerrors-write.good
A test/functions/resolution/errors/receiver-type-mismatch.1.good
A test/functions/resolution/errors/receiver-type-mismatch.2.good
A test/functions/resolution/errors/receiver-type-mismatch.chpl
A test/functions/resolution/errors/receiver-type-mismatch.compopts
M compiler/include/ResolutionCandidate.h
M compiler/resolution/ResolutionCandidate.cpp
M compiler/resolution/functionResolution.cpp
M test/classes/deitz/method/method_call2.good
M test/classes/nilability/multiple-errors.1.good
M test/classes/nilability/multiple-errors.2.good
M test/functions/bradc/resolution/badEnumDispatch.good
M test/functions/ferguson/query/query-generic-star-tuple-error.good
M test/functions/ferguson/query/query-generic-type-leaf-borrowed.good
M test/functions/ferguson/query/query-generic-type-leaf.good
M test/functions/lydia/method-iter-resolution-bug.bad
M test/functions/resolution/errors/testBadCallCandidates.1-all.good
M test/functions/resolution/errors/testBadCallCandidates.1.good
M test/functions/resolution/errors/testBadCallCandidates.10-all.good
M test/functions/resolution/errors/testBadCallCandidates.10.good
M test/functions/resolution/errors/testBadCallCandidates.11-all.good
M test/functions/resolution/errors/testBadCallCandidates.11.good
M test/functions/resolution/errors/testBadCallCandidates.12-all.good
M test/functions/resolution/errors/testBadCallCandidates.12.good
M test/functions/resolution/errors/testBadCallCandidates.13-all.good
M test/functions/resolution/errors/testBadCallCandidates.13.good
M test/functions/resolution/errors/testBadCallCandidates.14.good
M test/functions/resolution/errors/testBadCallCandidates.15.good
M test/functions/resolution/errors/testBadCallCandidates.16-all.good
M test/functions/resolution/errors/testBadCallCandidates.16.good
M test/functions/resolution/errors/testBadCallCandidates.17-all.good
M test/functions/resolution/errors/testBadCallCandidates.17.good
M test/functions/resolution/errors/testBadCallCandidates.18-all.good
M test/functions/resolution/errors/testBadCallCandidates.18.good
M test/functions/resolution/errors/testBadCallCandidates.19-all.good
M test/functions/resolution/errors/testBadCallCandidates.19.good
M test/functions/resolution/errors/testBadCallCandidates.2-all.good
M test/functions/resolution/errors/testBadCallCandidates.2.good
M test/functions/resolution/errors/testBadCallCandidates.20.good
M test/functions/resolution/errors/testBadCallCandidates.21.good
M test/functions/resolution/errors/testBadCallCandidates.3.good
M test/functions/resolution/errors/testBadCallCandidates.4-all.good
M test/functions/resolution/errors/testBadCallCandidates.4.good
M test/functions/resolution/errors/testBadCallCandidates.5-all.good
M test/functions/resolution/errors/testBadCallCandidates.5.good
M test/functions/resolution/errors/testBadCallCandidates.6.good
M test/functions/resolution/errors/testBadCallCandidates.7.good
M test/functions/resolution/errors/testBadCallCandidates.8.good
M test/functions/resolution/errors/testBadCallCandidates.9.good
M test/functions/resolution/functionAndMethodWithSameNameBug.bad
M test/types/bool/resolution/resolveQueryTypeW.bad
M test/types/enum/bradc/dispatch/dispatchenums.good
M test/visibility/shadow-overload.good
Compare: https://github.com/chapel-lang/chapel/compare/c069e86fb9f4...309c919c75ce