From 0be9654d5a48dcb0100284c667feb703934499e3 Mon Sep 17 00:00:00 2001 From: Olivier Halligon Date: Sat, 21 Jul 2018 19:59:48 +0200 Subject: [PATCH] =?UTF-8?q?Fix=20#92=20=E2=80=94=20Add=20hints=20for=20the?= =?UTF-8?q?=20compiler=20to=20avoid=20type-checker=20timeout?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 3 ++ Sources/SwiftIdentifier.swift | 69 +++++++++++++++++++++++++++-------- 2 files changed, 56 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 247287cd..5b82266c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,9 @@ * Fixed using filter expression in call node. [Ilya Puchka](https://github.com/ilyapuchka) [#85](https://github.com/SwiftGen/StencilSwiftKit/pull/85) +* Fixed compilation issue with Xcode 10 & Swift 4.2 by adding hints to help the compiler. + [Olivier Halligon](https://github.com/AliSoftware) + [#93](https://github.com/SwiftGen/StencilSwiftKit/pull/93) ### Breaking Changes diff --git a/Sources/SwiftIdentifier.swift b/Sources/SwiftIdentifier.swift index 66f8ce01..f1b78268 100644 --- a/Sources/SwiftIdentifier.swift +++ b/Sources/SwiftIdentifier.swift @@ -6,34 +6,71 @@ import Foundation -private func mr(_ char: Int) -> CountableClosedRange { +typealias CharRange = CountableClosedRange + +private func mr(_ char: Int) -> CharRange { return char...char } // Official list of valid identifier characters // swiftlint:disable:next line_length // from: https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/LexicalStructure.html#//apple_ref/doc/uid/TP40014097-CH30-ID410 -private let headRanges: [CountableClosedRange] = [ - 0x61...0x7a, 0x41...0x5a, mr(0x5f), mr(0xa8), mr(0xaa), mr(0xad), mr(0xaf), - 0xb2...0xb5, 0xb7...0xba, 0xbc...0xbe, 0xc0...0xd6, 0xd8...0xf6, 0xf8...0xff, - 0x100...0x2ff, 0x370...0x167f, 0x1681...0x180d, 0x180f...0x1dbf, - 0x1e00...0x1fff, 0x200b...0x200d, 0x202a...0x202e, mr(0x203F), mr(0x2040), - mr(0x2054), 0x2060...0x206f, 0x2070...0x20cf, 0x2100...0x218f, 0x2460...0x24ff, - 0x2776...0x2793, 0x2c00...0x2dff, 0x2e80...0x2fff, 0x3004...0x3007, - 0x3021...0x302f, 0x3031...0x303f, 0x3040...0xd7ff, 0xf900...0xfd3d, - 0xfd40...0xfdcf, 0xfdf0...0xfe1f, 0xfe30...0xfe44, 0xfe47...0xfffd, - 0x10000...0x1fffd, 0x20000...0x2fffd, 0x30000...0x3fffd, 0x40000...0x4fffd, - 0x50000...0x5fffd, 0x60000...0x6fffd, 0x70000...0x7fffd, 0x80000...0x8fffd, - 0x90000...0x9fffd, 0xa0000...0xafffd, 0xb0000...0xbfffd, 0xc0000...0xcfffd, - 0xd0000...0xdfffd, 0xe0000...0xefffd +private let headRanges: [CharRange] = [ + 0x61...0x7a as CharRange, + 0x41...0x5a as CharRange, + mr(0x5f), mr(0xa8), mr(0xaa), mr(0xad), mr(0xaf), + 0xb2...0xb5 as CharRange, + 0xb7...0xba as CharRange, + 0xbc...0xbe as CharRange, + 0xc0...0xd6 as CharRange, + 0xd8...0xf6 as CharRange, + 0xf8...0xff as CharRange, + 0x100...0x2ff as CharRange, + 0x370...0x167f as CharRange, + 0x1681...0x180d as CharRange, + 0x180f...0x1dbf as CharRange, + 0x1e00...0x1fff as CharRange, + 0x200b...0x200d as CharRange, + 0x202a...0x202e as CharRange, + mr(0x203F), mr(0x2040), mr(0x2054), + 0x2060...0x206f as CharRange, + 0x2070...0x20cf as CharRange, + 0x2100...0x218f as CharRange, + 0x2460...0x24ff as CharRange, + 0x2776...0x2793 as CharRange, + 0x2c00...0x2dff as CharRange, + 0x2e80...0x2fff as CharRange, + 0x3004...0x3007 as CharRange, + 0x3021...0x302f as CharRange, + 0x3031...0x303f as CharRange, + 0x3040...0xd7ff as CharRange, + 0xf900...0xfd3d as CharRange, + 0xfd40...0xfdcf as CharRange, + 0xfdf0...0xfe1f as CharRange, + 0xfe30...0xfe44 as CharRange, + 0xfe47...0xfffd as CharRange, + 0x10000...0x1fffd as CharRange, + 0x20000...0x2fffd as CharRange, + 0x30000...0x3fffd as CharRange, + 0x40000...0x4fffd as CharRange, + 0x50000...0x5fffd as CharRange, + 0x60000...0x6fffd as CharRange, + 0x70000...0x7fffd as CharRange, + 0x80000...0x8fffd as CharRange, + 0x90000...0x9fffd as CharRange, + 0xa0000...0xafffd as CharRange, + 0xb0000...0xbfffd as CharRange, + 0xc0000...0xcfffd as CharRange, + 0xd0000...0xdfffd as CharRange, + 0xe0000...0xefffd as CharRange ] -private let tailRanges: [CountableClosedRange] = [ +private let tailRanges: [CharRange] = [ 0x30...0x39, 0x300...0x36F, 0x1dc0...0x1dff, 0x20d0...0x20ff, 0xfe20...0xfe2f ] private func identifierCharacterSets(exceptions: String) -> (head: NSMutableCharacterSet, tail: NSMutableCharacterSet) { - let addRange: (NSMutableCharacterSet, CountableClosedRange) -> Void = { mcs, range in + let addRange: (NSMutableCharacterSet, CharRange) -> Void = { mcs, range in mcs.addCharacters(in: NSRange(location: range.lowerBound, length: range.count)) }