Skip to content

[stdlib] Suppress noisy warnings #4538

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
Aug 29, 2016
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
2 changes: 1 addition & 1 deletion docs/Literals.rst
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,6 @@ literal type is always Dictionary.

String interpolations are a bit different: they try to individually convert
each element of the interpolation to the type that adopts
ExpressibleByStringInterpolation, then calls the variadic
_ExpressibleByStringInterpolation, then calls the variadic
``convertFromStringInterpolation`` to put them all together. The default type
for an interpolated literal without context is also ``StringLiteralType``.
4 changes: 2 additions & 2 deletions include/swift/AST/DiagnosticsSema.def
Original file line number Diff line number Diff line change
Expand Up @@ -2107,10 +2107,10 @@ ERROR(optional_used_as_boolean,none,
"test for '!= nil' instead", (Type))

ERROR(interpolation_missing_proto,none,
"string interpolation requires the protocol 'ExpressibleByStringInterpolation' to be defined",
"string interpolation requires the protocol '_ExpressibleByStringInterpolation' to be defined",
())
ERROR(interpolation_broken_proto,none,
"protocol 'ExpressibleByStringInterpolation' is broken",
"protocol '_ExpressibleByStringInterpolation' is broken",
())

ERROR(object_literal_broken_proto,none,
Expand Down
2 changes: 1 addition & 1 deletion include/swift/AST/KnownProtocols.def
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ EXPRESSIBLE_BY_LITERAL_PROTOCOL(ExpressibleByDictionaryLiteral)
EXPRESSIBLE_BY_LITERAL_PROTOCOL(ExpressibleByExtendedGraphemeClusterLiteral)
EXPRESSIBLE_BY_LITERAL_PROTOCOL(ExpressibleByFloatLiteral)
EXPRESSIBLE_BY_LITERAL_PROTOCOL(ExpressibleByIntegerLiteral)
EXPRESSIBLE_BY_LITERAL_PROTOCOL(ExpressibleByStringInterpolation)
EXPRESSIBLE_BY_LITERAL_PROTOCOL_(ExpressibleByStringInterpolation)
EXPRESSIBLE_BY_LITERAL_PROTOCOL(ExpressibleByStringLiteral)
EXPRESSIBLE_BY_LITERAL_PROTOCOL(ExpressibleByNilLiteral)
EXPRESSIBLE_BY_LITERAL_PROTOCOL(ExpressibleByUnicodeScalarLiteral)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ public struct CollectionMisuseResiliencyChecks {
}

% for inc, protocol, direction, end in (
% ('inc', 'Indexable', 'after', 'end'),
% ('dec', 'BidirectionalIndexable', 'before', 'start')):
% ('inc', '_Indexable', 'after', 'end'),
% ('dec', '_BidirectionalIndexable', 'before', 'start')):

