简体   繁体   中英

The compiler is unable to type-check expression Swift 5?

I am having trouble when trying to compile my code as this error keeps appearing:

The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions.

Here is the section of the code where the error appears: 在此处输入图片说明

Any ideas on how I can get the code to compile and clear this error?

The solution would be to split your expressions into many expressions for example try replacing:

return Council(status: status ?? self.status,
council : council ?? self.council,
year: year ?? self.year,
councilRating: councilRating ?? self.councilRating,
annualChange: annualChange ?? self.annualChange,
councilTax: councilTax ?? self.councilTax)

With:

let s = status ?? self.status
let c = council ?? self.council
let y = year ?? self.year
let cr = councilRating ?? self.councilRating
let ac = annualChange ?? self.annualChange
let ct = councilTax ?? self.councilTax


return Council(status: s,
council : c,
year: y,
councilRating: cr,
annualChange: ac,
councilTax: ct)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM