From e327e4a13e333e4fab9b48eedb05c7cd73322589 Mon Sep 17 00:00:00 2001 From: Ewan Mellor Date: Wed, 7 Nov 2018 13:29:31 -0800 Subject: [PATCH] Change uses of functions deprecated in Swift 4.2. This is three instances of flatMap changing to compactMap, and one instance of UnsafeMutablePointer.deallocate(capacity:) changing to UnsafeMutablePointer.deallocate(). --- runtime/Swift/Sources/Antlr4/ParserRuleContext.swift | 4 ++-- runtime/Swift/Sources/Antlr4/atn/SemanticContext.swift | 2 +- .../Swift/Sources/Antlr4/misc/extension/UUIDExtension.swift | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/runtime/Swift/Sources/Antlr4/ParserRuleContext.swift b/runtime/Swift/Sources/Antlr4/ParserRuleContext.swift index d1f8d2200..82e546be0 100644 --- a/runtime/Swift/Sources/Antlr4/ParserRuleContext.swift +++ b/runtime/Swift/Sources/Antlr4/ParserRuleContext.swift @@ -202,7 +202,7 @@ open class ParserRuleContext: RuleContext { return [TerminalNode]() } - return children.flatMap { + return children.compactMap { if let tnode = $0 as? TerminalNode, let symbol = tnode.getSymbol(), symbol.getType() == ttype { return tnode } @@ -220,7 +220,7 @@ open class ParserRuleContext: RuleContext { guard let children = children else { return [T]() } - return children.flatMap { $0 as? T } + return children.compactMap { $0 as? T } } override diff --git a/runtime/Swift/Sources/Antlr4/atn/SemanticContext.swift b/runtime/Swift/Sources/Antlr4/atn/SemanticContext.swift index bf9be2924..118f549f5 100644 --- a/runtime/Swift/Sources/Antlr4/atn/SemanticContext.swift +++ b/runtime/Swift/Sources/Antlr4/atn/SemanticContext.swift @@ -427,7 +427,7 @@ public class SemanticContext: Hashable, CustomStringConvertible { } private static func filterPrecedencePredicates(_ collection: inout Set) -> [PrecedencePredicate] { - let result = collection.flatMap { + let result = collection.compactMap { $0 as? PrecedencePredicate } collection = Set(collection.filter { diff --git a/runtime/Swift/Sources/Antlr4/misc/extension/UUIDExtension.swift b/runtime/Swift/Sources/Antlr4/misc/extension/UUIDExtension.swift index 75bbf581c..d2951c35c 100644 --- a/runtime/Swift/Sources/Antlr4/misc/extension/UUIDExtension.swift +++ b/runtime/Swift/Sources/Antlr4/misc/extension/UUIDExtension.swift @@ -11,7 +11,7 @@ extension UUID { public init(mostSigBits: Int64, leastSigBits: Int64) { let bytes = UnsafeMutablePointer.allocate(capacity: 16) defer { - bytes.deallocate(capacity: 16) + bytes.deallocate() } bytes.withMemoryRebound(to: Int64.self, capacity: 2) { $0.pointee = leastSigBits