-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Sema] Implement type erasure for dynamic replacement. #30101
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
[Sema] Implement type erasure for dynamic replacement. #30101
Conversation
dynamically replaceable function returns an opaque type.
@swift-ci please smoke test |
Printer << "("; | ||
Printer.callPrintNamePre(PrintNameContext::Attribute); | ||
auto typeLoc = cast<TypeEraserAttr>(this)->getTypeEraserLoc(); | ||
if (auto type = typeLoc.getType()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's an option to prefer the TypeRepr
when printing. Can you check willUseTypeReprPrinting
in this conditional?
@@ -520,7 +520,7 @@ SIMPLE_DECL_ATTR(_inheritsConvenienceInitializers, | |||
93) | |||
|
|||
DECL_ATTR(_typeEraser, TypeEraser, | |||
OnProtocol | UserInaccessible | NotSerialized | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. Please bump the version number in ModuleFormat.h
to account for this.
@@ -7417,6 +7417,7 @@ ExprWalker::rewriteTarget(SolutionApplicationTarget target) { | |||
return None; | |||
|
|||
result.setFunctionBody(newBody); | |||
fn.getAbstractFunctionDecl()->setHasSingleExpressionBody(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anything that calls hasSingleExperssionBody
and subsequently calls getSingleExpressionBody
after the function builder transformation is applied will crash. In my case it was -dump-ast
Before generating constraints for an expression that could potentially be a return value, perform type erasure on this expression if needed. An expression needs type erasure if:
Resolves: rdar://problem/58763698