-
Notifications
You must be signed in to change notification settings - Fork 447
add parsing for ~ (the 'without' operator) #1461
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -219,6 +219,7 @@ extension Parser { | |
var keepGoing: RawTokenSyntax? = nil | ||
var loopProgress = LoopProgressCondition() | ||
repeat { | ||
var withoutToken: RawTokenSyntax? = nil | ||
let type: RawTypeSyntax | ||
if let classKeyword = self.consume(if: .keyword(.class)) { | ||
type = RawTypeSyntax( | ||
|
@@ -228,12 +229,16 @@ extension Parser { | |
) | ||
) | ||
} else { | ||
if self.currentToken.starts(with: "~") { | ||
withoutToken = self.consumePrefix("~", as: .prefixOperator) | ||
} | ||
Comment on lines
+232
to
+234
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the withoutToken = self.consumeIfContextualPunctuator("~") |
||
type = self.parseType() | ||
} | ||
|
||
keepGoing = self.consume(if: .comma) | ||
elements.append( | ||
RawInheritedTypeSyntax( | ||
hasWithout: withoutToken, | ||
typeName: type, | ||
trailingComma: keepGoing, | ||
arena: self.arena | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1551,6 +1551,16 @@ final class DeclarationTests: XCTestCase { | |
""" | ||
) | ||
} | ||
|
||
func testSuppressedImplicitConformance() { | ||
assertParse( | ||
""" | ||
struct Hello: ~Copyable {} | ||
|
||
enum Whatever: Int, ~ Hashable, Equatable {} | ||
""" | ||
) | ||
Comment on lines
+1556
to
+1562
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you create separate |
||
} | ||
} | ||
|
||
extension Parser.DeclAttributes { | ||
|
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 would prefer this to be named
WithoutTilde
. This actually contains the tilde itself, so it’s not a boolean variable, which theHas
implies.