From fa8f4022754356859f3af1c4ffbac02ab3dc3e7c Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Sat, 1 Feb 2014 00:46:07 +0100 Subject: some renamings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- .../neg/macro-blackbox-dynamic-materialization/Macros_1.scala | 2 +- .../neg/macro-blackbox-fundep-materialization/Macros_1.scala | 8 ++++---- test/files/neg/macro-divergence-controlled/Impls_Macros_1.scala | 4 ++-- test/files/neg/t8104/Macros_1.scala | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) (limited to 'test/files/neg') diff --git a/test/files/neg/macro-blackbox-dynamic-materialization/Macros_1.scala b/test/files/neg/macro-blackbox-dynamic-materialization/Macros_1.scala index 3cfbdf45e9..fc2907b6dc 100644 --- a/test/files/neg/macro-blackbox-dynamic-materialization/Macros_1.scala +++ b/test/files/neg/macro-blackbox-dynamic-materialization/Macros_1.scala @@ -18,7 +18,7 @@ object Macros { def impl[T: c.WeakTypeTag](c: Context) = { import c.universe._ val tpe = weakTypeOf[T] - if (tpe.members.exists(_.typeSignature =:= typeOf[Int])) + if (tpe.members.exists(_.info =:= typeOf[Int])) c.abort(c.enclosingPosition, "I don't like classes that contain integers") q"new Foo[$tpe]{ override def toString = ${tpe.toString} }" } diff --git a/test/files/neg/macro-blackbox-fundep-materialization/Macros_1.scala b/test/files/neg/macro-blackbox-fundep-materialization/Macros_1.scala index a6f7de23bb..8d776388ee 100644 --- a/test/files/neg/macro-blackbox-fundep-materialization/Macros_1.scala +++ b/test/files/neg/macro-blackbox-fundep-materialization/Macros_1.scala @@ -15,12 +15,12 @@ object Iso { val sym = c.weakTypeOf[T].typeSymbol if (!sym.isClass || !sym.asClass.isCaseClass) c.abort(c.enclosingPosition, s"$sym is not a case class") - val fields = sym.typeSignature.declarations.toList.collect{ case x: TermSymbol if x.isVal && x.isCaseAccessor => x } + val fields = sym.info.decls.toList.collect{ case x: TermSymbol if x.isVal && x.isCaseAccessor => x } def mkTpt() = { val core = Ident(TupleClass(fields.length) orElse UnitClass) if (fields.length == 0) core - else AppliedTypeTree(core, fields map (f => TypeTree(f.typeSignature))) + else AppliedTypeTree(core, fields map (f => TypeTree(f.info))) } def mkFrom() = { @@ -32,8 +32,8 @@ object Iso { List(AppliedTypeTree(Ident(newTypeName("Iso")), List(Ident(sym), mkTpt()))), emptyValDef, List( - DefDef(Modifiers(), nme.CONSTRUCTOR, List(), List(List()), TypeTree(), Block(List(Apply(Select(Super(This(tpnme.EMPTY), tpnme.EMPTY), nme.CONSTRUCTOR), List())), Literal(Constant(())))), + DefDef(Modifiers(), termNames.CONSTRUCTOR, List(), List(List()), TypeTree(), Block(List(Apply(Select(Super(This(typeNames.EMPTY), typeNames.EMPTY), termNames.CONSTRUCTOR), List())), Literal(Constant(())))), DefDef(Modifiers(), newTermName("to"), List(), List(List(ValDef(Modifiers(PARAM), newTermName("f"), Ident(sym), EmptyTree))), TypeTree(), mkFrom())))) - c.Expr[Iso[T, U]](Block(List(evidenceClass), Apply(Select(New(Ident(newTypeName("$anon"))), nme.CONSTRUCTOR), List()))) + c.Expr[Iso[T, U]](Block(List(evidenceClass), Apply(Select(New(Ident(newTypeName("$anon"))), termNames.CONSTRUCTOR), List()))) } } diff --git a/test/files/neg/macro-divergence-controlled/Impls_Macros_1.scala b/test/files/neg/macro-divergence-controlled/Impls_Macros_1.scala index 186c285871..5c04503260 100644 --- a/test/files/neg/macro-divergence-controlled/Impls_Macros_1.scala +++ b/test/files/neg/macro-divergence-controlled/Impls_Macros_1.scala @@ -9,8 +9,8 @@ object Complex { def impl[T: c.WeakTypeTag](c: Context): c.Expr[Complex[T]] = { import c.universe._ val tpe = weakTypeOf[T] - for (f <- tpe.declarations.collect{case f: TermSymbol if f.isParamAccessor && !f.isMethod => f}) { - val trecur = appliedType(typeOf[Complex[_]], List(f.typeSignature)) + for (f <- tpe.decls.collect{case f: TermSymbol if f.isParamAccessor && !f.isMethod => f}) { + val trecur = appliedType(typeOf[Complex[_]], List(f.info)) if (c.openImplicits.tail.exists(ic => ic.pt =:= trecur)) c.abort(c.enclosingPosition, "diverging implicit expansion. reported by a macro!") val recur = c.inferImplicitValue(trecur, silent = true) if (recur == EmptyTree) c.abort(c.enclosingPosition, s"couldn't synthesize $trecur") diff --git a/test/files/neg/t8104/Macros_1.scala b/test/files/neg/t8104/Macros_1.scala index 2ad4bc5a99..e135bd807b 100644 --- a/test/files/neg/t8104/Macros_1.scala +++ b/test/files/neg/t8104/Macros_1.scala @@ -4,8 +4,8 @@ object Macros { def impl[T](c: Context)(implicit T: c.WeakTypeTag[T]) = { import c.universe._ import definitions._ - val fields = T.tpe.declarations.toList.collect{ case x: TermSymbol if x.isVal && x.isCaseAccessor => x } - val Repr = appliedType(TupleClass(fields.length).asType.toType, fields.map(_.typeSignature)) + val fields = T.tpe.decls.toList.collect{ case x: TermSymbol if x.isVal && x.isCaseAccessor => x } + val Repr = appliedType(TupleClass(fields.length).asType.toType, fields.map(_.info)) q"new Generic[$T]{ type Repr = $Repr }" } } \ No newline at end of file -- cgit v1.2.3