Skip to content

Commit

Permalink
Merge pull request #1563 from hylo-lang/synthesize-equatable
Browse files Browse the repository at this point in the history
Implement equality operator synthesization
  • Loading branch information
kyouko-taiga authored Aug 20, 2024
2 parents b5bd439 + 3742593 commit 211d4e0
Show file tree
Hide file tree
Showing 8 changed files with 329 additions and 143 deletions.
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

0 comments on commit 211d4e0

Please sign in to comment.