Skip to content

Commit

Permalink
Merge pull request #37 from Kuniwak/issue-36
Browse files Browse the repository at this point in the history
Use temporary vaiables to avoid type inference problem on Swift 4.0.x
  • Loading branch information
Kuniwak authored Jun 1, 2018
2 parents 9d85851 + ecc3fc6 commit d3f87e0
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions Sources/Diffable+PrettyPrintable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,11 @@ extension Diffable: PrettyPrintable {
let head: PrettyLine = .line("struct \(type) {")
let tail: PrettyLine = .line("}")

return [head] + childLines(by: entries) + [tail]
// XXX: This temporary variable is necessary for Swift 4.0.x.
// Type inference could be failed if the temporary variable is nothing.
let body: [PrettyLine] = childLines(by: entries)

return [head] + body + [tail]

case let .anyClass(type: type, entries: entries):
if entries.isEmpty {
Expand All @@ -219,7 +223,11 @@ extension Diffable: PrettyPrintable {
let head: PrettyLine = .line("class \(type) {")
let tail: PrettyLine = .line("}")

return [head] + childLines(by: entries) + [tail]
// XXX: This temporary variable is necessary for Swift 4.0.x.
// Type inference could be failed if the temporary variable is nothing.
let body: [PrettyLine] = childLines(by: entries)

return [head] + body + [tail]

case let .minorCustomReflectable(type: type, content: content):
switch content {
Expand All @@ -239,7 +247,11 @@ extension Diffable: PrettyPrintable {
let head: PrettyLine = .line("(unknown) \(type): CustomReflectable {")
let tail: PrettyLine = .line("}")

return [head] + childLines(by: entries) + [tail]
// XXX: This temporary variable is necessary for Swift 4.0.x.
// Type inference could be failed if the temporary variable is nothing.
let body: [PrettyLine] = childLines(by: entries)

return [head] + body + [tail]
}

case let .unrecognizable(debugInfo):
Expand Down

0 comments on commit d3f87e0

Please sign in to comment.