mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
getInheritedProtocols() skips type resolution and directly resolves TypeReprs to TypeDecls. On the other hand, when building a protocol requirement signature, we use type resolution to resolve inheritance clause entries so that we can properly support parameterized protocol types, and protocol compositions that contain classes. Since a TypeRepr with an invalid sub-component resolves to an ErrorType, this meant that in invalid code, the first list of protocols might contain protocols that don't appear in the second. This broke rewrite system invariants. Fix this by checking if type resolution failed when building the requirement signature of a protocol, and if so, also look at getInheritedProtocols(). Fixes https://github.com/apple/swift/issues/61020.
15 lines
546 B
Swift
15 lines
546 B
Swift
// RUN: %target-typecheck-verify-swift -debug-generic-signatures 2>&1 | %FileCheck %s
|
|
|
|
protocol Base<T> {
|
|
associatedtype T
|
|
}
|
|
|
|
// CHECK-LABEL: .Derived@
|
|
// CHECK-NEXT: Requirement signature: <Self where Self : Base>
|
|
protocol Derived: Base & DoesNotExist { // expected-error {{cannot find type 'DoesNotExist' in scope}}
|
|
func position(_: T)
|
|
}
|
|
|
|
// CHECK-LABEL: .OtherDerived@
|
|
// CHECK-NEXT: Requirement signature: <Self where Self : Base>
|
|
protocol OtherDerived: Base<DoesNotExist> {} // expected-error {{cannot find type 'DoesNotExist' in scope}} |