Files
swift-mirror/test/ClangImporter/objc_generics_conformance.swift
Henrik G. Olsson cbc0ec3b88 Add -verify-ignore-unrelated where necessary (NFC)
These are tests that fail in the next commit without this flag. This
does not add -verify-ignore-unrelated to all tests with -verify, only
the ones that would fail without it. This is NFC since this flag is
currently a no-op.
2025-10-04 14:19:52 -07:00

44 lines
1.4 KiB
Swift

// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -parse-as-library -verify -verify-ignore-unrelated -swift-version 4 -I %S/Inputs/custom-modules %s
// REQUIRES: objc_interop
// Objective-C generic classes can conform to protocols, but for type witnesses
// (for associated types) cannot depend on the type parameters.
import Foundation
import objc_generics
// rdar://problem/34979938
protocol WithAssocT {
associatedtype T
}
extension GenericClass : WithAssocT { // expected-error{{type 'T' involving Objective-C type parameter 'T' cannot be used for associated type 'T' of protocol 'WithAssocT'}}
}
protocol WithAssocOther {
associatedtype Other
}
extension GenericClass : WithAssocOther {
typealias Other = [T] // expected-error{{type 'GenericClass<T>.Other' (aka 'Array<T>') involving Objective-C type parameter 'T' cannot be used for associated type 'Other' of protocol 'WithAssocOther'}}
}
protocol WithAssocSeparate {
associatedtype Separate
}
extension GenericClass {
typealias Separate = T // expected-note {{'Separate' declared here}}
}
extension GenericClass : WithAssocSeparate { // expected-error {{type 'GenericClass<T>.Separate' (aka 'T') involving Objective-C type parameter 'T' cannot be used for associated type 'Separate' of protocol 'WithAssocSeparate'}}
}
protocol WithAssocElement {
associatedtype Element
}
extension GenericClass : WithAssocElement {
typealias Element = Int
}