Since compiledOptEscChar and compiledOptEscEscChar
are compiled values, they should be 'val' because
we can know it at compile-time. As such, we need
to force this to execute at compile-time as to
avoid the Assert.invariant failed that occurs when
we execute a compile-time check at run-time (lazy val).
DFDL-471
diff --git a/daffodil-runtime1/src/main/scala/edu/illinois/ncsa/daffodil/processors/PrimitivesLengthKind.scala b/daffodil-runtime1/src/main/scala/edu/illinois/ncsa/daffodil/processors/PrimitivesLengthKind.scala
index 10a1148..eac9302 100644
--- a/daffodil-runtime1/src/main/scala/edu/illinois/ncsa/daffodil/processors/PrimitivesLengthKind.scala
+++ b/daffodil-runtime1/src/main/scala/edu/illinois/ncsa/daffodil/processors/PrimitivesLengthKind.scala
@@ -453,31 +453,7 @@
case x => Some(x)
}
- lazy val compiledOptEscChar: Option[String] = {
- // Attempts to use the below (which is what I want to do)
- // results in Null pointer exceptions.
- //
- // val res = self.es match {
- // case None => None
- // case Some(esObj) => constEval(esObj.knownEscapeCharacter)
- // }
- // res
- evalAsConstant(esObj.escapeCharacter)
- }
-
- lazy val compiledOptEscEscChar: Option[String] = {
- // Attempts to use the below (which is what I want to do)
- // results in Null pointer exceptions.
- //
- // val res = es match {
- // case None => None
- // case Some(esObj) => constEval(esObj.knownEscapeEscapeCharacter)
- // }
- // res
- evalAsConstant(esObj.escapeEscapeCharacter)
- }
-
- private def constEval(knownValue: Option[String]) = {
+ protected def constEval(knownValue: Option[String]) = {
val optConstValue = knownValue match {
case None => None
case Some(constValue) => {
@@ -489,7 +465,7 @@
optConstValue
}
- private def evalAsConstant(knownValue: Option[CompiledExpression]) = {
+ protected def evalAsConstant(knownValue: Option[CompiledExpression]) = {
knownValue match {
case None => None
case Some(ce) if ce.isConstant => {
@@ -556,6 +532,9 @@
val es = e.optionEscapeScheme
val esObj = EscapeScheme.getEscapeScheme(es, e)
+ val compiledOptEscChar: Option[String] = evalAsConstant(esObj.escapeCharacter)
+ val compiledOptEscEscChar: Option[String] = evalAsConstant(esObj.escapeEscapeCharacter)
+
val tm = e.allTerminatingMarkup
val cname = toString