/// Test that the elements of `instances` satisfy
/// ${'some of ' if inc == 'dec' else ''}the semantic
Expand Down Expand Up @@ -91,7 +91,7 @@ internal func _checkIncrementalAdvance<Instances, BaseCollection>(
${TRACE}
) where
Instances : Collection,
BaseCollection : Indexable,
BaseCollection : _Indexable,
Instances.Iterator.Element == BaseCollection.Index,
// FIXME(compiler limitation): these constraints should be applied to
// associated types of Collection.
Expand Down Expand Up @@ -128,7 +128,7 @@ public func checkForwardIndex<Instances, BaseCollection>(
endIndex: Instances.Iterator.Element, ${TRACE}
) where
Instances : Collection,
BaseCollection : Indexable,
BaseCollection : _Indexable,
Instances.Iterator.Element == BaseCollection.Index,
// FIXME(compiler limitation): these constraints should be applied to
// associated types of Collection.
Expand Down Expand Up @@ -158,7 +158,7 @@ public func checkBidirectionalIndex<Instances, BaseCollection>(
${TRACE}
) where
Instances: Collection,
BaseCollection : BidirectionalIndexable,
BaseCollection : _BidirectionalIndexable,
Instances.Iterator.Element == BaseCollection.Index,
// FIXME(compiler limitation): these constraints should be applied to
// associated types of Collection.
Expand Down Expand Up @@ -197,7 +197,7 @@ public func checkRandomAccessIndex<Instances, Distances, BaseCollection>(
) where
Instances : Collection,
Distances : Collection,
BaseCollection : RandomAccessIndexable,
BaseCollection : _RandomAccessIndexable,
Instances.Iterator.Element == BaseCollection.Index,
Distances.Iterator.Element == BaseCollection.IndexDistance,
// FIXME(compiler limitation): these constraints should be applied to
Expand Down Expand Up @@ -230,7 +230,7 @@ public func checkAdvancesAndDistances<Instances, Distances, BaseCollection>(
) where
Instances : Collection,
Distances : Collection,
BaseCollection : Indexable,
BaseCollection : _Indexable,
Instances.Iterator.Element == BaseCollection.Index,
Distances.Iterator.Element == BaseCollection.IndexDistance,
// FIXME(compiler limitation): these constraints should be applied to
Expand Down
4 changes: 2 additions & 2 deletions stdlib/public/SDK/Foundation/Data.swift
Original file line number Diff line number Diff line change
Expand Up @@ -735,10 +735,10 @@ extension Data : CustomStringConvertible, CustomDebugStringConvertible, CustomRe

extension Data {
@available(*, unavailable, renamed: "copyBytes(to:count:)")
public func getBytes(_ buffer: UnsafeMutablePointer<Swift.Void>, length: Int) { }
public func getBytes<UnsafeMutablePointerVoid: _Pointer>(_ buffer: UnsafeMutablePointerVoid, length: Int) { }

@available(*, unavailable, renamed: "copyBytes(to:from:)")
public func getBytes(_ buffer: UnsafeMutablePointer<Swift.Void>, range: NSRange) { }
public func getBytes<UnsafeMutablePointerVoid: _Pointer>(_ buffer: UnsafeMutablePointerVoid, range: NSRange) { }
}

