You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
swift-ci opened this issue
Apr 25, 2017
· 5 comments
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler in itselfcrashBug: A crash, i.e., an abnormal termination of software
The following code causes a compiler issue in 3.1, while it worked on 3.0: -
Here is the code:
import UIKit
public protocol Addable: class {
static func +(lhs: Self, rhs: NSLayoutConstraint) -> NSLayoutConstraint
static func +(lhs: Self, rhs: [NSLayoutConstraint]) -> [NSLayoutConstraint]
}
extension UIView : Addable {}
extension Addable where Self: UIView
{
/// To add single constraint on the lhs view
public static func +(lhs: Self, rhs: NSLayoutConstraint) -> NSLayoutConstraint {
lhs.addConstraint(rhs)
return rhs
}
/// To add multiple constraints on the lhs view
public static func +(lhs: Self, rhs: [NSLayoutConstraint]) -> [NSLayoutConstraint] {
return rhs.map { lhs + $0 }
}
}
Note: - Now If we remove Second method of protocol & we also remove its implementation part from protocol extension then the remaining code is compilable.
As far as I know there is something wrong with — rhs.map { lhs + $0 } in the second method of Addable. means using the first method inside the second method.
If we use the same code with custom operators in the same way then the issue will remain same. Here is the link to my project KVConstraintKit in which I have made few custom operators and all of them having the same issues but works fine in swift 3.0.
The text was updated successfully, but these errors were encountered:
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler in itselfcrashBug: A crash, i.e., an abnormal termination of software
Attachment: Download
Environment
Xcode 8.3, 8.3.1 & 8.3.2
Additional Detail from JIRA
md5: 04da073b449197f8764045007efc5985
Issue Description:
The following code causes a compiler issue in 3.1, while it worked on 3.0: -
Here is the code:
Note: - Now If we remove Second method of protocol & we also remove its implementation part from protocol extension then the remaining code is compilable.
As far as I know there is something wrong with — rhs.map { lhs + $0 } in the second method of Addable. means using the first method inside the second method.
If we use the same code with custom operators in the same way then the issue will remain same. Here is the link to my project KVConstraintKit in which I have made few custom operators and all of them having the same issues but works fine in swift 3.0.
The text was updated successfully, but these errors were encountered: