@@ -118,7 +118,7 @@ extension FileTranslator {
118118 let assignExprs : [ Expression ] = properties. map { property in
119119 let typeUsage = property. typeUsage
120120 return . assignment(
121- left: . identifierPattern ( " self " ) . dot ( property. swiftSafeName) ,
121+ left: . selfDot ( property. swiftSafeName) ,
122122 right: . try (
123123 . identifierPattern( " container " ) . dot ( " decode \( typeUsage. isOptional ? " IfPresent " : " " ) " )
124124 . call ( [
@@ -156,7 +156,7 @@ extension FileTranslator {
156156 . try (
157157 . identifierPattern( " container " ) . dot ( " encode \( property. typeUsage. isOptional ? " IfPresent " : " " ) " )
158158 . call ( [
159- . init( label: nil , expression: . identifierPattern ( property. swiftSafeName) ) ,
159+ . init( label: nil , expression: . selfDot ( property. swiftSafeName) ) ,
160160 . init( label: " forKey " , expression: . dot( property. swiftSafeName) ) ,
161161 ] )
162162 )
@@ -181,7 +181,7 @@ extension FileTranslator {
181181 let assignExprs : [ Expression ] = properties. map { property, isKeyValuePair in
182182 let decoderExpr : Expression =
183183 isKeyValuePair ? . initFromDecoderExpr( ) : . decodeFromSingleValueContainerExpr( )
184- return . assignment( left: . identifierPattern ( property. swiftSafeName) , right: . try ( decoderExpr) )
184+ return . assignment( left: . selfDot ( property. swiftSafeName) , right: . try ( decoderExpr) )
185185 }
186186 return decoderInitializer ( body: assignExprs. map { . expression( $0) } )
187187 }
@@ -194,12 +194,11 @@ extension FileTranslator {
194194 {
195195 let exprs : [ Expression ]
196196 if let firstSingleValue = properties. first ( where: { !$0. isKeyValuePair } ) {
197- let expr : Expression = . identifierPattern ( firstSingleValue. property. swiftSafeName)
197+ let expr : Expression = . selfDot ( firstSingleValue. property. swiftSafeName)
198198 . encodeToSingleValueContainerExpr ( gracefully: false )
199199 exprs = [ expr]
200200 } else {
201- exprs = properties. filter { $0. isKeyValuePair } . map ( \. property. swiftSafeName)
202- . map { name in . identifierPattern( name) . encodeExpr ( ) }
201+ exprs = properties. filter ( \. isKeyValuePair) . map { . selfDot( $0. property. swiftSafeName) . encodeExpr ( ) }
203202 }
204203 return encoderFunction ( body: exprs. map { . expression( $0) } )
205204 }
@@ -216,18 +215,15 @@ extension FileTranslator {
216215 let assignBlocks : [ CodeBlock ] = properties. map { ( property, isKeyValuePair) in
217216 let decoderExpr : Expression =
218217 isKeyValuePair ? . initFromDecoderExpr( ) : . decodeFromSingleValueContainerExpr( )
219- let assignExpr : Expression = . assignment(
220- left: . identifierPattern( property. swiftSafeName) ,
221- right: . try ( decoderExpr)
222- )
218+ let assignExpr : Expression = . assignment( left: . selfDot( property. swiftSafeName) , right: . try ( decoderExpr) )
223219 return . expression( assignExpr. wrapInDoCatchAppendArrayExpr ( ) )
224220 }
225221 let atLeastOneNotNilCheckExpr : Expression = . try (
226222 . identifierType( TypeName . decodingError) . dot ( " verifyAtLeastOneSchemaIsNotNil " )
227223 . call ( [
228224 . init(
229225 label: nil ,
230- expression: . literal( . array( properties. map { . identifierPattern ( $0. property. swiftSafeName) } ) )
226+ expression: . literal( . array( properties. map { . selfDot ( $0. property. swiftSafeName) } ) )
231227 ) , . init( label: " type " , expression: . identifierPattern( " Self " ) . dot ( " self " ) ) ,
232228 . init( label: " codingPath " , expression: . identifierPattern( " decoder " ) . dot ( " codingPath " ) ) ,
233229 . init( label: " errors " , expression: . identifierPattern( " errors " ) ) ,
@@ -250,14 +246,12 @@ extension FileTranslator {
250246 ? nil
251247 : . try (
252248 . identifierPattern( " encoder " ) . dot ( " encodeFirstNonNilValueToSingleValueContainer " )
253- . call ( [
254- . init( label: nil , expression: . literal( . array( singleValueNames. map { . identifierPattern( $0) } ) ) )
255- ] )
249+ . call ( [ . init( label: nil , expression: . literal( . array( singleValueNames. map { . selfDot( $0) } ) ) ) ] )
256250 )
257251 let encodeExprs : [ Expression ] =
258252 ( encodeSingleValuesExpr. flatMap { [ $0] } ?? [ ] )
259253 + properties. filter { $0. isKeyValuePair } . map ( \. property)
260- . map { property in . identifierPattern ( property. swiftSafeName) . optionallyChained ( ) . encodeExpr ( ) }
254+ . map { property in . selfDot ( property. swiftSafeName) . optionallyChained ( ) . encodeExpr ( ) }
261255 return encoderFunction ( body: encodeExprs. map { . expression( $0) } )
262256 }
263257
0 commit comments