diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2014-02-01 00:46:07 +0100 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2014-02-15 09:23:51 +0100 |
commit | fa8f4022754356859f3af1c4ffbac02ab3dc3e7c (patch) | |
tree | 967f7ba7625c63c7d87b0ef659afb8516c589def /test/files/run/reflection-magicsymbols-invoke.scala | |
parent | 462d0b8b1c9de95baad773856a7e1f658ebd0956 (diff) | |
download | scala-fa8f4022754356859f3af1c4ffbac02ab3dc3e7c.tar.gz scala-fa8f4022754356859f3af1c4ffbac02ab3dc3e7c.tar.bz2 scala-fa8f4022754356859f3af1c4ffbac02ab3dc3e7c.zip |
some renamings
It’s almost 1am, so I’m only scratching the surface, mechanistically
applying the renames that I’ve written down in my notebook:
* typeSignature => info
* declarations => decls
* nme/tpnme => termNames/typeNames
* paramss => paramLists
* allOverriddenSymbols => overrides
Some explanation is in order so that I don’t get crucified :)
1) No information loss happens when abbreviating `typeSignature` and `declarations`.
We already have contractions in a number of our public APIs (e.g. `typeParams`),
and I think it’s fine to shorten words as long as people can understand
the shortened versions without a background in scalac.
2) I agree with Simon that `nme` and `tpnme` are cryptic. I think it would
be thoughtful of us to provide newcomers with better names. To offset
the increase in mouthfulness, I’ve moved `MethodSymbol.isConstructor`
to `Symbol.isConstructor`, which covers the most popular use case for nme’s.
3) I also agree that putting `paramss` is a lot to ask of our users.
The double-“s” convention is very neat, but let’s admit that it’s just
weird for the newcomers. I think `paramLists` is a good compromise here.
4) `allOverriddenSymbols` is my personal complaint. I think it’s a mouthful
and a shorter name would be a much better fit for the public API.
Diffstat (limited to 'test/files/run/reflection-magicsymbols-invoke.scala')
-rw-r--r-- | test/files/run/reflection-magicsymbols-invoke.scala | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/test/files/run/reflection-magicsymbols-invoke.scala b/test/files/run/reflection-magicsymbols-invoke.scala index ff3992709f..793f78bff4 100644 --- a/test/files/run/reflection-magicsymbols-invoke.scala +++ b/test/files/run/reflection-magicsymbols-invoke.scala @@ -9,7 +9,7 @@ package scala { } object Test extends App { - def key(sym: Symbol) = sym + ": " + sym.typeSignature + def key(sym: Symbol) = sym + ": " + sym.info def test(tpe: Type, receiver: Any, method: String, args: Any*) { def wrap[T](op: => T) = try { @@ -24,11 +24,11 @@ object Test extends App { } print(s"testing ${tpe.typeSymbol.name}.$method: ") wrap({ - if (method == nme.CONSTRUCTOR.toString) { - val ctor = tpe.declaration(nme.CONSTRUCTOR).asMethod + if (method == termNames.CONSTRUCTOR.toString) { + val ctor = tpe.decl(termNames.CONSTRUCTOR).asMethod cm.reflectClass(ctor.owner.asClass).reflectConstructor(ctor)(args: _*) } else { - val meth = tpe.declaration(TermName(method).encodedName.toTermName).asMethod + val meth = tpe.decl(TermName(method).encodedName.toTermName).asMethod cm.reflect(receiver).reflectMethod(meth)(args: _*) } }) @@ -53,8 +53,8 @@ object Test extends App { println("============\nAnyVal") println("it's important to print the list of AnyVal's members") println("if some of them change (possibly, adding and/or removing magic symbols), we must update this test") - typeOf[AnyVal].declarations.toList.sortBy(key).foreach(sym => println(key(sym))) - test(typeOf[AnyVal], null, nme.CONSTRUCTOR.toString) + typeOf[AnyVal].decls.toList.sortBy(key).foreach(sym => println(key(sym))) + test(typeOf[AnyVal], null, termNames.CONSTRUCTOR.toString) test(typeOf[AnyVal], 2, "getClass") println("============\nAnyRef") @@ -84,17 +84,17 @@ object Test extends App { println("============\nArray") println("it's important to print the list of Array's members") println("if some of them change (possibly, adding and/or removing magic symbols), we must update this test") - ArrayClass.typeSignature.members.toList.sortBy(key).foreach(sym => println(key(sym))) - test(ArrayClass.typeSignature, Array(1, 2), "length") - test(ArrayClass.typeSignature, Array(1, 2), "apply", 0) - test(ArrayClass.typeSignature, Array(1, 2), "update", 0, 0) - test(ArrayClass.typeSignature, Array(1, 2), "clone") + ArrayClass.info.members.toList.sortBy(key).foreach(sym => println(key(sym))) + test(ArrayClass.info, Array(1, 2), "length") + test(ArrayClass.info, Array(1, 2), "apply", 0) + test(ArrayClass.info, Array(1, 2), "update", 0, 0) + test(ArrayClass.info, Array(1, 2), "clone") println("============\nOther") test(typeOf[String], "2", "+", 3) println("============\nCTM") - test(PredefModule.moduleClass.typeSignature, Predef, "classOf") - test(PredefModule.moduleClass.typeSignature, Predef, "classOf", typeOf[String]) + test(PredefModule.moduleClass.info, Predef, "classOf") + test(PredefModule.moduleClass.info, Predef, "classOf", typeOf[String]) test(typeOf[scala.reflect.api.Universe], scala.reflect.runtime.universe, "reify", "2") }
\ No newline at end of file |