New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SR-7341] Type checker regression for multiple properties with different return types as of March 28 master snapshot #49889
Comments
Comment by Ben A (JIRA) I tried coming up with a smaller test case: final class Wrapper<Wrapped> {
let value: Wrapped
init(value: Wrapped) { self.value = value }
}
final class Action {
let isEnabled: Wrapper<Int>
init() { self.isEnabled = Wrapper(value: 1) }
} file2.swift final class OtherWrapper<Wrapped> {
let value: Wrapped
init(value: Wrapped) { self.value = value }
}
extension Action {
fileprivate var isEnabled: OtherWrapper<Bool> { return OtherWrapper(value: self.isEnabled.value != 0) }
} However, that code compiles fine in Swift 4.1, the March 28 master snapshot, and April 20 master snapshot. But, the attached zipped project still doesn't build in the March 28 master snapshot, nor the latest April 20 master snapshot. This is the main issue preventing us from verifying SR-7337 as well as testing the new batch mode. |
Comment by Ben A (JIRA) Okay I had a look at PRs that landed between the March 26 master snapshot (when this last worked) and the March 28 master snapshot (when this first regressed), and this PR seems like a likely culprit given the PR description + related bugs it closed: #15412 @hamishknight does that seem plausible? If so, would you mind having a look at the attached sample project? |
Here's a reduced test case, it requires two modules: Module A, a.swift: public class Action<T> {
public var i = 0
} Module B, b.swift: import A
extension Action {
var i: String {
let x: Int = i // in 4.1 no error, in the 2018-04-18 snapshot error: Cannot convert value of type 'String' to specified type 'Int'
return String(x)
}
} The above compiles in 4.1, but doesn't in the 2018-04-18 snapshot. I'm not sure what the exact cause of the problem is (and unfortunately I don't quite have the time to look into it in detail at the moment), though I agree that it's likely a result of #15412 – previously we would have given Though |
cc @belkadan |
Comment by Ben A (JIRA) No problem![]( Thank you so much for providing the small repro case and all of the extra context) |
Thanks to both of you. Hm, I wonder if the type checker wasn't prepared to deal with property overloads. @swift-ci create |
Comment by Ben A (JIRA) This is still an issue in the Xcode 10 beta. I know you all must have been super busy leading up to today's announcements; just wanted to flag this again as it's the major blocker for us doing any beta testing, batch mode testing, etc. Thanks! |
We saw this in WWDC 18 lab that this issue stops users from using Xcode 10 with Pods. |
cc @DougGregor |
The above linked PR resolves the issue in Swift 5 under Swift 4 compatibility mode. I’ve filed https://bugs.swift.org/browse/SR-8619 to track a broader Swift 5 mode change where we no longer shadow another module’s property overload regardless of whether the two properties are defined in extensions of generic types. |
Attachment: Download
Environment
macOS 10.13.4
Xcode 9.3 w/ Swift 4.1 (App Store version)
Additional Detail from JIRA
md5: 0f27ae3ae554c0de612033abe1dbe496
Issue Description:
Our project uses the open source project ReactiveObjCBridge, which helps bridge the ReactiveObjC and ReactiveSwift worlds. While trying to reproduce and check for fixes for SR-7206, I ran into a new type checker issue that has been present since the March 28 master snapshot and still isn't fixed as of the April 2 master snapshot (not necessarily expecting a fix, but sometimes issues come and go on master). Here's the section of code in question in ReactiveObjCBridge:
With that
isEnabled
decl, there becomes 2isEnabled
properties with different return types on the same type. In Swift 4.1 this compiles fine, but in these recent snapshots you get an error about `RACSignal<NSNumber>` having no member 'producer'. This is easily corrected (at least temporarily to work through this issue and move on with compiling) by updating this line to:I believe this forces it to pick the correct
self.isEnabled
, but then you get this type error about the map closure:Cannot convert value of type '(NSNumber) -> NSNumber' to expected argument type '(_) -> _'
. I haven't been able to get passed this one, but in general it seems like there's a type checker issue that's worth reporting here.Unfortunately, the open source project doesn't meet a few of the requirements for adding it to the source compat suite. I'm fairly certain this project no longer builds in Swift 3 compatibility mode, and it also requires Carthage or CocoaPods to build correctly. Given that, I've attached a zip file with a sample project with this dependency. You could be able to just open the sample project workspace and build using any of the snapshots mentioned to reproduce this issue. Thanks in advance!
The text was updated successfully, but these errors were encountered: