Skip to content

Commit d09fd02

Browse files
committed
Merge pull request #2 from phaller/topic/virt_refinedmanifest
Add refinedType to object ClassManifest
2 parents 6197fea + 9e5ffbd commit d09fd02

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/library/scala/reflect/ClassManifest.scala

+11
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,17 @@ object ClassManifest {
245245
override val typeArguments = args.toList
246246
override def toString = prefix.toString+"#"+name+argString
247247
}
248+
249+
/** Manifest for the refined type
250+
* `parent { val fieldNames(0) : fieldTypes(0) ; ... ; val fieldNames(n) : fieldTypes(n) }`.
251+
*/
252+
def refinedType[T](parent: Manifest[_], fieldNames: List[String], fieldTypes: List[Manifest[_]]): Manifest[T] =
253+
new RefinedManifest[T] {
254+
def erasure = parent.erasure
255+
def fields = fieldNames zip fieldTypes
256+
override def toString = parent + (fieldNames zip fieldTypes).map{case(n, t) => "val "+ n +" : "+ t}.mkString("{","; ", "}")
257+
}
258+
248259
}
249260

250261
/** Manifest for the class type `clazz[args]`, where `clazz` is

src/library/scala/reflect/Manifest.scala

+3
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,9 @@ object Manifest {
267267
override def toString = parents.mkString(" with ")
268268
}
269269

270+
/** Manifest for the refined type
271+
* `parent { val fieldNames(0) : fieldTypes(0) ; ... ; val fieldNames(n) : fieldTypes(n) }`.
272+
*/
270273
def refinedType[T](parent: Manifest[_], fieldNames: List[String], fieldTypes: List[Manifest[_]]): Manifest[T] =
271274
new RefinedManifest[T] {
272275
def erasure = parent.erasure

0 commit comments

Comments
 (0)