Skip to content

Sema: Fix crash when synthesizing RawRepresentable conformance with non-Equatable raw type #29173

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

Conversation

slavapestov
Copy link
Contributor

@slavapestov slavapestov commented Jan 13, 2020

The error recovery logic around derived conformances is a little bit
tricky. Make sure we don't crash if a type explicitly provides a
RawValue type witness that is not equatable, but omits the witnesses
for init(rawValue:) and the rawValue property.

Fixes https://bugs.swift.org/browse/SR-6897, rdar://problem/58127114.

@slavapestov slavapestov requested a review from CodaFi January 13, 2020 23:28
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@theblixguy
Copy link
Collaborator

theblixguy commented Jan 13, 2020

Looks like this should fix SR-6897 as well. Also, can you try this test case:

struct S : ExpressibleByStringLiteral {
  init(stringLiteral: String) {}
}

enum E: S {
  case a
  typealias RawValue = S
  init?(rawValue: Int) { self = .a }
  var rawValue: Int { 0 }
}

? It used to crash for me when I was working on #27050.

@slavapestov
Copy link
Contributor Author

Ah, I forgot about #27050. I think this fix supersedes it since it centralizes the 'can derive' check. I'll add your test case too, thanks!

…on-Equatable raw type

The error recovery logic around derived conformances is a little bit
tricky. Make sure we don't crash if a type explicitly provides a
RawValue type witness that is not equatable, but omits the witnesses
for init(rawValue:) and the rawValue property.

Fixes <rdar://problem/58127114>.
@slavapestov slavapestov force-pushed the enum-raw-value-not-equatable-fix branch from 21fe869 to 1dd527e Compare January 14, 2020 00:07
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

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.

2 participants