Skip to content

Fix RequirementMachine crash with invalid AST via getSuperclassForDecl() #82115

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 4 commits into from
Jun 11, 2025

Conversation

slavapestov
Copy link
Contributor

@slavapestov slavapestov commented Jun 9, 2025

getSuperclassForDecl() 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, and instead just filling in the generic arguments with ErrorType in the invalid case.

@slavapestov slavapestov requested review from hborla and xedin as code owners June 9, 2025 16:54
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 force-pushed the get-superclass-for-decl branch from 1f61c43 to 7bbb299 Compare June 10, 2025 20:50
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov slavapestov merged commit 5e37849 into swiftlang:main Jun 11, 2025
3 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