Skip to content

Tests: Expand tests for @backDeployed diagnostics on Obj-C compatible decls #77570

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions test/attr/attr_backDeployed_objc.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -parse-as-library -verify %s

// REQUIRES: OS=macosx

import Foundation

public class SwiftClass {
@backDeployed(before: macOS 12.0) // expected-error {{'@backDeployed' must not be used on an '@objc' instance method}}
@objc final public func objCMethod() {}
}

public class ObjCClass: NSObject {
@backDeployed(before: macOS 12.0) // expected-error {{'@backDeployed' cannot be applied to a non-final instance method}}
public func method() {}

@backDeployed(before: macOS 12.0) // expected-error {{'@backDeployed' must not be used on an '@objc' instance method}}
@objc public func objcMethod() {}

@backDeployed(before: macOS 12.0) // expected-error {{'@backDeployed' must not be used on an '@objc' instance method}}
@objc final public func finalObjcMethod() {}

@backDeployed(before: macOS 12.0)
final public func finalMethod() {}

@backDeployed(before: macOS 12.0) // expected-error {{'@backDeployed' cannot be applied to a non-final instance method}}
@nonobjc public func nonObjCMethod() {}

@backDeployed(before: macOS 12.0)
@nonobjc final public func finalNonObjCMethod() {}

@backDeployed(before: macOS 12.0) // expected-error {{'@backDeployed' cannot be applied to a non-final property}}
public var property: [Int] { [1] }

@backDeployed(before: macOS 12.0) // expected-error {{'@backDeployed' must not be used on an '@objc' property}}
@objc public var objCProperty: [Int] { [1] }

@backDeployed(before: macOS 12.0) // expected-error {{'@backDeployed' must not be used on an '@objc' property}}
@objc public final var finalObjCProperty: [Int] { [1] }

@backDeployed(before: macOS 12.0)
public final var finalProperty: [Int] { [1] }

@backDeployed(before: macOS 12.0) // expected-error {{'@backDeployed' cannot be applied to a non-final property}}
@nonobjc public var nonObjCProperty: [Int] { [1] }

@backDeployed(before: macOS 12.0)
@nonobjc public final var finalNonObjCProperty: [Int] { [1] }
}

extension DummyClass {
@backDeployed(before: macOS 12.0) // expected-error {{'@backDeployed' cannot be applied to a non-final instance method}}
public func method() {}

@backDeployed(before: macOS 12.0) // expected-error {{'@backDeployed' must not be used on an '@objc' instance method}}
@objc public func objcMethod() {}

@backDeployed(before: macOS 12.0) // expected-error {{'@backDeployed' must not be used on an '@objc' instance method}}
@objc final public func finalObjcMethod() {}

@backDeployed(before: macOS 12.0)
final public func finalMethod() {}

@backDeployed(before: macOS 12.0) // expected-error {{'@backDeployed' cannot be applied to a non-final instance method}}
@nonobjc public func nonObjCMethod() {}

@backDeployed(before: macOS 12.0)
@nonobjc final public func finalNonObjCMethod() {}

@backDeployed(before: macOS 12.0) // expected-error {{'@backDeployed' cannot be applied to a non-final property}}
public var property: [Int] { [1] }

@backDeployed(before: macOS 12.0) // expected-error {{'@backDeployed' must not be used on an '@objc' property}}
@objc public var objCProperty: [Int] { [1] }

@backDeployed(before: macOS 12.0) // expected-error {{'@backDeployed' must not be used on an '@objc' property}}
@objc public final var finalObjCProperty: [Int] { [1] }

@backDeployed(before: macOS 12.0)
public final var finalProperty: [Int] { [1] }

@backDeployed(before: macOS 12.0) // expected-error {{'@backDeployed' cannot be applied to a non-final property}}
@nonobjc public var nonObjCProperty: [Int] { [1] }

@backDeployed(before: macOS 12.0)
@nonobjc public final var finalNonObjCProperty: [Int] { [1] }
}
8 changes: 0 additions & 8 deletions test/attr/attr_objc.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2696,11 +2696,3 @@ class issue55246 {
subscript<T>(foo : [T]) -> Int { return 0 }
// access-note-adjust{{@objc}} expected-error@-1 {{subscript cannot be marked @objc because it has generic parameters}}
}

// @backDeployed

public class BackDeployClass {
@backDeployed(before: macOS 12.0) // expected-error {{'@backDeployed' must not be used on an '@objc' instance method}}
@objc
final public func objcMethod() {}
}