Skip to content

Commit 9e5f6f4

Browse files
AnthonyLatsishborla
authored andcommitted
Add regression test to close swiftlang#43527
1 parent f9dad06 commit 9e5f6f4

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

test/Constraints/generics.swift

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -942,3 +942,26 @@ do {
942942
}
943943
}
944944
}
945+
946+
// https://github.com/apple/swift/issues/43527
947+
do {
948+
struct Box<Contents, U> {}
949+
950+
class Sweets {}
951+
class Chocolate {}
952+
953+
struct Gift<Contents> {
954+
// expected-note@-1 2 {{arguments to generic parameter 'Contents' ('Chocolate' and 'Sweets') are expected to be equal}}
955+
956+
init(_: Box<[Contents], Never>) {}
957+
}
958+
959+
let box = Box<[Chocolate], Never>()
960+
961+
var g1: Gift<Sweets>
962+
g1 = Gift<Chocolate>(box)
963+
// expected-error@-1 {{cannot assign value of type 'Gift<Chocolate>' to type 'Gift<Sweets>'}}
964+
965+
let g2: Gift<Sweets> = Gift<Chocolate>(box)
966+
// expected-error@-1 {{cannot assign value of type 'Gift<Chocolate>' to type 'Gift<Sweets>'}}
967+
}

0 commit comments

Comments
 (0)