Skip to content

Commit

Permalink
Value types currently doesn't works...
Browse files Browse the repository at this point in the history
  • Loading branch information
rock88 committed Apr 8, 2021
1 parent 7495304 commit 68c1cb1
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions Sources/EasyDi.swift
Original file line number Diff line number Diff line change
Expand Up @@ -424,12 +424,14 @@ open class Assembly: AssemblyInternal {
if context.singletons[key] == nil {
context.singletons[key] = result
} else {
var current = context.singletons[key] as! ObjectType
let currentPointer = withUnsafePointer(to: &current, { unsafeBitCast($0.pointee, to: Int.self) })
let resultPointer = withUnsafePointer(to: &result, { unsafeBitCast($0.pointee, to: Int.self) })
let current = context.singletons[key] as! ObjectType

if currentPointer != resultPointer {
fatalError("Singleton already exist, inspect your dependencies graph", #file, #line)
if type(of: current) is AnyClass {
if unsafeBitCast(current, to: Int.self) != unsafeBitCast(result, to: Int.self) {
fatalError("Singleton already exist, inspect your dependencies graph", #file, #line)
}
} else {
// Skip value types
}
}
}
Expand Down

0 comments on commit 68c1cb1

Please sign in to comment.