Skip to content

Commit 6a9732c

Browse files
committed
Revert "[TEST] enable the _Copyable constraint everywhere and see what breaks"
This reverts commit 3421da1cf1a2fa601c69b8f1ae6863f45c55298f.
1 parent d4a94f6 commit 6a9732c

File tree

7 files changed

+18
-15
lines changed

7 files changed

+18
-15
lines changed

lib/Sema/ConstraintSystem.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1806,8 +1806,7 @@ 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)) {
1810-
if (true) {
1809+
if (getASTContext().LangOpts.hasFeature(Feature::MoveOnly)) {
18111810
ProtocolDecl *copyable = TypeChecker::getProtocol(
18121811
getASTContext(), SourceLoc(), KnownProtocolKind::Copyable);
18131812

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 {{type '_Copyable' has no member 'none'}}
62+
Optional(.none) // expected-error {{cannot infer contextual base in reference to 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 {{reference to member 'S' cannot be resolved without a contextual type}}
936+
_ = Container(value: Value(42).formatted(.S(a: .a, b: .b(0)))) // expected-error {{type 'R_79757320' has no member 'S'}}
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 {{type '_Copyable' has no member 'bar'}}
740+
foo(.bar) // expected-error {{cannot infer contextual base in reference to member 'bar'}}
741741
}
742742

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

test/Constraints/rdar68155466.swift

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

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

27-
_ = Loop(data(), id: \.uniqueID) { $0 } // expected-error {{key path cannot refer to instance method 'uniqueID()'}}
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}}

test/Constraints/static_members_on_protocol_in_generic_context.swift

Lines changed: 10 additions & 7 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 12 {{missing same-type requirement on 'Self'}} {{12-12= where Self == <#Type#>}}
178+
extension P { // expected-note 13 {{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 4 {{missing same-type requirement on 'Self'}}
185+
extension P { // expected-note 6 {{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,20 +224,23 @@ _ = 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 {{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}}
227+
test(.doesntExist) // expected-error {{type 'P' has no member 'doesntExist'}}
228+
test(.doesnt.exist()) // expected-error {{type 'P' has no member 'doesnt'}}
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 {{type '_Copyable' has no member 'invalidProp'}}
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'}}
233234
test(.invalidMethod())
234235
// expected-error@-1 {{contextual member reference to static method 'invalidMethod()' requires 'Self' constraint in the protocol extension}}
235236
test(.invalidMethod().other)
236-
// expected-error@-1 {{type '_Copyable' has no member 'invalidMethod'}}
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'}}
237239
test(.generic(42))
238240
// expected-error@-1 {{contextual member reference to static method 'generic' requires 'Self' constraint in the protocol extension}}
239241
test(.generic(42).other)
240-
// expected-error@-1 {{type '_Copyable' has no member 'generic'}}
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'}}
241244
test(.generic(S())) // expected-error {{contextual member reference to static method 'generic' requires 'Self' constraint in the protocol extension}}
242245
test(.generic(G<Int>())) // expected-error {{contextual member reference to static method 'generic' requires 'Self' constraint in the protocol extension}}
243246
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 {{type '_Copyable' has no member 'notAThing'}}
32+
g(.notAThing, 7) // expected-error {{cannot infer contextual base in reference to member 'notAThing'}}
3333
}
3434

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

0 commit comments

Comments
 (0)