Skip to content

[stdlib] Add conditional Lazy conformance to Slice when Base is Lazy #13242

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions stdlib/public/core/LazyCollection.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,9 @@ extension ${TraversalCollection} where Self : LazyCollectionProtocol {

% end

extension Slice: LazySequenceProtocol where Base: LazySequenceProtocol { }
extension Slice: LazyCollectionProtocol where Base: LazyCollectionProtocol { }

// ${'Local Variables'}:
// eval: (read-only-mode 1)
// End:
18 changes: 18 additions & 0 deletions test/stdlib/LazySlice.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// RUN: rm -rf %t ; mkdir -p %t
// RUN: %target-build-swift %s -o %t/a.out3 -swift-version 3 && %target-run %t/a.out3
// REQUIRES: executable_test

import StdlibUnittest

var tests = TestSuite("LazySlice")

tests.test("CommuteLazyness") {
let a = [1,2,3].lazy
let b = a[...]
var c = b.filter { $0 == 0 }
// NOTE, this test will fail once lazy collectionness becomes a conditiona
// conformance, and will need updating to be a LazyBidirectional thingy
expectType(LazyFilterBidirectionalCollection<Slice<LazyRandomAccessCollection<[Int]>>>.self, &c)
}

runAllTests()