/// Provides bridging functionality for struct Data to class NSData and vice-versa.
Expand Down
30 changes: 25 additions & 5 deletions stdlib/public/core/BidirectionalCollection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
/// `BidirectionalCollection` protocol instead, because it has a more complete
/// interface.
@available(*, deprecated, message: "it will be removed in Swift 4.0. Please use 'BidirectionalCollection' instead")
public protocol BidirectionalIndexable : Indexable {
public typealias BidirectionalIndexable = _BidirectionalIndexable
public protocol _BidirectionalIndexable : _Indexable {
// FIXME(ABI)(compiler limitation): there is no reason for this protocol
// to exist apart from missing compiler features that we emulate with it.
// rdar://problem/20531108
Expand Down Expand Up @@ -65,7 +66,7 @@ public protocol BidirectionalIndexable : Indexable {
/// - If `i > c.startIndex && i <= c.endIndex`
/// `c.index(after: c.index(before: i)) == i`.
public protocol BidirectionalCollection
: BidirectionalIndexable, Collection {
: _BidirectionalIndexable, Collection {

// TODO: swift-3-indexing-model - replaces functionality in BidirectionalIndex
/// Returns the position immediately before the given index.
Expand All @@ -83,18 +84,37 @@ public protocol BidirectionalCollection

/// A sequence that can represent a contiguous subrange of the collection's
/// elements.
associatedtype SubSequence : BidirectionalIndexable, Collection
associatedtype SubSequence : _BidirectionalIndexable, Collection
= BidirectionalSlice<Self>
// FIXME(compiler limitation):
// associatedtype SubSequence : BidirectionalCollection

/// A type that can represent the indices that are valid for subscripting the
/// collection, in ascending order.
associatedtype Indices : BidirectionalIndexable, Collection
associatedtype Indices : _BidirectionalIndexable, Collection
= DefaultBidirectionalIndices<Self>
// FIXME(compiler limitation):
// associatedtype Indices : BidirectionalCollection

/// The indices that are valid for subscripting the collection, in ascending
/// order.
///
/// A collection's `indices` property can hold a strong reference to the
/// collection itself, causing the collection to be non-uniquely referenced.
/// If you mutate the collection while iterating over its indices, a strong
/// reference can cause an unexpected copy of the collection. To avoid the
/// unexpected copy, use the `index(after:)` method starting with
/// `startIndex` to produce indices instead.
///
/// var c = MyFancyCollection([10, 20, 30, 40, 50])
/// var i = c.startIndex
/// while i != c.endIndex {
/// c[i] /= 5
/// i = c.index(after: i)
/// }
/// // c == MyFancyCollection([2, 4, 6, 8, 10])
var indices: Indices { get }

// TODO: swift-3-indexing-model: tests.
/// The last element of the collection.
///
Expand All @@ -111,7 +131,7 @@ public protocol BidirectionalCollection
}

/// Default implementation for bidirectional collections.
extension BidirectionalIndexable {
extension _BidirectionalIndexable {

@inline(__always)
public func formIndex(before i: inout Index) {
Expand Down
4 changes: 2 additions & 2 deletions stdlib/public/core/Builtin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,12 @@ internal func _isClassOrObjCExistential<T>(_ x: T.Type) -> Bool {
/// not much you can do with this other than use it to identify the
/// object.
@available(*, unavailable, message: "Removed in Swift 3. Use Unmanaged.passUnretained(x).toOpaque() instead.")
public func unsafeAddress(of object: AnyObject) -> UnsafePointer<Void> {
public func unsafeAddress(of object: AnyObject) -> UnsafeRawPointer {
Builtin.unreachable()
}

@available(*, unavailable, message: "Removed in Swift 3. Use Unmanaged.passUnretained(x).toOpaque() instead.")
public func unsafeAddressOf(_ object: AnyObject) -> UnsafePointer<Void> {
public func unsafeAddressOf(_ object: AnyObject) -> UnsafeRawPointer {
Builtin.unreachable()
}

Expand Down
18 changes: 10 additions & 8 deletions stdlib/public/core/Collection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
/// In most cases, it's best to ignore this protocol and use the `Collection`
/// protocol instead, because it has a more complete interface.
@available(*, deprecated, message: "it will be removed in Swift 4.0. Please use 'Collection' instead")
public protocol IndexableBase {
public typealias IndexableBase = _IndexableBase
public protocol _IndexableBase {
// FIXME(ABI)(compiler limitation): there is no reason for this protocol
// to exist apart from missing compiler features that we emulate with it.
// rdar://problem/20531108
Expand Down Expand Up @@ -159,7 +160,8 @@ public protocol IndexableBase {
/// In most cases, it's best to ignore this protocol and use the `Collection`
/// protocol instead, because it has a more complete interface.
@available(*, deprecated, message: "it will be removed in Swift 4.0. Please use 'Collection' instead")
public protocol Indexable : IndexableBase {
public typealias Indexable = _Indexable
public protocol _Indexable : _IndexableBase {
/// A type used to represent the number of steps between two indices, where
/// one value is reachable from the other.
///
Expand Down Expand Up @@ -354,7 +356,7 @@ public protocol Indexable : IndexableBase {
/// // Prints "15.0"
/// // Prints "20.0"
public struct IndexingIterator<
Elements : IndexableBase
Elements : _IndexableBase
// FIXME(compiler limitation):
// Elements : Collection
> : IteratorProtocol, Sequence {
Expand Down Expand Up @@ -530,7 +532,7 @@ public struct IndexingIterator<
/// forward or bidirectional collection must traverse the entire collection to
/// count the number of contained elements, accessing its `count` property is
/// an O(*n*) operation.
public protocol Collection : Indexable, Sequence {
public protocol Collection : _Indexable, Sequence {
/// A type that can represent the number of steps between a pair of
/// indices.
associatedtype IndexDistance : SignedInteger = Int
Expand All @@ -555,7 +557,7 @@ public protocol Collection : Indexable, Sequence {
/// This associated type appears as a requirement in the `Sequence`
/// protocol, but it is restated here with stricter constraints. In a
/// collection, the subsequence should also conform to `Collection`.
associatedtype SubSequence : IndexableBase, Sequence = Slice<Self>
associatedtype SubSequence : _IndexableBase, Sequence = Slice<Self>
// FIXME(compiler limitation):
// associatedtype SubSequence : Collection
// where
Expand Down Expand Up @@ -614,7 +616,7 @@ public protocol Collection : Indexable, Sequence {

/// A type that can represent the indices that are valid for subscripting the
/// collection, in ascending order.
associatedtype Indices : IndexableBase, Sequence = DefaultIndices<Self>
associatedtype Indices : _Indexable, Sequence = DefaultIndices<Self>

// FIXME(compiler limitation):
// associatedtype Indices : Collection
Expand Down Expand Up @@ -859,7 +861,7 @@ public protocol Collection : Indexable, Sequence {
}

/// Default implementation for forward collections.
extension Indexable {
extension _Indexable {
/// Replaces the given index with its successor.
///
/// - Parameter i: A valid index of the collection. `i` must be less than
Expand Down Expand Up @@ -1702,7 +1704,7 @@ extension Collection {
public enum Bit {}

@available(*, unavailable, renamed: "IndexingIterator")
public struct IndexingGenerator<Elements : IndexableBase> {}
public struct IndexingGenerator<Elements : _IndexableBase> {}

@available(*, unavailable, renamed: "Collection")
public typealias CollectionType = Collection
Expand Down
2 changes: 1 addition & 1 deletion stdlib/public/core/CollectionAlgorithms.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ ${orderingExplanation}
}
}

% for Self in 'Indexable', 'MutableIndexable':
% for Self in '_Indexable', '_MutableIndexable':
%{

subscriptCommentPre = """\
Expand Down
3 changes: 2 additions & 1 deletion stdlib/public/core/CompilerProtocols.swift
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,8 @@ public protocol ExpressibleByDictionaryLiteral {
/// String(stringInterpolationSegment: price * number),
/// String(stringInterpolationSegment: "."))
@available(*, deprecated, message: "it will be replaced or redesigned in Swift 4.0. Instead of conforming to 'ExpressibleByStringInterpolation', consider adding an 'init(_:String)'")
public protocol ExpressibleByStringInterpolation {
public typealias ExpressibleByStringInterpolation = _ExpressibleByStringInterpolation
public protocol _ExpressibleByStringInterpolation {
/// Creates an instance by concatenating the given values.
///
/// Do not call this initializer directly. It is used by the compiler when
Expand Down
3 changes: 3 additions & 0 deletions stdlib/public/core/ExistentialCollection.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,9 @@ protocol _AnyCollectionProtocol : Collection {
public struct ${Self}<Element>
: _AnyCollectionProtocol, ${SelfProtocol} {

// public typealias Indices
// = Default${Traversal.replace('Forward', '')}Indices<${Self}>

internal init(_box: _${Self}Box<Element>) {
self._box = _box
}
Expand Down
2 changes: 1 addition & 1 deletion stdlib/public/core/HashedCollections.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -2211,7 +2211,7 @@ public func _dictionaryUpCast<DerivedKey, DerivedValue, BaseKey, BaseValue>(
var result = Dictionary<BaseKey, BaseValue>(minimumCapacity: source.count)

for (k, v) in source {
result[k as! BaseKey] = v as! BaseValue
result[k as! BaseKey] = (v as! BaseValue)
}
return result
}
Expand Down
2 changes: 1 addition & 1 deletion stdlib/public/core/Indices.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ from gyb_stdlib_support import (

/// A collection of indices for an arbitrary ${collection}.
public struct ${Self}<
Elements : ${collectionForTraversal(Traversal).replace('Collection', 'Indexable')}
Elements : _${collectionForTraversal(Traversal).replace('Collection', 'Indexable')}
// FIXME(ABI)(compiler limitation):
// Elements : Collection
// rdar://problem/20531108
Expand Down
5 changes: 3 additions & 2 deletions stdlib/public/core/MutableCollection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
/// `MutableCollection` protocol instead, because it has a more complete
/// interface.
@available(*, deprecated, message: "it will be removed in Swift 4.0. Please use 'MutableCollection' instead")
public protocol MutableIndexable : Indexable {
public typealias MutableIndexable = _MutableIndexable
public protocol _MutableIndexable : _Indexable {
// FIXME(ABI)(compiler limitation): there is no reason for this protocol
// to exist apart from missing compiler features that we emulate with it.
// rdar://problem/20531108
Expand Down Expand Up @@ -216,7 +217,7 @@ public protocol MutableIndexable : Indexable {
/// // Must be equivalent to:
/// a[i] = x
/// let y = x
public protocol MutableCollection : MutableIndexable, Collection {
public protocol MutableCollection : _MutableIndexable, Collection {
// FIXME: should be constrained to MutableCollection
// (<rdar://problem/20715009> Implement recursive protocol
// constraints)
Expand Down
30 changes: 25 additions & 5 deletions stdlib/public/core/RandomAccessCollection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
/// `RandomAccessCollection` protocol instead, because it has a more complete
/// interface.
@available(*, deprecated, message: "it will be removed in Swift 4.0. Please use 'RandomAccessCollection' instead")
public protocol RandomAccessIndexable : BidirectionalIndexable {
public typealias RandomAccessIndexable = _RandomAccessIndexable
public protocol _RandomAccessIndexable : _BidirectionalIndexable {
// FIXME(ABI)(compiler limitation): there is no reason for this protocol
// to exist apart from missing compiler features that we emulate with it.
// rdar://problem/20531108
Expand Down Expand Up @@ -46,21 +47,40 @@ public protocol RandomAccessIndexable : BidirectionalIndexable {
/// `Strideable` protocol or you must implement the `index(_:offsetBy:)` and
/// `distance(from:to:)` methods with O(1) efficiency.
public protocol RandomAccessCollection :
RandomAccessIndexable, BidirectionalCollection
_RandomAccessIndexable, BidirectionalCollection
{
/// A collection that represents a contiguous subrange of the collection's
/// elements.
associatedtype SubSequence : RandomAccessIndexable, BidirectionalCollection
associatedtype SubSequence : _RandomAccessIndexable, BidirectionalCollection
= RandomAccessSlice<Self>
// FIXME(compiler limitation):
// associatedtype SubSequence : RandomAccessCollection

/// A type that can represent the indices that are valid for subscripting the
/// collection, in ascending order.
associatedtype Indices : RandomAccessIndexable, BidirectionalCollection
associatedtype Indices : _RandomAccessIndexable, BidirectionalCollection
= DefaultRandomAccessIndices<Self>
// FIXME(compiler limitation):
// associatedtype Indices : RandomAccessCollection

/// The indices that are valid for subscripting the collection, in ascending
/// order.
///
/// A collection's `indices` property can hold a strong reference to the
/// collection itself, causing the collection to be non-uniquely referenced.
/// If you mutate the collection while iterating over its indices, a strong
/// reference can cause an unexpected copy of the collection. To avoid the
/// unexpected copy, use the `index(after:)` method starting with
/// `startIndex` to produce indices instead.
///
/// var c = MyFancyCollection([10, 20, 30, 40, 50])
/// var i = c.startIndex
/// while i != c.endIndex {
/// c[i] /= 5
/// i = c.index(after: i)
/// }
/// // c == MyFancyCollection([2, 4, 6, 8, 10])
var indices: Indices { get }
}

/// Supply the default "slicing" `subscript` for `RandomAccessCollection`
Expand Down Expand Up @@ -103,7 +123,7 @@ extension RandomAccessCollection where SubSequence == RandomAccessSlice<Self> {
// wrong complexity.

/// Default implementation for random access collections.
extension RandomAccessIndexable {
extension _RandomAccessIndexable {
/// Returns an index that is the specified distance from the given index,
/// unless that distance is beyond a given limiting index.
///
Expand Down
Loading