-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Turn on the Copyable
as an inferred generic constraint by default
#64059
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
swift-ci
merged 5 commits into
swiftlang:main
from
kavon:staging-bootstrap-with-copyable
Mar 5, 2023
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2f734e5
[nfc] remove outdated FIXME's
kavon 091d63a
revise how the `Copyable` constraint is added
kavon d69c037
add a Copyable conformance for `PackExpansionType`
kavon 8406699
add Copyable to a few `-parse-stdlib` tests
kavon 3a77083
note a small diagnostic regression
kavon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// RUN: %empty-directory(%t) | ||
|
||
// This test checks that conformances to _Copyable do not appear in swiftinterface files | ||
|
||
// Generate the parseable interface of the current file via the merge-modules step | ||
// RUN: %target-build-swift -emit-module -o %t/Test.swiftmodule -emit-module-interface-path %t/TestMerge.swiftinterface -module-name Test %s -enable-library-evolution -swift-version 5 | ||
|
||
// Generate the parseable interface of the current file via a single frontend invocation | ||
// RUN: %target-swift-frontend -enable-library-evolution -typecheck -emit-module-interface-path %t/TestSingle.swiftinterface -module-name Test %s -enable-library-evolution -swift-version 5 | ||
|
||
// Make sure Copyable doesn't appear anywhere in these files! | ||
// RUN: %FileCheck --implicit-check-not Copyable %s < %t/TestSingle.swiftinterface | ||
// RUN: %FileCheck --implicit-check-not Copyable %s < %t/TestMerge.swiftinterface | ||
|
||
|
||
// CHECK: forceGenericSubst | ||
public func forceGenericSubst<T>(_ t: T) { | ||
print(t) | ||
} | ||
|
||
public protocol ProtocolWithAssocType { | ||
associatedtype SomeType | ||
func get() -> SomeType | ||
} | ||
|
||
public class BestClass: ProtocolWithAssocType { | ||
public typealias SomeType = BestStruct | ||
public func get() -> SomeType { return BestStruct() } | ||
} | ||
|
||
public struct BestStruct { let c = BestClass() } | ||
|
||
public enum BestEnum<T> { | ||
case nothing | ||
case something(T) | ||
} | ||
|
||
public func caller(_ c: BestClass, _ s: BestStruct, _ e: BestEnum<BestStruct>) { | ||
forceGenericSubst(c) | ||
forceGenericSubst(s) | ||
forceGenericSubst(e) | ||
} | ||
|
||
public typealias TheTop = (Int, String) | ||
|
||
public struct S<T> { | ||
let t: T | ||
init(_ t: T) { self.t = t } | ||
} | ||
|
||
public typealias Handler = () -> () | ||
|
||
public func genericFn<T>(_ t: T) -> S<T> { | ||
return S(t) | ||
} | ||
|
||
public func maker(_ top: TheTop, withCompletion comp: @escaping Handler) -> S<TheTop> { | ||
_ = genericFn(top) | ||
_ = genericFn(comp) | ||
return S(top) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,30 @@ | ||
// RUN: %target-typecheck-verify-swift -enable-experimental-move-only | ||
|
||
protocol P: _Copyable {} | ||
protocol P: _Copyable {} // expected-error {{'_Copyable' is unavailable}} | ||
struct S: P {} | ||
|
||
class C: _Copyable {} | ||
typealias PleaseLetMeDoIt = _Copyable // expected-error {{'_Copyable' is unavailable}} | ||
typealias WhatIfIQualify = Swift._Copyable // expected-error {{'_Copyable' is unavailable}} | ||
|
||
@_moveOnly struct MOStruct: _Copyable {} // expected-error {{move-only struct 'MOStruct' cannot conform to '_Copyable'}} | ||
class C: _Copyable {} // expected-error {{'_Copyable' is unavailable}} | ||
|
||
@_moveOnly struct MOStruct: _Copyable {} | ||
// expected-error@-1 {{move-only struct 'MOStruct' cannot conform to '_Copyable'}} | ||
// expected-error@-2 {{'_Copyable' is unavailable}} | ||
|
||
|
||
func whatever<T>(_ t: T) where T: _Copyable {} // expected-error {{'_Copyable' is unavailable}} | ||
func vatever<T: _Copyable>(_ t: T) {} // expected-error {{'_Copyable' is unavailable}} | ||
func buttever(_ t: any _Copyable) {} // expected-error {{'_Copyable' is unavailable}} | ||
func zuttever(_ t: some _Copyable) {} // expected-error 2{{'_Copyable' is unavailable}} | ||
|
||
enum RockNRoll<T: _Copyable> { // expected-error {{'_Copyable' is unavailable}} | ||
case isNoisePollution(_Copyable) // expected-error {{'_Copyable' is unavailable}} | ||
case isMusic(T) | ||
} | ||
|
||
enum namespace { | ||
typealias _Copyable = Int | ||
|
||
func _Copyable() -> _Copyable { return 0 } | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
|
||
// >> First verify that when building the stdlib, we do have the copyable constraint. Note the module-name!! | ||
// RUN: %target-swift-frontend -enable-experimental-move-only -typecheck -verify -parse-stdlib -module-name Swift %s | ||
|
||
// FIXME: Now demonstrate that plain -parse-stdlib, such as in some arbitrary test, doesn't get the Copyable constraint :( | ||
// RUN: not %target-swift-frontend -enable-experimental-move-only -typecheck -verify -parse-stdlib %s | ||
|
||
@_marker public protocol _Copyable {} | ||
|
||
func nextTime<T>(_ t: T) {} | ||
|
||
@_moveOnly struct MO {} | ||
|
||
nextTime(MO()) // expected-error {{move-only type 'MO' cannot be used with generics yet}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.