diff options
author | Paul Phillips <paulp@improving.org> | 2013-12-31 07:04:57 -0800 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2013-12-31 07:29:44 -0800 |
commit | 969a269033ee3477cb21a539cf2b5b6fa308d105 (patch) | |
tree | 95d06cf3a1a53384938f6377730ec2988b757384 /src/compiler | |
parent | e0a3702f8a07ca87b5ae71167793533271a4fe57 (diff) | |
download | scala-969a269033ee3477cb21a539cf2b5b6fa308d105.tar.gz scala-969a269033ee3477cb21a539cf2b5b6fa308d105.tar.bz2 scala-969a269033ee3477cb21a539cf2b5b6fa308d105.zip |
Finalized some case classes, for better static checking.
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/patmat/PatternExpander.scala | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/patmat/PatternExpander.scala b/src/compiler/scala/tools/nsc/transform/patmat/PatternExpander.scala index 5cb4aff272..e84ccbf754 100644 --- a/src/compiler/scala/tools/nsc/transform/patmat/PatternExpander.scala +++ b/src/compiler/scala/tools/nsc/transform/patmat/PatternExpander.scala @@ -39,7 +39,7 @@ trait PatternExpander[Pattern, Type] { * * sequenceType is Seq[T], elementType is T, repeatedType is T*. */ - case class Repeated(sequenceType: Type, elementType: Type, repeatedType: Type) { + sealed case class Repeated(sequenceType: Type, elementType: Type, repeatedType: Type) { def exists = elementType != NoType def elementList = if (exists) elementType :: Nil else Nil @@ -52,7 +52,7 @@ trait PatternExpander[Pattern, Type] { override def toString = "<none>" } - case class Patterns(fixed: List[Pattern], star: Pattern) { + final case class Patterns(fixed: List[Pattern], star: Pattern) { def hasStar = star != NoPattern def starArity = if (hasStar) 1 else 0 def nonStarArity = fixed.length @@ -86,7 +86,7 @@ trait PatternExpander[Pattern, Type] { * @param fixed The non-sequence types which are extracted * @param repeated The sequence type which is extracted */ - case class Extractor(whole: Type, fixed: List[Type], repeated: Repeated) { + final case class Extractor(whole: Type, fixed: List[Type], repeated: Repeated) { require(whole != NoType, s"expandTypes($whole, $fixed, $repeated)") def productArity = fixed.length @@ -107,7 +107,7 @@ trait PatternExpander[Pattern, Type] { override def toString = "%s => %s".format(whole, offeringString) } - case class TypedPat(pat: Pattern, tpe: Type) { + final case class TypedPat(pat: Pattern, tpe: Type) { override def toString = s"$pat: $tpe" } @@ -118,7 +118,7 @@ trait PatternExpander[Pattern, Type] { * sequence which can populate at least <elementArity> patterns. * < 0: There are more products than patterns: compile time error. */ - case class Aligned(patterns: Patterns, extractor: Extractor) { + final case class Aligned(patterns: Patterns, extractor: Extractor) { def elementArity = patterns.nonStarArity - productArity def productArity = extractor.productArity def starArity = patterns.starArity |