Files
Sourcery/SourceryRuntime/Sources/Common/AST/Actor.swift
T
Ruslan A 7153768c65 Fix associatedtype generics (#1345)
* Preliminary associatedtype support

* Implemented associatedtype support with generic requirements

* Fixed failing test

* Squashed commit of the following:

commit 9d01e6f99a
Author: Ruslan A <r.alikhamov@gmail.com>
Date:   Fri Jun 14 20:06:41 2024 +0400

    Improved concurrency support in SwiftTemplate caching (#1344)

* Removed test code

* Removed comment

* Updated Linux classes

* update internal boilerplate code.

* Updated generated code

* Removed warnings

* Updated expected file

* Updated expected file

* Adjusted protocol type for Linux

* Removed protocol composition due to Swift compiler crash under Linux
2024-06-19 22:50:18 +04:00

116 lines
3.7 KiB
Swift

import Foundation
// sourcery: skipDescription
/// Descibes Swift actor
#if canImport(ObjectiveC)
@objc(SwiftActor) @objcMembers
#endif
public final class Actor: Type {
// sourcery: skipJSExport
public class var kind: String { return "actor" }
/// Returns "actor"
public override var kind: String { Self.kind }
/// Whether type is final
public var isFinal: Bool {
modifiers.contains { $0.name == "final" }
}
/// Whether method is distributed method
public var isDistributed: Bool {
modifiers.contains(where: { $0.name == "distributed" })
}
/// :nodoc:
public override init(name: String = "",
parent: Type? = nil,
accessLevel: AccessLevel = .internal,
isExtension: Bool = false,
variables: [Variable] = [],
methods: [Method] = [],
subscripts: [Subscript] = [],
inheritedTypes: [String] = [],
containedTypes: [Type] = [],
typealiases: [Typealias] = [],
genericRequirements: [GenericRequirement] = [],
attributes: AttributeList = [:],
modifiers: [SourceryModifier] = [],
annotations: [String: NSObject] = [:],
documentation: [String] = [],
isGeneric: Bool = false,
implements: [String: Type] = [:],
kind: String = Actor.kind) {
super.init(
name: name,
parent: parent,
accessLevel: accessLevel,
isExtension: isExtension,
variables: variables,
methods: methods,
subscripts: subscripts,
inheritedTypes: inheritedTypes,
containedTypes: containedTypes,
typealiases: typealiases,
genericRequirements: genericRequirements,
attributes: attributes,
modifiers: modifiers,
annotations: annotations,
documentation: documentation,
isGeneric: isGeneric,
implements: implements,
kind: kind
)
}
/// :nodoc:
// sourcery: skipJSExport
override public var description: String {
var string = super.description
string.append(", ")
string.append("kind = \(String(describing: self.kind)), ")
string.append("isFinal = \(String(describing: self.isFinal)), ")
string.append("isDistributed = \(String(describing: self.isDistributed))")
return string
}
override public func diffAgainst(_ object: Any?) -> DiffableResult {
let results = DiffableResult()
guard let castObject = object as? Actor else {
results.append("Incorrect type <expected: Actor, received: \(Swift.type(of: object))>")
return results
}
results.append(contentsOf: super.diffAgainst(castObject))
return results
}
/// :nodoc:
// sourcery: skipJSExport
public override var hash: Int {
var hasher = Hasher()
hasher.combine(super.hash)
return hasher.finalize()
}
/// :nodoc:
public override func isEqual(_ object: Any?) -> Bool {
guard let rhs = object as? Actor else { return false }
return super.isEqual(rhs)
}
// sourcery:inline:Actor.AutoCoding
/// :nodoc:
required public init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
/// :nodoc:
override public func encode(with aCoder: NSCoder) {
super.encode(with: aCoder)
}
// sourcery:end
}