Skip to content
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

Implement equality operator synthesization #1563

Merged
merged 11 commits into from
Aug 20, 2024
3 changes: 2 additions & 1 deletion Sources/FrontEnd/AST/AST.swift
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,6 @@ public struct AST {
/// Returns the kind identifying synthesized declarations of `requirement`, or `nil` if
/// `requirement` is not synthesizable.
public func synthesizedKind<T: DeclID>(of requirement: T) -> SynthesizedFunctionDecl.Kind? {
// If the requirement is defined in `Deinitializable`, it must be the deinitialization method.
switch requirement.rawValue {
case core.deinitializable.deinitialize.rawValue:
return .deinitialize
Expand All @@ -313,6 +312,8 @@ public struct AST {
return .moveAssignment
case core.copyable.copy.rawValue:
return .copy
case core.equatable.equal.rawValue:
return .equal
default:
return nil
}
Expand Down
3 changes: 3 additions & 0 deletions Sources/FrontEnd/AST/Decl/SynthesizedFunctionDecl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ public struct SynthesizedFunctionDecl: Hashable {
/// A copy method.
case copy

/// An equality method.
case equal

/// A global initializer for a binding declaration.
case globalInitialization(BindingDecl.ID)

Expand Down
3 changes: 3 additions & 0 deletions Sources/FrontEnd/Types/BuiltinType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ public enum BuiltinType: TypeProtocol {
/// The type of the built-in module.
case module

/// The type of a union discriminator.
public static let discriminator = word

/// `true` iff `self` is `.i` or `.word`.
public var isInteger: Bool {
switch self {
Expand Down
Loading