Skip to content

Commit 95f6b2b

Browse files
committed
Fix unseen Inner Class of Abstract Class
- Scala 3.3.5 complains about not seeing the inner class Value of Enum, so we refactor to create an EnumValue trait DAFFODIL-2975
1 parent 37edb36 commit 95f6b2b

File tree

9 files changed

+30
-29
lines changed

9 files changed

+30
-29
lines changed

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ lazy val runtime1 = Project("daffodil-runtime1", file("daffodil-runtime1"))
8888
.settings(Dependencies.genjavadocVersion) // converts scaladoc to javadoc
8989
.dependsOn(
9090
io,
91-
lib % "test->test",
91+
lib % "compile-internal, test->test",
9292
udf,
9393
macroLib % "compile-internal, test-internal",
9494
slf4jLogger % "test"

daffodil-core/src/test/scala/org/apache/daffodil/core/schema/annotation/props/TestPropertyRuntime.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import org.apache.daffodil.lib.schema.annotation.props._
2626
import org.junit.Assert._
2727
import org.junit.Test
2828

29-
sealed trait MyPropType extends MyProp.Value
29+
sealed trait MyPropType extends EnumValue
3030
object MyProp
3131
extends Enum[MyPropType] // with ThrowsSDE
3232
{
@@ -87,7 +87,7 @@ class HasMixin
8787
lazy val properties: PropMap = Map.empty
8888
}
8989

90-
sealed trait TheExampleProp extends TheExampleProp.Value
90+
sealed trait TheExampleProp extends EnumValue
9191
object TheExampleProp extends Enum[TheExampleProp] {
9292
case object Left extends TheExampleProp
9393
case object Right extends TheExampleProp

daffodil-lib/src/main/scala/org/apache/daffodil/lib/schema/annotation/props/ByHandMixins.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ import passera.unsigned.ULong
5555
* So the code generator has exclusions for these.
5656
*/
5757

58-
sealed trait AlignmentType extends AlignmentType.Value
58+
sealed trait AlignmentType extends EnumValue
5959
object AlignmentType extends Enum[AnyRef] { // Note: Was using AlignmentUnits mixin here!
6060
case object Implicit extends AlignmentType
6161
override lazy val values = Array(Implicit)
@@ -140,7 +140,7 @@ trait TextStandardBaseMixin extends PropertyMixin {
140140
}
141141
}
142142

143-
sealed trait SeparatorSuppressionPolicy extends SeparatorSuppressionPolicy.Value
143+
sealed trait SeparatorSuppressionPolicy extends EnumValue
144144
object SeparatorSuppressionPolicy extends Enum[SeparatorSuppressionPolicy] {
145145
case object Never extends SeparatorSuppressionPolicy
146146
case object TrailingEmpty extends SeparatorSuppressionPolicy
@@ -484,7 +484,7 @@ trait TextStandardExponentRepMixin extends PropertyMixin {
484484
* By hand because we can set our preference for it via a tunable.
485485
* And also can require it to be present or not via a tunable.
486486
*/
487-
sealed trait EmptyElementParsePolicy extends EmptyElementParsePolicy.Value
487+
sealed trait EmptyElementParsePolicy extends EnumValue
488488
object EmptyElementParsePolicy extends Enum[EmptyElementParsePolicy] {
489489
case object TreatAsMissing extends EmptyElementParsePolicy // deprecated
490490
case object TreatAsEmpty extends EmptyElementParsePolicy

daffodil-lib/src/main/scala/org/apache/daffodil/lib/schema/annotation/props/Properties.scala

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -84,23 +84,6 @@ import org.apache.daffodil.lib.util._
8484
abstract class EnumBase
8585
abstract class EnumValueBase extends Serializable
8686
abstract class Enum[A] extends EnumBase with Converter[String, A] {
87-
class Value extends EnumValueBase { self: A =>
88-
override lazy val toString = {
89-
val theVal = this
90-
val cn = getNameFromClass(this)
91-
val en = cn match {
92-
//
93-
// Special case for CalendarFirstDayOfWeek
94-
//
95-
case "Sunday" | "Monday" | "Tuesday" | "Wednesday" | "Thursday" | "Friday" |
96-
"Saturday" =>
97-
cn
98-
case _ => Misc.toInitialLowerCaseUnlessAllUpperCase(cn)
99-
}
100-
en
101-
}
102-
}
103-
10487
def toPropName(prop: A) = prop.toString
10588

10689
val values: Array[A]
@@ -133,6 +116,21 @@ abstract class Enum[A] extends EnumBase with Converter[String, A] {
133116

134117
def apply(name: String, context: ThrowsSDE): A
135118
} // end class
119+
trait EnumValue extends EnumValueBase {
120+
override lazy val toString = {
121+
val theVal = this
122+
val cn = getNameFromClass(this)
123+
val en = cn match {
124+
//
125+
// Special case for CalendarFirstDayOfWeek
126+
//
127+
case "Sunday" | "Monday" | "Tuesday" | "Wednesday" | "Thursday" | "Friday" | "Saturday" =>
128+
cn
129+
case _ => Misc.toInitialLowerCaseUnlessAllUpperCase(cn)
130+
}
131+
en
132+
}
133+
}
136134

137135
/**
138136
* base mixin for traits representing collections of DFDL properties

daffodil-propgen/src/main/scala/org/apache/daffodil/propGen/PropertyGenerator.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ class PropertyGenerator(arg: Node) {
379379
*/
380380

381381
val templateStart =
382-
"""sealed trait Currency extends Currency.Value
382+
"""sealed trait Currency extends EnumValue
383383
object Currency extends Enum[Currency] {
384384
"""
385385
val templateMiddle =

daffodil-propgen/src/main/scala/org/apache/daffodil/propGen/TunableGenerator.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ class TunableGenerator(schemaRootConfig: scala.xml.Node, schemaRootExt: scala.xm
5656
|import org.apache.daffodil.lib.exceptions.ThrowsSDE
5757
|import org.apache.daffodil.lib.schema.annotation.props.EmptyElementParsePolicy
5858
|import org.apache.daffodil.lib.schema.annotation.props.Enum
59+
|import org.apache.daffodil.lib.schema.annotation.props.EnumValue
5960
|import org.apache.daffodil.lib.util.Misc
6061
|import org.apache.daffodil.lib.xml.DaffodilXMLLoader
6162
|import org.apache.daffodil.lib.xml.XMLUtils
@@ -347,7 +348,7 @@ class TunableEnumDefinition(
347348
private val allEnumerationValues = getAllEnumerationValues(simpleTypeNode)
348349

349350
private val top = s"""
350-
|sealed trait ${scalaType} extends ${scalaType}.Value
351+
|sealed trait ${scalaType} extends EnumValue
351352
|object ${scalaType} extends Enum[${scalaType}] {
352353
""".trim.stripMargin
353354

daffodil-propgen/src/main/scala/org/apache/daffodil/propGen/WarnIDGenerator.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,9 @@ class WarnIDGenerator(schema: scala.xml.Node) {
5353
|import org.apache.daffodil.lib.exceptions.Assert
5454
|import org.apache.daffodil.lib.exceptions.ThrowsSDE
5555
|import org.apache.daffodil.lib.schema.annotation.props.Enum
56+
|import org.apache.daffodil.lib.schema.annotation.props.EnumValue
5657
|
57-
|sealed trait WarnID extends WarnID.Value
58+
|sealed trait WarnID extends EnumValue
5859
|object WarnID extends Enum[WarnID] {
5960
""".trim.stripMargin
6061

daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/debugger/InteractiveDebugger.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ class InteractiveDebugger(
139139
var parseStep = 0
140140

141141
/* how to display data */
142-
var representation: Representation.Value = Representation.Text
142+
var representation: Representation = Representation.Text
143143
}
144144

145145
var debugState: DebugState.Type = DebugState.Pause

daffodil-test/src/test/scala/org/apache/daffodil/runtime1/layers/SimpleBombOutLayer.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import java.io.OutputStream
2424
import org.apache.daffodil.lib.exceptions.Assert
2525
import org.apache.daffodil.lib.exceptions.ThrowsSDE
2626
import org.apache.daffodil.lib.schema.annotation.props.Enum
27+
import org.apache.daffodil.lib.schema.annotation.props.EnumValue
2728
import org.apache.daffodil.runtime1.layers.api.Layer
2829

2930
/**
@@ -34,7 +35,7 @@ final class STL_BombOutLayer() extends Layer("stlBombOutLayer", "urn:STL") {
3435

3536
private lazy val context: ThrowsSDE = this.getLayerRuntime.layerRuntimeData.context
3637

37-
sealed trait Loc extends Loc.Value
38+
sealed trait Loc extends EnumValue
3839
object Loc
3940
extends Enum[Loc] // with ThrowsSDE
4041
{
@@ -66,7 +67,7 @@ final class STL_BombOutLayer() extends Layer("stlBombOutLayer", "urn:STL") {
6667
}
6768
import Loc._
6869

69-
sealed trait Kind extends Kind.Value
70+
sealed trait Kind extends EnumValue
7071
object Kind extends Enum[Kind] {
7172
final case object ThrowRE extends Kind
7273
final case object ThrowEX extends Kind

0 commit comments

Comments
 (0)