Skip to content

Commit 385f4b2

Browse files
committed
Add correct(ish) example
1 parent 51b335f commit 385f4b2

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

test/NameLookup/module_selector.swift

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,40 @@ import struct ModuleSelectorTestingKit::A
1212

1313
let magnitude: Never = fatalError()
1414

15+
// Test correct code using `A`
16+
17+
extension ModuleSelectorTestingKit::A: @retroactive Swift::Equatable {
18+
@_implements(Swift::Equatable, ==(_:_:))
19+
public static func equals(_: ModuleSelectorTestingKit::A, _: ModuleSelectorTestingKit::A) -> Swift::Bool {
20+
Swift::fatalError()
21+
}
22+
23+
// FIXME: Add tests with autodiff @_differentiable(jvp:vjp:) and
24+
// @_derivative(of:)
25+
26+
@_dynamicReplacement(for: ModuleSelectorTestingKit::negate())
27+
mutating func myNegate() {
28+
let fn: (Swift::Int, Swift::Int) -> Swift::Int =
29+
(+)
30+
// FIXME: it'd be nice to handle module selectors on operators.
31+
32+
let magnitude: Int.Swift::Magnitude = main::magnitude
33+
// FIXME incorrect: expected-error@-1 {{variable used within its own initial value}}
34+
// expected-EVENTUALLY-error@-1 {{something about type mismatch between 'Never' and 'Int.Swift::Magnitude'}}
35+
36+
if Swift::Bool.Swift::random() {
37+
self.ModuleSelectorTestingKit::negate()
38+
}
39+
else {
40+
self = ModuleSelectorTestingKit::A(value: .Swift::min)
41+
}
42+
43+
self.main::myNegate()
44+
}
45+
46+
// FIXME: Can we test @convention(witness_method:)?
47+
}
48+
1549
// Test resolution of main:: using `B`
1650

1751
extension main::B {}

0 commit comments

Comments
 (0)