Skip to content

Commit

Permalink
Band-aid, while I figure out why calls of Variant(Object?) crash with…
Browse files Browse the repository at this point in the history
… It's illegal to construct a from , unwrap it or pass it as it is.pwd
  • Loading branch information
migueldeicaza committed Nov 15, 2024
1 parent acebda3 commit c95f7ef
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Sources/SwiftGodot/Variant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,9 @@ extension Optional: VariantStorable where Wrapped: VariantStorable {
public typealias Representable = Wrapped.Representable

public func toVariantRepresentable() -> Wrapped.Representable {
if let wrapped = self {
return wrapped.toVariantRepresentable()
}
// It's not needed and is just a wrong abstraction of internal implementation leaking into the public API
fatalError("It's illegal to construct a `Variant` from `Variant?`, unwrap it or pass it as it is.")
}
Expand Down
7 changes: 6 additions & 1 deletion Tests/SwiftGodotTests/VariantTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ final class VariantTests: GodotTestCase {

XCTAssertEqual (unwrapped, testString)
}


func testWrap() {
let x: Node? = Node()
let j = Variant(x)

}
func testVariantCall() {
let string = "Hello Hello Hello Hello"
let variant = Variant(string)
Expand Down

0 comments on commit c95f7ef

Please sign in to comment.