Skip to content

[6.2] AST: More robust TypeBase::getSuperclassForDecl() #82131

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

Conversation

slavapestov
Copy link
Contributor

@slavapestov slavapestov commented Jun 10, 2025

6.2 cherry-pick of part of #82115.

  • Description: Fix a possible crash when a superclass requirement involves an invalid class declaration. A utility method would return ErrorType, which wasn't handled correctly by all callers. Change the utility method to always return a nominal type instead.

  • Risk: Low.

  • Tested: New test case added.

  • Reviewed by: @xedin

This can return ErrorType if the AST is invalid.

A handful of callers handle the ErrorType result, but most don't,
blindly assuming the result is always a nominal type. This resulted
in a crash in at least one test case.

Lift the burden from callers by always returning a nominal type here.
@slavapestov slavapestov requested a review from a team as a code owner June 10, 2025 00:26
@slavapestov slavapestov changed the title AST: More robust TypeBase::getSuperclassForDecl() [6.2] AST: More robust TypeBase::getSuperclassForDecl() Jun 10, 2025
@slavapestov
Copy link
Contributor Author

@swift-ci Please test

@slavapestov slavapestov enabled auto-merge June 10, 2025 13:45
@slavapestov slavapestov merged commit 4b3943a into swiftlang:release/6.2 Jun 10, 2025
5 checks passed
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.

2 participants