编译器无法快速对此表达式进行类型检查4? [英] The compiler is unable to type-check this expression swift 4?

查看:489
本文介绍了编译器无法快速对此表达式进行类型检查4?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新xCode之后,我将此错误输入我的代码中:

After updating xCode i am getting this error into my code :

编译器无法合理地对该表达式进行类型检查 时间;尝试将表达式分成不同的子表达式

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

代码:

//check popup in window frame

let spaceFromLeftSide = cutOutViewX.constant + cutOutViewWidth.constant/2 - (options.textWidth + padding*2)/2

if spaceFromLeftSide < 0{

    if options.side == .bottom {
        messageRightSpaceFromBottomDot.constant -= spaceFromLeftSide - padding
    }
    else if options.side == .top{
        messageRightSpaceFromTopDot.constant += spaceFromLeftSide - padding
    }
}

let spaceFromRightSide = cutOutViewX.constant + cutOutViewWidth.constant/2 + (options.textWidth + padding*2)/2

if spaceFromRightSide > targetView.frame.size.width{

    if options.side == .bottom {
        messageRightSpaceFromBottomDot.constant -= spaceFromRightSide - ( targetView.frame.size.width )
    }
    else if options.side == .top{
        messageRightSpaceFromTopDot.constant += spaceFromRightSide - ( targetView.frame.size.width )
    }
}

错误:

let spaceFromRightSide = cutOutViewX.constant + cutOutViewWidth.constant/2 + (options.textWidth + padding*2)/2

如何解决此问题?

推荐答案

编译器无法在合理的时间内对这个表达式进行类型检查;尝试将表达式分成不同的子表达式

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

当快速编译器发现表达式计算过长时,将出现此错误.有关更多详细信息,请在此处检查

This error appears when swift compiler finds the expression calculation lengthy. For more details check here

要解决此问题,您只需要将表情分成较小的部分即可.就像:

To resolve this, you just need to break your expression into smaller parts. Just like:

let cutOutxOrigin = 3 * cutOutViewX.constant / 2
let actualPadding = (options.textWidth + padding * 2) / 2

let spaceFromRightSide = cutOutxOrigin + actualPadding

这篇关于编译器无法快速对此表达式进行类型检查4?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