         }
         let setterCode: String
         if field.isWritable {
-            let setterBody = instanceSetter(for: field, ref: idiomaticRef, knownRecord: knownRecord, indentation: doubleIndent, record, target: pointee, ptr: "newValue")
+            let cast = fieldRef.isVoid ? setterExpression : fieldRef.cast(expression: setterExpression, from: varRef)
+            let setterBody = pointee + " = " + cast
             setterCode = swiftCode(field, doubleIndent + "\(deprecated) set {\n" +
                 doubleIndent + indentation + setterBody + "\n" +
                 doubleIndent + "}\n", indentation: doubleIndent)

            typeName = field.returnTypeName(for: record, beingIdiomatic: false, useStruct: true)
        }
        let knownRecord = ptrLevel == 1 ? GIR.knownRecords[containedTypeRef.type.name] : nil
        let structRef = knownRecord?.structRef
        let idiomaticTypeName: String
        let underlyingRef: TypeReference
        if ptrLevel == 0, let optionSet = field.knownBitfield {
            underlyingRef = optionSet.underlyingCRef
            idiomaticTypeName = typeName
        } else if ptrLevel == 1, let structRef = structRef {
            underlyingRef = idiomaticRef
            idiomaticTypeName = structRef.forceUnwrappedName
        } else {
            underlyingRef = fieldTypeRef.isVoid ? containedTypeRef : fieldTypeRef
            idiomaticTypeName = typeName.doForceOptional ? (typeName + "!") : typeName
        }
        let varDecl = swiftCode(field, indentation + "@inlinable \(publicDesignation)var \(swname): \(idiomaticTypeName) {\n", indentation: indentation)
        let deprecated = field.deprecated != nil ? "@available(*, deprecated) " : ""
        let getterCode: String
        if field.isReadable {
            let cast = underlyingRef.cast(expression: pointee, from: containedTypeRef)
            let head = doubleIndent + "\(deprecated)get {\n" + doubleIndent +
                indentation + "let rv = "
            let tail = "\n"

        return code
    }
}

/// Swift code for the parameters of a constructor
public func constructorParam(_ method: GIR.Method, prefix: String?) -> String {
