mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
If there was any requirements in the @objc protocol, the user got an error in
some form (a complaint about those requirements), but giving the direct error is
better, and handles @objc protocol with no requirements.
Also, fix a hole in that existing @objc method check: in `class Outer<T> { class
Inner {} }`, Inner should be considered generic, but the loop that was checking
for this didn't consider it.
Fixes https://bugs.swift.org/browse/SR-7370 and rdar://problem/39239512.
34 lines
862 B
Swift
34 lines
862 B
Swift
// RUN: %target-swift-frontend %s -typecheck -verify
|
|
// REQUIRES: OS=macosx
|
|
|
|
import Foundation
|
|
import CoreData
|
|
|
|
// Does not segfault
|
|
|
|
@available(macOS 10.12, *)
|
|
class Foo<T>: NSObject, NSFetchedResultsControllerDelegate {
|
|
override init() {
|
|
super.init()
|
|
}
|
|
|
|
@nonobjc func controllerWillChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>) {
|
|
}
|
|
}
|
|
|
|
// Segfaults
|
|
|
|
@available(macOS 10.12, *)
|
|
class Bar<T>: NSObject {
|
|
override init() {
|
|
super.init()
|
|
}
|
|
}
|
|
|
|
@available(macOS 10.12, *)
|
|
extension Bar: NSFetchedResultsControllerDelegate {
|
|
// expected-error@-1 {{conformance of generic class 'Bar<T>' to @objc protocol 'NSFetchedResultsControllerDelegate' cannot be in an extension}}
|
|
@nonobjc func controllerWillChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>) {
|
|
}
|
|
}
|