[Swift] Suppress "Optional" in the output when printing a value.

Suppress "Optional" in the output when printing a value in the tests and
some debugging messages.

This is a change in behavior in Swift 4.2 (SE-0054) that implicitly
unwrapped optionals are now seen as plain Optional at runtime, and so
print doesn't implicitly unwrap them any more.
This commit is contained in:
Ewan Mellor 2018-11-08 20:04:24 -08:00
parent 938883d516
commit 75d4d867ef
No known key found for this signature in database
GPG Key ID: 7CE1C6BC9EC8645D
2 changed files with 6 additions and 6 deletions

View File

@ -1,6 +1,6 @@
writeln(s) ::= <<print(<s>)>>
writeln(s) ::= <<print((<s>) ?? "nil")>>
write(s) ::= <<print(<s>, terminator: "")>>
write(s) ::= <<print((<s>) ?? "nil", terminator: "")>>
False() ::= "false"

View File

@ -1754,7 +1754,7 @@ open class ParserATNSimulator: ATNSimulator {
}
if debug {
print("config from pred transition=\(String(describing: c))")
print("config from pred transition=\(c?.description ?? "nil")")
}
return c!
}
@ -1796,7 +1796,7 @@ open class ParserATNSimulator: ATNSimulator {
}
if debug {
print("config from pred transition=\(String(describing: c))")
print("config from pred transition=\(c?.description ?? "nil")")
}
return c
}
@ -1804,7 +1804,7 @@ open class ParserATNSimulator: ATNSimulator {
final func ruleTransition(_ config: ATNConfig, _ t: RuleTransition) -> ATNConfig {
if debug {
print("CALL rule \(getRuleName(t.target.ruleIndex!)), ctx=\(String(describing: config.context))")
print("CALL rule \(getRuleName(t.target.ruleIndex!)), ctx=\(config.context?.description ?? "nil")")
}
let returnState = t.followState
@ -1961,7 +1961,7 @@ open class ParserATNSimulator: ATNSimulator {
_ to: DFAState?) -> DFAState? {
var to = to
if debug {
print("EDGE \(String(describing: from)) -> \(String(describing: to)) upon \(getTokenName(t))")
print("EDGE \(from?.description ?? "nil")) -> \(to?.description ?? "nil") upon \(getTokenName(t))")
}
if to == nil {