     switch signal.returns.knownType {
     case is GIR.Record:
         return "return \(signal.returns.typeRef.cast(expression: "output", from: signal.returns.swiftReturnRef))"
-    case let type as GIR.Alias: // use containedTypes
+    case is GIR.Alias: // use containedTypes
         return ""
     case is GIR.Bitfield:
         return "return output.rawValue"

            }
        }

        "public extension \(record.name.swift) {"
        Code.block {
            Code.loop(over: record.signals.filter { signalSanityCheck($0) == nil }) { signal in
                
                commentCode(signal)
                "/// - Note: This function represents signal `\(signal.name)`"
                "/// - Parameter flags: Flags"


func signalSanityCheck(_ signal: GIR.Signal) -> String? {

    var errors: String?
    
    if !signal.args.allSatisfy({ $0.ownershipTransfer == .none }) {
        errors = (errors ?? "") + " (1) argument with owner transfership is not allowed;"
    }
    
    if !signal.args.allSatisfy({ $0.direction == .in }) {
        errors = (errors ?? "") + " (2)  argument out or inout direction is not allowed;"
    }

    if !signal.args.allSatisfy({ $0.typeRef.type.name != "Void" }) {
        errors = (errors ?? "") + " (3)  Void argument is not yet supported;"
    }
    
    if !signal.args.allSatisfy({ $0.typeRef.type.name != "gpointer" }) {
        errors = (errors ?? "") + " (3.1)  gpointer argument is not yet supported;"
    }
    
    if !signal.args.allSatisfy({ !($0.knownType is GIR.Alias) }) || (signal.returns.knownType is GIR.Alias) {
        errors = (errors ?? "") + " (4)  Alias argument or return is not yet supported;"
    }

    if signal.returns.isOptional {
        errors = (errors ?? "") + " (5)  argument or return optional is not allowed;"
    }

    if !signal.args.allSatisfy({ !$0.isArray }) || signal.returns.isArray {
        errors = (errors ?? "") + " (6)  argument or return array is not allowed;"
    }

    if signal.returns.isNullable == true {
        errors = (errors ?? "") + " (7)  argument or return nullability is not allowed;"
    }

    if signal.returns.knownType is GIR.Record {
        errors = (errors ?? "") + " (8)  Record return is not yet supported;"
    }

    return errors.flatMap { "// Warning: signal \(signal.name) is ignored because of" + $0 }
}

func buildSignalExtension(for record: GIR.Record) -> String {
