-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Closed
Labels
associated type inferencebugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfconformancesFeature → protocol: protocol conformancesFeature → protocol: protocol conformancesswift 6.0type checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysisunexpected errorBug: Unexpected errorBug: Unexpected error
Description
| Previous ID | SR-15027 |
| Radar | rdar://problem/81587765 |
| Original Reporter | @jepers |
| Type | Bug |
Environment
Xcode 12.5.1, macOS 11.4
Xcode 13 beta3, macOS 11.5
Additional Detail from JIRA
| Votes | 1 |
| Component/s | |
| Labels | Bug |
| Assignee | None |
| Priority | Medium |
md5: 695475a3af144ed4ae3cd8dbf8d77adb
Issue Description:
This compiles:
protocol P {
associatedtype T
var a: T { get }
var b: T { get }
}
struct S: P {
let a: Int
let b: T
} but this does not (surprisingly):
protocol P {
associatedtype T
var a: T { get }
var b: T { get }
var c: T { get }
}
struct S: P {
let a: Int
let b: T
let c: T // ERROR: Reference to invalid associated type 'T' of type 'S'
}Changing property to func produces same behavior.
Another similar example:
protocol P {
associatedtype T
func foo(x: T) -> T
}
struct S: P {
func foo(x: Int) -> T { 123 } // ERROR: Reference to invalid associated type 'T' of type 'S'
}Originating thread:
https://forums.swift.org/t/associatedtype-not-inferred/50947
Metadata
Metadata
Assignees
Labels
associated type inferencebugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfconformancesFeature → protocol: protocol conformancesFeature → protocol: protocol conformancesswift 6.0type checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysisunexpected errorBug: Unexpected errorBug: Unexpected error