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-1158] Sub-subclass doesn't conform to protocol #43766
Comments
Comment by Diego (JIRA) Related: badoo/Chatto#60 As this seems to be solved in master, is there any chance to cherry-pick the fix for swift-2.2.1? |
Comment by Diego (JIRA) Also, in the screenshot in badoo/Chatto#60 the error message says "DemoMessagePresenter.swift:124:38: error: cannot convert value of type 'InteractionHandlerT?' to expected argument type '_?'" which is quite misleading. In that screenshot-code, taking the return value into a let variable changes the error to "Return expression of type 'DemoMessagePresenter<ViewModelBuilderT, InteractionHandlerT>' does not conform to 'ChatItemPresenterProtocol'" which is more sensible. |
@atrick, any idea which recent commit might have fixed this? |
diegosanchezr (JIRA User), would you be able to provide a project that reproduces the problem? I was trying to put together a test case, but I can't get it to fail against swift-2.2-branch: diff --git a/test/decl/class/Inputs/inheritance_protocol_multi_file_2.swift b/test/decl/class/Inputs/inheritance_protocol_multi_file_2.swift
new file mode 100644
index 0000000..3180548
--- /dev/null
+++ b/test/decl/class/Inputs/inheritance_protocol_multi_file_2.swift
@@ -0,0 +1,10 @@
+class ClassLevel3: ClassLevel2 {
+ override init() {
+ super.init()
+ }
+}
+
+public func createClassLevel3() -> MyProtocol {
+ let class3 = ClassLevel3()
+ return class3 // <- Compiler error. Says doesn't conform to MyProtocol
+}
diff --git a/test/decl/class/inheritance_protocol_multi_file.swift b/test/decl/class/inheritance_protocol_multi_file.swift
new file mode 100644
index 0000000..179bc5d
--- /dev/null
+++ b/test/decl/class/inheritance_protocol_multi_file.swift
@@ -0,0 +1,12 @@
+// RUN: %target-swift-frontend -parse -verify -primary-file %s %S/Inputs/inheritance_protocol_multi_file_2.swift
+// RUN: %target-swift-frontend -parse -verify %s -primary-file %S/Inputs/inheritance_protocol_multi_file_2.swift
+// RUN: %target-swift-frontend -emit-ir -verify -whole-module-optimization %s %S/Inputs/inheritance_protocol_multi_file_2.swift && false
+// RUN: %target-swift-frontend -emit-ir -verify -whole-module-optimization %S/Inputs/inheritance_protocol_multi_file_2.swift %s
+
+public protocol MyProtocol {}
+public class ClassLevel1: MyProtocol {
+ public init() {}
+}
+public class ClassLevel2: ClassLevel1 {
+ public override init () {}
+} |
Comment by Diego (JIRA) @jckarter Take a look at Example.zip. When I mean different modules I mean frameworks, not just different files |
Thanks for the clarification diegosanchezr (JIRA User). |
Got a reproducer. Only affects swift-2.2-branch, not master: diff --git a/test/decl/class/Inputs/inheritance_protocol_multi_module_2.swift b/test/decl/class/Inputs/inheritance_protocol_multi_module_2.swift
new file mode 100644
index 0000000..7a6ebb4
--- /dev/null
+++ b/test/decl/class/Inputs/inheritance_protocol_multi_module_2.swift
@@ -0,0 +1,12 @@
+import Mod
+
+class ClassLevel3: ClassLevel2 {
+ override init() {
+ super.init()
+ }
+}
+
+public func createClassLevel3() -> MyProtocol {
+ let class3 = ClassLevel3()
+ return class3 // <- Compiler error. Says doesn't conform to MyProtocol
+}
diff --git a/test/decl/class/inheritance_protocol_multi_module.swift b/test/decl/class/inheritance_protocol_multi_module.swift
new file mode 100644
index 0000000..cb4b029
--- /dev/null
+++ b/test/decl/class/inheritance_protocol_multi_module.swift
@@ -0,0 +1,14 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: %target-swift-frontend -emit-module-path %t/Mod.swiftmodule -module-name Mod %s
+// RUN: %target-swift-frontend -parse -verify -I %t %S/Inputs/inheritance_protocol_multi_module_2.swift
+
+/* module Mod */
+
+public protocol MyProtocol {}
+public class ClassLevel1: MyProtocol {
+ public init() {}
+}
+public class ClassLevel2: ClassLevel1 {
+ public override init () {}
+} |
Testing a fix (borrowed from @bitjammer's fix to master): #2075 |
Comment by Diego (JIRA) Confirming it's fixed in swift-2.2.1-SNAPSHOT-2016-04-12-a, thank u |
Attachment: Download
Additional Detail from JIRA
md5: 88d26548a43585e6ea0dfa127129503d
Issue Description:
Module 1:
Modue 2:
Workaround:
Only happens with whole-module-optimization. Affected versions: swift-2.2, swift-2.2.1-SNAPSHOT-2016-03-28-a.
Doesn't affect swift-DEVELOPMENT-SNAPSHOT-2016-03-24-a
The text was updated successfully, but these errors were encountered: