Skip to content

Commit f68c14b

Browse files
committed
[TEST] enable the _Copyable constraint everywhere and see what breaks
1 parent 2db7da5 commit f68c14b

File tree

7 files changed

+15
-18
lines changed

7 files changed

+15
-18
lines changed

lib/Sema/ConstraintSystem.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1806,7 +1806,8 @@ TypeVariableType *ConstraintSystem::openGenericParameter(
18061806

18071807
// When move-only types are available, add a constraint to force generic
18081808
// parameters to conform to a "Copyable" protocol.
1809-
if (getASTContext().LangOpts.hasFeature(Feature::MoveOnly)) {
1809+
// if (getASTContext().LangOpts.hasFeature(Feature::MoveOnly)) {
1810+
if (true) {
18101811
ProtocolDecl *copyable = TypeChecker::getProtocol(
18111812
getASTContext(), SourceLoc(), KnownProtocolKind::Copyable);
18121813

test/Constraints/construction.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ acceptString("\(hello), \(world) #\(i)!")
5959
Optional<Int>(1) // expected-warning{{unused}}
6060
Optional(1) // expected-warning{{unused}}
6161
_ = .none as Optional<Int>
62-
Optional(.none) // expected-error {{cannot infer contextual base in reference to member 'none'}}
62+
Optional(.none) // expected-error {{type '_Copyable' has no member 'none'}}
6363

6464
// Interpolation
6565
_ = "\(hello), \(world) #\(i)!"

test/Constraints/generics.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,7 @@ func rdar79757320() {
933933
}
934934

935935
// FIXME: There has to be a way to propagate holes that makes it easy to suppress failures caused by missing members.
936-
_ = Container(value: Value(42).formatted(.S(a: .a, b: .b(0)))) // expected-error {{type 'R_79757320' has no member 'S'}}
936+
_ = Container(value: Value(42).formatted(.S(a: .a, b: .b(0)))) // expected-error {{reference to member 'S' cannot be resolved without a contextual type}}
937937
// expected-error@-1 {{cannot infer contextual base in reference to member 'a'}}
938938
// expected-error@-2 {{cannot infer contextual base in reference to member 'b'}}
939939
}

test/Constraints/members.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ func rdar66891544() {
737737
func foo<T>(_: T, defaultT: T? = nil) {}
738738
func foo<U>(_: U, defaultU: U? = nil) {}
739739

740-
foo(.bar) // expected-error {{cannot infer contextual base in reference to member 'bar'}}
740+
foo(.bar) // expected-error {{type '_Copyable' has no member 'bar'}}
741741
}
742742

743743
// rdar://55369704 - extraneous diagnostics produced in combination with missing/misspelled members

test/Constraints/rdar68155466.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import Foundation
99
}
1010
}
1111

12-
struct Loop< // expected-note {{required by generic struct 'Loop' where 'ID' = '() -> Int'}}
12+
struct Loop<
1313
Data : RandomAccessCollection,
1414
ID : Hashable,
1515
Content
@@ -24,5 +24,4 @@ func data() -> [A] {
2424
return []
2525
}
2626

27-
_ = Loop(data(), id: \.uniqueID) { $0 } // expected-error {{key path cannot refer to instance method 'uniqueID()'}}
28-
// expected-error@-1 {{type '() -> Int' cannot conform to 'Hashable'}} expected-note@-1 {{only concrete types such as structs, enums and classes can conform to protocols}}
27+
_ = Loop(data(), id: \.uniqueID) { $0 } // expected-error {{key path cannot refer to instance method 'uniqueID()'}}

test/Constraints/static_members_on_protocol_in_generic_context.swift

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -175,14 +175,14 @@ test_combo(.genericFn(42)) // expected-error {{global function 'test_combo' requ
175175

176176
/* Invalid result types */
177177

178-
extension P { // expected-note 13 {{missing same-type requirement on 'Self'}} {{12-12= where Self == <#Type#>}}
178+
extension P { // expected-note 12 {{missing same-type requirement on 'Self'}} {{12-12= where Self == <#Type#>}}
179179
static func generic<T>(_: T) -> T { fatalError() }
180180
static func genericWithReqs<T: Collection, Q>(_: T) -> Q where T.Element == Q { // expected-note {{in call to function 'genericWithReqs'}} expected-note {{required by static method 'genericWithReqs' where 'T' = '()'}}
181181
fatalError()
182182
}
183183
}
184184

185-
extension P { // expected-note 6 {{missing same-type requirement on 'Self'}}
185+
extension P { // expected-note 4 {{missing same-type requirement on 'Self'}}
186186
static var invalidProp: Int { 42 }
187187
static var selfProp: Self { fatalError() }
188188
static func invalidMethod() -> Int { 42 }
@@ -224,23 +224,20 @@ _ = P[q: ""].other
224224
// expected-error@-1 {{static member 'subscript' cannot be used on protocol metatype '(any P).Type'}}
225225
// expected-error@-2 {{value of type 'Int' has no member 'other'}}
226226

227-
test(.doesntExist) // expected-error {{type 'P' has no member 'doesntExist'}}
228-
test(.doesnt.exist()) // expected-error {{type 'P' has no member 'doesnt'}}
227+
test(.doesntExist) // expected-error {{reference to member 'doesntExist' cannot be resolved without a contextual type}}
228+
test(.doesnt.exist()) // expected-error {{reference to member 'doesnt' cannot be resolved without a contextual type}}
229229
test(.invalidProp)
230230
// expected-error@-1 {{contextual member reference to static property 'invalidProp' requires 'Self' constraint in the protocol extension}}
231231
test(.invalidProp.other)
232-
// expected-error@-1 {{contextual member reference to static property 'invalidProp' requires 'Self' constraint in the protocol extension}}
233-
// expected-error@-2 {{value of type 'Int' has no member 'other'}}
232+
// expected-error@-1 {{type '_Copyable' has no member 'invalidProp'}}
234233
test(.invalidMethod())
235234
// expected-error@-1 {{contextual member reference to static method 'invalidMethod()' requires 'Self' constraint in the protocol extension}}
236235
test(.invalidMethod().other)
237-
// expected-error@-1 {{contextual member reference to static method 'invalidMethod()' requires 'Self' constraint in the protocol extension}}
238-
// expected-error@-2 {{value of type 'Int' has no member 'other'}}
236+
// expected-error@-1 {{type '_Copyable' has no member 'invalidMethod'}}
239237
test(.generic(42))
240238
// expected-error@-1 {{contextual member reference to static method 'generic' requires 'Self' constraint in the protocol extension}}
241239
test(.generic(42).other)
242-
// expected-error@-1 {{contextual member reference to static method 'generic' requires 'Self' constraint in the protocol extension}}
243-
// expected-error@-2 {{value of type 'Int' has no member 'other'}}
240+
// expected-error@-1 {{type '_Copyable' has no member 'generic'}}
244241
test(.generic(S())) // expected-error {{contextual member reference to static method 'generic' requires 'Self' constraint in the protocol extension}}
245242
test(.generic(G<Int>())) // expected-error {{contextual member reference to static method 'generic' requires 'Self' constraint in the protocol extension}}
246243
test(.genericWithReqs([S()])) // expected-error {{contextual member reference to static method 'genericWithReqs' requires 'Self' constraint in the protocol extension}}

test/Sema/diag_ambiguous_overloads.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ struct S {
2929
func g<T>(_ a: T, _ b: Int) -> Void {}
3030
func g(_ a: String) -> Void {}
3131
func test2() -> Void {
32-
g(.notAThing, 7) // expected-error {{cannot infer contextual base in reference to member 'notAThing'}}
32+
g(.notAThing, 7) // expected-error {{type '_Copyable' has no member 'notAThing'}}
3333
}
3434

3535
func h(_ a: Int, _ b: Int) -> Void {}

0 commit comments

Comments
 (0)