Skip to content

Commit

Permalink
Fix readonly closure property precondition
Browse files Browse the repository at this point in the history
  • Loading branch information
j-f1 committed Jan 29, 2023
1 parent d65dd9a commit a711b1a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Sources/WebIDLToSwift/WebIDL+SwiftRepresentation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -671,15 +671,16 @@ extension IDLType: SwiftRepresentable {
// TODO: handle readonly closure properties
// (should they be a JSFunction? or a closure? or something else?))
if case let .single(name) = value {
precondition(!readonly, "readonly closure properties are not supported")
if let callback = ModuleState.types[name] as? IDLCallback {
precondition(!readonly, "readonly closure properties are not supported")
return "\(closureWrapper(callback, optional: false))"
}
if let ref = ModuleState.types[name] as? IDLTypedef,
case let .single(name) = ref.idlType.value,
let callback = ModuleState.types[name] as? IDLCallback
{
assert(ref.idlType.nullable)
precondition(!readonly, "readonly closure properties are not supported")
precondition(ref.idlType.nullable)
return "\(closureWrapper(callback, optional: true))"
}
}
Expand Down

0 comments on commit a711b1a

Please sign in to comment.