Skip to content

Commit

Permalink
Merge pull request #77570 from tshortli/back-deployed-objc-tests
Browse files Browse the repository at this point in the history
Tests: Expand tests for @backDeployed diagnostics on Obj-C compatible decls
  • Loading branch information
tshortli authored Nov 13, 2024
2 parents 184058e + e52a150 commit 69571db
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 8 deletions.
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() {}
}

0 comments on commit 69571db

Please sign in to comment.