<commit_before>// RUN: %target-swift-frontend -typecheck -verify %s

import Foundation

class X<T> : NSObject {
    init(x: ()) {
        super.init()
    }
}

class Y : X<Int> {
    init(y: ()) {
        super.init(x: ())
    }
}

extension Y {
    @objc func f() {} // expected-error{{@objc is not supported within extensions of generic classes, or classes that inherit from generic classes}}
}<commit_msg>Add files via upload<commit_after>// RUN: %target-swift-frontend -typecheck -verify %s

import Foundation

// Tests for correct detection of the "objc_in_generic_extension" error,
// declared in {Swift Source}/include/swift/AST/DiagnosticsSema.def

// Test "0 levels" deep
class A<T> : NSObject {
    init(a: ()) {
        super.init()
    }
}
extension A {
    // This should throw an error
    @objc func a1() {} // expected-error{{@objc is not supported within extensions of generic classes, or classes that inherit from generic classes}}
    // This should *not* throw an error
    func a2() {}
}

// Test "1 level" deep
class B : A<Int> {
    init(b: ()) {
        super.init(a: ())
    }
}
extension B {
    // This should throw an error
    @objc func b1() {} // expected-error{{@objc is not supported within extensions of generic classes, or classes that inherit from generic classes}}
    // This should *not* throw an error
    func b2() {}
}

// Test "many levels" deep
class C : B {}
class D : C {
    init(d: ()) {
        super.init(b: ())
    }
}
extension D {
    // This should throw an error
    @objc func d1() {} // expected-error{{@objc is not supported within extensions of generic classes, or classes that inherit from generic classes}}
    // This should *not* throw an error
    func d2() {}
}

{'fraction_non_alphanumeric': 0.1325998841922409, 'fraction_numerical': 0.004632310364794441, 'mean_word_length': 2.789473684210526, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1203791', 'n_tokens_mistral': 542, 'n_tokens_neox': 535, 'n_words': 194}