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
SR-5440 Typealias in constrained extension misinterprets the where clause
SR-7217 Protocol composition with conflicting typealiases does not diagnose
Issue Description:
I'm not entirely sure what the intended behavior should be for the examples in the below demonstration program, I suppose the current behavior might be the result of more than one bug.
Perhaps the last example, S6, should be allowed but is currently not working as inteded?
This program compiles successfully with Xcode 9.3 default toolchain and recent development snapshots.
protocol P {
associatedtype A = Int
}
protocol Q {
associatedtype A = Bool
}
struct S1: P {
var v: A // A is Int, as expected.
}
struct S2: P, Q {
var v: A // A is Bool, but should be ambiguous?
}
struct S3: Q, P {
var v: A // A is Int, but should be ambiguous?
}
struct S4<T> {
var v: A // A is Int (Bool with recent snapshots), but should be undeclared?
}
extension S4: P where T == Double {}
extension S4: Q where T == Double {}
struct S5<T> {
var v: A // A is Bool (Int with recent snapshots), but should be undeclared?
}
extension S5: Q where T == Double {}
extension S5: P where T == Double {}
struct S6<T>: P {
var v: A // A is Bool, but should be ambiguos or: Bool only if T == Float, otherwise Int?
}
extension S6: Q where T == Float {}
The text was updated successfully, but these errors were encountered:
struct S<T> {
var v: A // <-- Compiler happy, says A is String here.
// I assume it should be error: A is undeclared
}
extension S where T == Double {
typealias A = String
}
I haven't seen a principled fix while working on this, so it is likely those now 'working' examples are either just a favorable combination of circumstances or the result of some change in validation that makes extensions be visited before primary declarations.
Environment
Xcode 9.3, default toolchain and recent development snapshots
Additional Detail from JIRA
md5: a723144527397c76606f258fbc351848
relates to:
Issue Description:
I'm not entirely sure what the intended behavior should be for the examples in the below demonstration program, I suppose the current behavior might be the result of more than one bug.
Perhaps the last example, S6, should be allowed but is currently not working as inteded?
Related forum post: https://forums.swift.org/t/whats-the-intended-behavior-here-associated-type-with-default-type-conditional-conformances/12094
This program compiles successfully with Xcode 9.3 default toolchain and recent development snapshots.
The text was updated successfully, but these errors were encountered: