Skip to content

Conversation

@kubamracek
Copy link
Contributor

@kubamracek kubamracek commented Jul 22, 2025

This solves a compiler crasher, for which a reproducer is in the attached lit test. The existing logic tries to skip CGFloat from getting their constant values imported -- this is because importing CGFloats is special cased and needs more work to work correctly. However, we were failing to skip importing a CGFloat if it was used under a typedef with a different name. In this case, the code in VisitVarDecl attempted to recognize a CGFloat through type->isCGFloat() which is not enough (the type is not a CGFloat directly, it's a typedef instead). Let's instead ask the SwiftDeclSynthesizer directly if it's going to import the type as a CGFloat.

I have also added a frontend flag to disable value importing, this might be useful to quickly workaround situations like this in the future.

Also see #80749 for reference.

rdar://155657342

Copy link
Contributor

@j-hui j-hui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, other than a nit about code organization

@kubamracek
Copy link
Contributor Author

@swift-ci please test

Comment on lines +4679 to +4680
bool isCGFloat = (type && type->isCGFloat()) ||
(type && synthesizer.isCGFloat(type));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
bool isCGFloat = (type && type->isCGFloat()) ||
(type && synthesizer.isCGFloat(type));
bool isCGFloat = type && (type->isCGFloat()) ||
synthesizer.isCGFloat(type));

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops, missed that :) I'll leave it if you don't mind

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, no worries, this was just a minor nit :)

@kubamracek kubamracek merged commit 407ef9a into swiftlang:main Jul 23, 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.

5 participants