-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[AST] Remove ParenType #59141
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
[AST] Remove ParenType #59141
Conversation
58a21d3
to
570ab52
Compare
570ab52
to
f3bbcc2
Compare
c340b65
to
2ca6d57
Compare
2ca6d57
to
1218054
Compare
// Note we don't look through parens. | ||
ExistentialMetatypeType *existentialTy = nullptr; | ||
if (!constraintRepr->isParenType()) | ||
existentialTy = dyn_cast<ExistentialMetatypeType>(ty.get().getPointer()); |
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.
@kavon Is it intentional that this doesn't look through parens, e.g we accept any ~Copyable.Type
, but not any ~(Copyable.Type)
? For now I've just maintained the current behavior
1218054
to
c231330
Compare
Split out a couple of PRs to hopefully make this a bit easier to land: |
cfc3f53
to
8a5654b
Compare
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.
Can't wait to see this land!
@@ -1470,16 +1470,6 @@ class TypeDecoder { | |||
|
|||
return Builder.createDictionaryType(key.getType(), value.getType()); | |||
} | |||
case NodeKind::SugaredParen: { |
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.
We might want to keep some minimal demangler support just in case it's needed for backwards compatibility with existing debug info; just have this return base.getType()
on line 1481
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.
Ah okay, I guess that means we also need to keep the logic in Demangler.cpp?
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.
Updated with the restored demangling code
8a5654b
to
7ef6c0c
Compare
@swift-ci please test source compatibility |
7ef6c0c
to
f890d22
Compare
…arens Check for `isParenType` on the TypeRepr to avoid relying on getting that behavior by casting the type pointer.
I missed this in my other Sema ParenType PR, avoid relying on ParenType here.
Today ParenType is used: 1. As the type of ParenExpr 2. As the payload type of an unlabeled single associated value enum case (and the type of ParenPattern). 3. As the type for an `(X)` TypeRepr For 1, this leads to some odd behavior, e.g the type of `(5.0 * 5).squareRoot()` is `(Double)`. For 2, we should be checking the arity of the enum case constructor parameters and the presence of ParenPattern respectively. Eventually we ought to consider replacing Paren/TuplePattern with a PatternList node, similar to ArgumentList. 3 is one case where it could be argued that there's some utility in preserving the sugar of the type that the user wrote. However it's really not clear to me that this is particularly desirable since a bunch of diagnostic logic is already stripping ParenTypes. In cases where we care about how the type was written in source, we really ought to be consulting the TypeRepr.
f890d22
to
2d7500e
Compare
@swift-ci please test |
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.
LGTM! It's slightly unfortunate that we loose the sugar sometimes in the diagnostics but I don't think it's critical.
@swift-ci please test macOS |
🚢 |
Today ParenType is used:
(X)
TypeReprFor 1, this leads to some odd behavior, e.g the type of
(5.0 * 5).squareRoot()
is(Double)
. For 2, we should be checking the arity of the enum case constructor parameters and the presence of ParenPattern respectively. Eventually we ought to consider replacing Paren/TuplePattern with a PatternList node, similar to ArgumentList.3 is one case where it could be argued that there's some utility in preserving the sugar of the type that the user wrote. However it's really not clear to me that this is particularly desirable since a bunch of diagnostic logic is already stripping ParenTypes. In cases where we care about how the type was written in source, we really ought to be consulting the TypeRepr.