Skip to content

Commit

Permalink
Fix exported resource references (migueldeicaza#294)
Browse files Browse the repository at this point in the history
* Update MacroExport.swift

* Update MacroGodotTests.swift
  • Loading branch information
Airyzz authored Dec 10, 2023
1 parent 11020ce commit c8c79fa
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Sources/SwiftGodotMacroLibrary/MacroExport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public struct GodotExport: PeerMacro {
func dynamicCast<T, U>(_ value: T, as type: U.Type) -> U? { value as? U }
let oldRef = dynamicCast (\(varName), as: RefCounted.self)
if let res: \(typeName) = args [0].asObject () {
dynamicCast (\(varName), as: RefCounted.self)?.reference()
dynamicCast (res, as: RefCounted.self)?.reference()
\(varName) = res
}\(optBody)
oldRef?.unreference()
Expand Down
2 changes: 1 addition & 1 deletion Tests/SwiftGodotMacrosTests/MacroGodotTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ final class MacroGodotTests: XCTestCase {
}
let oldRef = dynamicCast (data, as: RefCounted.self)
if let res: MyData = args [0].asObject () {
dynamicCast (data, as: RefCounted.self)?.reference()
dynamicCast (res, as: RefCounted.self)?.reference()
data = res
}
oldRef?.unreference()
Expand Down

0 comments on commit c8c79fa

Please sign in to comment.