Skip to content

Commit 225c463

Browse files
committed
Simplify _GlueClassHook to work around Linux crash
Fixes #6
1 parent 485f5cc commit 225c463

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

Sources/Orion/ClassHook+Glue.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ public final class _GlueClassHookStorage {
2727
/// used to satisfy the compiler until the actual glue is provided.
2828
///
2929
/// :nodoc:
30-
public enum _GlueClassHookPlaceholder<HookType: ClassHookProtocol>: _GlueClassHook {
30+
public enum _GlueClassHookPlaceholder: _GlueClassHook {
31+
public class HookType: ClassHook<NSObject> {}
3132
public typealias OrigType = HookType
3233
public typealias SuprType = HookType
3334

@@ -75,8 +76,8 @@ public struct _GlueClassHookBuilder {
7576
/// :nodoc:
7677
public protocol _GlueClassHook: _GlueAnyHook {
7778
associatedtype HookType: ClassHookProtocol
78-
associatedtype OrigType: ClassHookProtocol where OrigType.Target == HookType.Target
79-
associatedtype SuprType: ClassHookProtocol where SuprType.Target == HookType.Target
79+
associatedtype OrigType: ClassHookProtocol
80+
associatedtype SuprType: ClassHookProtocol
8081

8182
static var storage: _GlueClassHookStorage { get }
8283
static func activate(withClassHookBuilder builder: inout _GlueClassHookBuilder)

Sources/Orion/ClassHook.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ public protocol ClassHookProtocol: class, AnyHook {
3131
/// - See: `_GlueAnyHook`
3232
///
3333
/// :nodoc:
34-
associatedtype _Glue: _GlueClassHook = _GlueClassHookPlaceholder<Self>
35-
where _Glue.HookType == Self
34+
associatedtype _Glue: _GlueClassHook = _GlueClassHookPlaceholder
3635

3736
/// The name of the target class, or the empty string to use `Target.self`.
3837
///
@@ -259,7 +258,7 @@ extension ClassHookProtocol {
259258
@_transparent
260259
public var orig: Self {
261260
disableRecursionCheck()
262-
guard let unwrapped = _Glue.OrigType(target: target) as? Self
261+
guard let target = target as? _Glue.OrigType.Target, let unwrapped = _Glue.OrigType(target: target) as? Self
263262
else { orionError("Could not get orig") }
264263
return unwrapped
265264
}
@@ -277,7 +276,7 @@ extension ClassHookProtocol {
277276
@_transparent
278277
public var supr: Self {
279278
disableRecursionCheck()
280-
guard let unwrapped = _Glue.SuprType(target: target) as? Self
279+
guard let target = target as? _Glue.SuprType.Target, let unwrapped = _Glue.SuprType(target: target) as? Self
281280
else { orionError("Could not get supr") }
282281
return unwrapped
283282
}

Sources/OrionProcessor/OrionDiagnosticEngine.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ public enum OrionDiagnosticConsumer {
3232
public class OrionDiagnosticEngine {
3333
private class MUXConsumer: DiagnosticConsumer {
3434
// this type pipes messages from many `DiagnosticEngine`s
35-
// to one OrionDiagnosticEngine
35+
// to one OrionDiagnosticEngine. We maintain a strong ref
36+
// to the Orion engine to ensure that it isn't deinit'd
37+
// until all of its child `DiagnosticEngine`s are.
3638
let engine: OrionDiagnosticEngine
3739
init(engine: OrionDiagnosticEngine) {
3840
self.engine = engine

0 commit comments

Comments
 (0)