Files
swift-mirror/validation-test/compiler_crashers_2_fixed/0122-rdar27383752.swift
Huon Wilson d33a5c16f2 [Sema] Explicit error for "extension GenericClass : ObjcProtocol".
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.
2018-04-13 08:09:02 +10:00

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>) {
}
}