From d275a8c97f812b5550c9cef243e6be0d7e0c24ca Mon Sep 17 00:00:00 2001 From: Ewan Mellor Date: Fri, 9 Nov 2018 10:51:44 -0800 Subject: [PATCH] [Swift] Make ParserATNSimulator.precedenceTransition return a nullable value. This was always clearly a possibility, looking at the body of the method. The newly-enabled performance tests expose this bug (and I don't know how we've gotten away with it otherwise for so long). The Java runtime also returns null at this point. --- runtime/Swift/Sources/Antlr4/atn/ParserATNSimulator.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/Swift/Sources/Antlr4/atn/ParserATNSimulator.swift b/runtime/Swift/Sources/Antlr4/atn/ParserATNSimulator.swift index ba9cecc8b..406e01be7 100644 --- a/runtime/Swift/Sources/Antlr4/atn/ParserATNSimulator.swift +++ b/runtime/Swift/Sources/Antlr4/atn/ParserATNSimulator.swift @@ -1722,7 +1722,7 @@ open class ParserATNSimulator: ATNSimulator { _ pt: PrecedencePredicateTransition, _ collectPredicates: Bool, _ inContext: Bool, - _ fullCtx: Bool) throws -> ATNConfig { + _ fullCtx: Bool) throws -> ATNConfig? { if debug { print("PRED (collectPredicates=\(collectPredicates)) \(pt.precedence)>=_p, ctx dependent=true") //if ( parser != nil ) { @@ -1757,7 +1757,7 @@ open class ParserATNSimulator: ATNSimulator { if debug { print("config from pred transition=\(c?.description ?? "nil")") } - return c! + return c }