Files
swift-mirror/validation-test/compiler_crashers_fixed/0030-string-as-extensibe-collection.script.swift
Dave Abrahams 4ce1891cae [stdlib] String is no longer a SequenceType
<rdar://20494686>

String itsef should only expose Unicode-correct algorithms, like proper
substring/prefix/suffix search, enumerating words/lines/paragraphs, case
folding etc. Promoting sequence-centric algorithms to methods on String
is not acceptable since it invites users to write wrong code. Thus,
String has to lose its SequenceType conformance.

Nevertheless, we recognize that sometimes it is useful to manipulate the
String contents on lower levels (UTF-8, UTF-16, Unicode scalars,
extended grapheme clusters), for example, when implementing high-level
Unicode operations, so we can't remove low-level operations
altogether. For this reason, String provides nested "views" for the
first three low-level representations, but grapheme clusters were in a
privileged position -- String itself is a collection of grapheme
clusters. We propose to add a characters view that will represent the
String as a collection of Character values.

Swift SVN r28065
2015-05-02 01:52:02 +00:00

12 lines
251 B
Swift

// RUN: %target-swift-frontend %s -emit-ir
// Test case submitted to project by https://github.com/tmu (Teemu Kurppa)
extension String : ExtensibleCollectionType {}
func f<S : ExtensibleCollectionType>(seq: S) -> S {
return S() + seq
}
f("a")