Skip to content

Commit 9b02d38

Browse files
committed
Add test to verify we dont allow overloading based on lifetime dependence
1 parent e5bf933 commit 9b02d38

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

test/Sema/explicit_lifetime_dependence_specifiers1.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@ struct BufferView : ~Escapable {
5656
consuming func consume() -> dependsOn(scoped self) BufferView { // expected-error{{invalid use of scoped lifetime dependence with consuming ownership}}
5757
return BufferView(self.ptr)
5858
}
59+
60+
func get() -> dependsOn(self) Self { // expected-note{{'get()' previously declared here}}
61+
return self
62+
}
63+
64+
func get() -> dependsOn(scoped self) Self { // expected-error{{invalid redeclaration of 'get()'}}
65+
return self
66+
}
5967
}
6068

6169
struct MutableBufferView : ~Escapable, ~Copyable {
@@ -202,3 +210,11 @@ public struct GenericBufferView<Element> : ~Escapable {
202210
self.count = count
203211
}
204212
}
213+
214+
func derive(_ x: BufferView) -> dependsOn(x) BufferView { // expected-note{{'derive' previously declared here}}
215+
return BufferView(x.ptr)
216+
}
217+
218+
func derive(_ x: BufferView) -> dependsOn(scoped x) BufferView { // expected-error{{invalid redeclaration of 'derive'}}
219+
return BufferView(x.ptr)
220+
}

0 commit comments

Comments
 (0)