Skip to content
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

Add required to NSObject #4884

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions Foundation.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
15FF00CC22934AD7004AD205 /* libCFURLSessionInterface.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 15FF00CA229348F2004AD205 /* libCFURLSessionInterface.a */; };
15FF00CE22934B78004AD205 /* module.map in Headers */ = {isa = PBXBuildFile; fileRef = 15FF00CD22934B49004AD205 /* module.map */; settings = {ATTRIBUTES = (Public, ); }; };
231503DB1D8AEE5D0061694D /* TestDecimal.swift in Sources */ = {isa = PBXBuildFile; fileRef = 231503DA1D8AEE5D0061694D /* TestDecimal.swift */; };
2763AC2C2B8BBF64002D79A4 /* TestNSObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2763AC2B2B8BBF64002D79A4 /* TestNSObject.swift */; };
294E3C1D1CC5E19300E4F44C /* TestNSAttributedString.swift in Sources */ = {isa = PBXBuildFile; fileRef = 294E3C1C1CC5E19300E4F44C /* TestNSAttributedString.swift */; };
2EBE67A51C77BF0E006583D5 /* TestDateFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2EBE67A31C77BF05006583D5 /* TestDateFormatter.swift */; };
316577C425214A8400492943 /* URLSessionTaskMetrics.swift in Sources */ = {isa = PBXBuildFile; fileRef = 316577C325214A8400492943 /* URLSessionTaskMetrics.swift */; };
Expand Down Expand Up @@ -823,6 +824,7 @@
15FF00CD22934B49004AD205 /* module.map */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.module-map"; name = module.map; path = CoreFoundation/URL.subproj/module.map; sourceTree = SOURCE_ROOT; };
22B9C1E01C165D7A00DECFF9 /* TestDate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestDate.swift; sourceTree = "<group>"; };
231503DA1D8AEE5D0061694D /* TestDecimal.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestDecimal.swift; sourceTree = "<group>"; };
2763AC2B2B8BBF64002D79A4 /* TestNSObject.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestNSObject.swift; sourceTree = "<group>"; };
294E3C1C1CC5E19300E4F44C /* TestNSAttributedString.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestNSAttributedString.swift; sourceTree = "<group>"; };
2EBE67A31C77BF05006583D5 /* TestDateFormatter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestDateFormatter.swift; sourceTree = "<group>"; };
316577C325214A8400492943 /* URLSessionTaskMetrics.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = URLSessionTaskMetrics.swift; path = URLSession/URLSessionTaskMetrics.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1915,6 +1917,7 @@
5B6F17921C48631C00935030 /* TestNSNull.swift */,
EA66F63F1BF1619600136161 /* TestNSNumber.swift */,
684C79001F62B611005BD73E /* TestNSNumberBridging.swift */,
2763AC2B2B8BBF64002D79A4 /* TestNSObject.swift */,
D834F9931C31C4060023812A /* TestNSOrderedSet.swift */,
7900433A1CACD33E00ECCBF1 /* TestNSPredicate.swift */,
E876A73D1C1180E000F279EC /* TestNSRange.swift */,
Expand Down Expand Up @@ -3215,6 +3218,7 @@
5B13B33F1C582D4C00651CE2 /* TestPropertyListSerialization.swift in Sources */,
5B13B32C1C582D4C00651CE2 /* TestDate.swift in Sources */,
C7DE1FCC21EEE67200174F35 /* TestUUID.swift in Sources */,
2763AC2C2B8BBF64002D79A4 /* TestNSObject.swift in Sources */,
231503DB1D8AEE5D0061694D /* TestDecimal.swift in Sources */,
7900433C1CACD33E00ECCBF1 /* TestNSPredicate.swift in Sources */,
5B13B33B1C582D4C00651CE2 /* TestNumberFormatter.swift in Sources */,
Expand Down
2 changes: 1 addition & 1 deletion Sources/Foundation/NSObject.swift
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ open class NSObject : NSObjectProtocol, Equatable, Hashable {

/// Implemented by subclasses to initialize a new object immediately after memory
/// for it has been allocated.
public init() {}
public required init() {}

/// Returns the object returned by `copy(with:)`.
///
Expand Down
22 changes: 22 additions & 0 deletions Tests/Foundation/Tests/TestNSObject.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2024 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//

class TestNSObject : XCTestCase {
static var allTests: [(String, (TestNSObject) -> () throws -> Void)] {
return [
("test_requiredInit", test_requiredInit),
]
}

func test_requiredInit() {
func helper<Delegate: NSObject>() -> Delegate {
Delegate()
}
}
}
1 change: 1 addition & 0 deletions Tests/Foundation/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ var allTestCases = [
testCase(TestNSNull.allTests),
testCase(TestNSNumber.allTests),
testCase(TestNSNumberBridging.allTests),
testCase(TestNSObject.allTests),
testCase(TestNumberFormatter.allTests),
testCase(TestOperationQueue.allTests),
testCase(TestNSOrderedSet.allTests),
Expand Down