diff options
author | Martin Odersky <odersky@gmail.com> | 2011-08-23 11:58:15 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2011-08-23 11:58:15 +0000 |
commit | e69822117c99a6c79a69a5b4dde3a82040400bb3 (patch) | |
tree | 0fee23c32b028e948c3c1445df8aeb325cc77166 /src/compiler/scala/reflect/internal/Symbols.scala | |
parent | a93134b4832e95ff014f162f4cc8667f8136cb7d (diff) | |
download | scala-e69822117c99a6c79a69a5b4dde3a82040400bb3.tar.gz scala-e69822117c99a6c79a69a5b4dde3a82040400bb3.tar.bz2 scala-e69822117c99a6c79a69a5b4dde3a82040400bb3.zip |
New reification code for symbols and types.
Diffstat (limited to 'src/compiler/scala/reflect/internal/Symbols.scala')
-rw-r--r-- | src/compiler/scala/reflect/internal/Symbols.scala | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/compiler/scala/reflect/internal/Symbols.scala b/src/compiler/scala/reflect/internal/Symbols.scala index 632b7194f8..d88b4b9c15 100644 --- a/src/compiler/scala/reflect/internal/Symbols.scala +++ b/src/compiler/scala/reflect/internal/Symbols.scala @@ -600,6 +600,27 @@ trait Symbols extends api.Symbols { self: SymbolTable => else if (isContravariant) -1 else 0 + + /** The sequence number of this parameter symbol among all type + * and value parameters of symbol's owner. -1 if symbol does not + * appear among the parameters of its owner. + */ + def paramPos: Int = { + def searchIn(tpe: Type, base: Int): Int = { + def searchList(params: List[Symbol], fallback: Type): Int = { + val idx = params indexOf this + if (idx >= 0) idx + base + else searchIn(fallback, base + params.length) + } + tpe match { + case PolyType(tparams, res) => searchList(tparams, res) + case MethodType(params, res) => searchList(params, res) + case _ => -1 + } + } + searchIn(owner.info, 0) + } + // ------ owner attribute -------------------------------------------------------------- def owner: Symbol = rawowner |