Skip to content

Print attributes on enum cases correctly (like 'indirect') #26311

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

Merged
merged 1 commit into from
Jul 24, 2019

Conversation

jrose-apple
Copy link
Contributor

Previously they were just skipped if enum elements weren't exploded into their own individual lines, since the ASTPrinter assumed they'd be present on the EnumCaseDecl. This led to miscompiles when using a module interface for an enum with indirect cases, since they'd be printed as non-indirect cases.

rdar://problem/53329452

@jrose-apple
Copy link
Contributor Author

@swift-ci Please test

@jrose-apple
Copy link
Contributor Author

@swift-ci Please test source compatibility

@harlanhaskins
Copy link
Contributor

Thanks for adding the verifier check too.

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - d35ec617aafd4f59d7a0a4707afce9e360f5ea8e

Previously they were just skipped if enum elements weren't exploded
into their own individual lines, since the ASTPrinter assumed they'd
be present on the EnumCaseDecl. This led to miscompiles when using
a module interface for an enum with indirect cases, since they'd be
printed as non-indirect cases.

rdar://problem/53329452
@jrose-apple
Copy link
Contributor Author

Source compat suite: Debug, Release

Test fix only.

@swift-ci Please test

@jrose-apple jrose-apple force-pushed the indirectly-responsible branch from d35ec61 to f54c39b Compare July 24, 2019 00:08
@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - d35ec617aafd4f59d7a0a4707afce9e360f5ea8e

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - d35ec617aafd4f59d7a0a4707afce9e360f5ea8e

indirect case b(Int)
// CHECK-NEXT: {{^}} case c{{$}}
case c
}
Copy link
Member

Choose a reason for hiding this comment

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

Do you think it's worth to add test cases for multi element case decl? e.g.

enum Something {
  indirect case a(Int), b(Int)
  case c
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mm, good point. This is a time-sensitive fix so I'll do it in a follow-up.

@jrose-apple jrose-apple merged commit 3596df7 into swiftlang:master Jul 24, 2019
@jrose-apple jrose-apple deleted the indirectly-responsible branch July 24, 2019 02:48
jrose-apple added a commit to jrose-apple/swift that referenced this pull request Jul 24, 2019
…#26311)

Previously they were just skipped if enum elements weren't exploded
into their own individual lines, since the ASTPrinter assumed they'd
be present on the EnumCaseDecl. This led to miscompiles when using
a module interface for an enum with indirect cases, since they'd be
printed as non-indirect cases.

rdar://problem/53329452
(cherry picked from commit 3596df7)
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.

4 participants