-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Push FunctionTypeRepr Input Invariants Up #17191
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
Conversation
@swift-ci please smoke test |
include/swift/AST/TypeRepr.h
Outdated
@@ -465,60 +465,6 @@ inline IdentTypeRepr::ComponentRange IdentTypeRepr::getComponentRange() { | |||
return ComponentRange(this); | |||
} | |||
|
|||
/// \brief A function type. |
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.
Note to self: Moving this below TupleTypeRepr might be a mistake. I should probably forward-declare and move the things accessing TupleTypeRepr into TypeRepr.cpp
@@ -1461,7 +1461,7 @@ class PlaceholderExpansionScanner { | |||
bool walkToTypeReprPre(TypeRepr *T) override { | |||
if (auto *FTR = dyn_cast<FunctionTypeRepr>(T)) { | |||
FoundFunctionTypeRepr = true; | |||
if (auto *TTR = dyn_cast_or_null<TupleTypeRepr>(FTR->getArgsTypeRepr())) { | |||
if (auto *TTR = FTR->getArgsTypeRepr()) { |
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.
This probably doesn't need to be an if
at all now.
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.
It's the _or_null
that's got me scared.
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.
I'm not sure how you'd ever get a FunctionTypeRepr with no argument types, but fair enough.
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.
It was probably defensive coding. If the tests pass without it I would just remove it.
lib/IRGen/IRGenDebugInfo.cpp
Outdated
@@ -889,7 +889,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo { | |||
// throw it away before lowering. | |||
else if (isa<GenericFunctionType>(BaseTy)) { | |||
auto *fTy = cast<AnyFunctionType>(BaseTy); | |||
auto *nongenericTy = FunctionType::get(fTy->getInput(), fTy->getResult(), | |||
auto *nongenericTy = FunctionType::get(fTy->getParams(), fTy->getResult(), |
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.
N.B. Wrong patch
Validation of the input side of FunctionTypeRepr was previously being done in Sema because of expression folding. If we instead push the invariant that the input TypeRepr should always be a TupleTypeRepr into the AST a number of nice cleanups fall out: - The SIL Parser no longer accepts Swift 2-style type declarations - Parse is more cleanly able to reject invalid FunctionTypeReprs - Clients of the AST can be assured the input type is always a TupleType so we can flush Swift 2 hacks
@swift-ci please smoke test |
⛵️ @swift-ci please test and merge |
Validation of the input side of FunctionTypeRepr was previously being done in Sema because of expression folding. If we instead push the invariant that the input TypeRepr should always be a TupleTypeRepr into the AST a number of nice cleanups fall out: