| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Adds query methods to the public reflection API for querying the
JAVA_ENUM and JAVA_ANNOTATION flags.
Didn't include JAVA_DEFAULTMETHOD because it does not correspond
to a real java classfile flag (just a non-abstract method in an
interface), and we want to clean the usage of this flag before adding
it to a public API.
The flags themselfs are not added to the reflection API. A comment in
api/FlagSets.scala says:
Q: I have a pretty flag. Can I put it here?
A: Only if there's a tree that cannot be built without it.
If you want to put a flag here so that it can be tested
against, introduce an `isXXX` method in one of the api.Symbols
classes instead.
|
|
|
| |
`paramLists` name doesn't end in `ss`, so that sentence belongs to `paramss`. Also a few punctuation fixes.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This commit corrects many typos found in scaladocs, comments and
documentation. It should reduce a bit number of PRs which fix one
typo.
There are no changes in the 'real' code except one corrected name of
a JUnit test method and some error messages in exceptions. In the case
of typos in other method or field names etc., I just skipped them.
Obviously this commit doesn't fix all existing typos. I just generated
in IntelliJ the list of potential typos and looked through it quickly.
|
|
|
|
|
| |
- Replace newTermName in favour of TermName
- Replace newTypeName in favour of TypeName
|
| |
|
|
|
|
| |
this is some weird stuff
|
|
|
|
|
|
|
| |
As per Jason's feedback, these are now undeprecated, being aliases for
info and infoIn. I haven't touched the newly introduced setInfo family of
methods, because I think that on internal level we don't need setTypeSignature
anyway.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before this commit, Symbol.associatedFile used to be broken in two ways.
Firstly, it was never autoloaded (just like we used to have flags,
privateWithin and annotations). Secondly, it was never filled in by runtime
reflection.
My first attempt at fixing those problems was, well, just fixing them.
However, its runtime implementation was based on a hacky function that
we were not very much excited about supported (see comments),
whereas its compile-time usefulness was somewhat questionable.
Therefore the second attempt at fixing this bug is deprecating the API
altogether, replacing it with `Symbol.pos.source`.
Since `Symbol.pos` isn't retained for runtime consumption,
`Symbol.pos.source` is still going to return `NoAbstractFile` as before
this commit, but that's left for future work, and suggested approach
is documented in SI-8259.
|
|
|
|
| |
Seems to be useful to people, so why not expose it more widely?
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
As per Jason’s additional request, this commit exposes alternatives
in the base Symbol type, rather than only in TermSymbol.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Reflection API exhibits a tension inherent to experimental things:
on the one hand we want it to grow into a beautiful and robust API,
but on the other hand we have to deal with immaturity of underlying mechanisms
by providing not very pretty solutions to enable important use cases.
In Scala 2.10, which was our first stab at reflection API, we didn't
have a systematic approach to dealing with this tension, sometimes exposing
too much of internals (e.g. Symbol.deSkolemize) and sometimes exposing
too little (e.g. there's still no facility to change owners, to do typing
transformations, etc). This resulted in certain confusion with some internal
APIs living among public ones, scaring the newcomers, and some internal APIs
only available via casting, which requires intimate knowledge of the
compiler and breaks compatibility guarantees.
This led to creation of the `internal` API module for the reflection API,
which provides advanced APIs necessary for macros that push boundaries
of the state of the art, clearly demarcating them from the more or less
straightforward rest and providing compatibility guarantees on par with
the rest of the reflection API.
This commit does break source compatibility with reflection API in 2.10,
but the next commit is going to introduce a strategy of dealing with that.
|
|
|
|
|
|
|
|
| |
This is the first step in disentangling api#Symbol.isPackage, which is
supposed to return false for package classes, and internal#Symbol.isPackage,
which has traditionally being used as a synonym for hasPackageFlag and
hence returned true for package classes (unlike isModule which is false
for module classes).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
`Symbol.isOverride` joins `Symbol.isLocal` in the unfortunate family
of methods for which we had to break source compatibility because of
their utter brokenness.
Apparently, `isOverride` only returns true for those symbols that have
the OVERRIDE flag set (i.e. the ones that are derived from source definitions
that have the `override` modifier specified next to them). Of course,
this is very confusing, and that’s exacerbated by the fact that we can’t
fix this behavior, because there’s `internal#Symbol.isOverride` that someone
might rely on.
Given that there’s perfectly working `Symbol.allOverriddenSymbols`,
this commit removes the `Symbol.isOverride` API altogether.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
While playing with tests for Type.companionType, I figured out that
companionSymbol isn’t what it seems to be:
scala> ScalaPackage.companionSymbol
res5: $r.intp.global.Symbol = <none>
scala> ScalaPackageClass.companionSymbol
res6: $r.intp.global.Symbol = package scala
Or even funnier observation:
scala> class C; object C
defined class C
defined object C
scala> val classC = typeOf[C].typeSymbol
classC: $r.intp.global.Symbol = class C
scala> val moduleC = classC.companionSymbol
moduleC: $r.intp.global.Symbol = object C
scala> classC.companionSymbol == moduleC
res0: Boolean = true
scala> moduleC.companionSymbol == classC
res1: Boolean = true
scala> moduleC.moduleClass.companionSymbol == moduleC
res2: Boolean = true
Of course, I rushed to clean this up, so that `companionSymbol` only
returns something other than NoSymbol if the target has a companion in
the common sense, not wrt the internal “class with the same name in the
same package” convention of scalac, and that `companionSymbol` for
module classes is a class, not a source module.
Unfortunately it’s not that easy, because api.Symbol#companionSymbol
has the same name as internal.Symbol#companionSymbol, so we can’t change
the behavior of the former without changing the behavior of the latter.
Therefore I deprecated api.Symbol#companionSymbol and introduced a replacement
called api.Symbol#companion with sane semantics.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Exposes a popular code pattern in macros as a dedicated reflection API.
This simple commit, however, ended up being not so simple, as it often
happens with our compiler.
When writing a test for the new API, I realized that our (pre-existing)
MethodSymbol.isPrimaryConstructor API returns nonsensical results for
implementation artifacts (trait mixin ctors, module class ctors).
What’s even more funny is that according to our reflection internals,
even Java classes have primary constructors. Well, that’s not surprising,
because `primaryConstructor` is just `decl(ctorName).alternatives.head`.
Good thing that package classes don’t have constructors or that would
elevate the situation to three fries short of a happy meal.
At the moment, I’m too scared to fiddle with internal#Symbol.primaryConstructor,
because that could easily break someone right before RC1, so I simply
documented the findings in SI-8193 and postponed the actual work, except
for one thing - isJavaDefined symbols no longer have primary constructors.
|
|
|
|
|
|
| |
Following Simon’s request, this commit introduces a dedicated API
that can be used to acquire the list of exceptions thrown by a method,
abstracting away from whether it’s a Java or a Scala artifact.
|
|
|
|
|
|
|
|
|
|
|
| |
Makes sure that almost every abstract type declared in reflection API
erases to a unique class, so that they can be adequately used for
method overloading to the same extent that tags allow them to be used
in pattern matching.
The only two exceptions from this rule are the types whose implementations
we do not control: FlagSet that is implemented as Long and RuntimeClass
that is implemented as java.lang.Class[_].
|
|
|
|
|
|
|
| |
I don’t remember why we didn’t have written it as `def name: NameType`
in the first place (probably because of path-dependent bugs that were
popping up every now and then when we were developing the first version
of reflection API), but now there are definitely no obstacles to that.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Due to an unfortunate name collision, internal.Symbols#Symbol.isLocal
means something different from Flag.LOCAL. Therefore api.Symbols#Symbol.isLocal
was directly violating its documentation.
Since we can’t give api#isLocal an implementation different from internal#isLocal,
we have to rename, and for that occasion I have come up with names
api#isPrivateThis and api#isProtectedThis, which in my opinion suits the
public API better than internal#isPrivateLocal and internal#isProtectedLocal.
Given the extraordinary circumstances of having no way for api#isLocal
to work correctly, I’m forced to remove api#isLocal without a deprecation
notice, exercising our right to break experimental APIs, something that
we have never done before for reflection or macros. This is sad.
|
|
|
|
|
|
|
| |
Amazingly enough, we've missed the fact that non-type symbols can also
be abstract. Having been enlightened by this, I'm exposing isDeferred
and merging it along with isAbstractType and isAbstractClass into the
unified Symbol.isAbstract method.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Confusing, now-it-happens now-it-doesn't mysteries lurk
in the darkness. When scala packages are declared like this:
package scala.collection.mutable
Then paths relative to scala can easily be broken via the unlucky
presence of an empty (or nonempty) directory. Example:
// a.scala
package scala.foo
class Bar { new util.Random }
% scalac ./a.scala
% mkdir util
% scalac ./a.scala
./a.scala:4: error: type Random is not a member of package util
new util.Random
^
one error found
There are two ways to play defense against this:
- don't use relative paths; okay sometimes, less so others
- don't "opt out" of the scala package
This commit mostly pursues the latter, with occasional doses
of the former.
I created a scratch directory containing these empty directories:
actors annotation ant api asm beans cmd collection compat
concurrent control convert docutil dtd duration event factory
forkjoin generic hashing immutable impl include internal io
logging macros man1 matching math meta model mutable nsc parallel
parsing partest persistent process pull ref reflect reify remote
runtime scalap scheduler script swing sys text threadpool tools
transform unchecked util xml
I stopped when I could compile the main src directories
even with all those empties on my classpath.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
500 lines of generated boilerplate is *impossible to maintain*.
Generated code of this kind should never be allowed.
Three lines of documentation, duplicated 100 times, cannot
masquerade as three hundred lines of documentation. If someone
knows to look at the documentation of implicit ClassTags,
they *already know* about implicit ClassTags. It is wherever
"match" is documented which needs this information (and I am
sure we can express it more clearly, given the luxury of
only saying it once.)
Documenting each ClassTag with the same boilerplate is
comparable in utility to attaching such text to every Int.
"An Int is a whole number within the range -2147483648 to
2147483647 inclusive. It's usually used to represent how
many of something there are, such as '5 bunnies' or '3
witty commit messages', but you can store about anything
in an Int if you can fit it into 32 bits."
We don't do that, because you're expected to discover what
an Int is in a manner which generalizes to all the Ints you
may encounter. The situation with implicit ClassTags is
immediately analogous.
|
|\
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
* origin/2.10.x:
SI-7171 Consider prefix when assessing type finality.
please ant with filenames, add comments
Fixed error in reflection API docs about linearization order on method baseClasses
Shadowed Implict typo (fixes no issue)
remove unused imports
Conflicts:
src/reflect/scala/reflect/internal/Types.scala
|
| |
| |
| |
| | |
baseClasses
|
|/ |
|
| |
|
|
|
|
|
| |
- Added the labels across scala.reflect and scala.reflect.macros
- Added the styling in template.css that is used by all labels
|
| |
|
|
|
|
| |
blocked by SI-6511
|
| |
|
|
|
|
| |
Oh those pretty groups, u gotta luv'em...
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
| |
This matter was discussed at scala-internals:
http://groups.google.com/group/scala-internals/browse_thread/thread/6414d200cf31c357
And I am convinced with Paul's argument: consistency of the convention
is very important.
|
|
|
|
|
| |
The name looks weird in the scaladoc overview panel,
so I decided to do a last-minute rename.
|
|
|
|
|
|
|
|
|
| |
The only place we use something from scala.reflect.io in the public API
is Symbol.associatedFile, so I've excluded scala.reflect.io from scaladoc
and added a "warning: experimental" comment to associatedFile instead.
I'd argue that this greatly simplifies the surface of reflection API
(typing scala.reflect in the search bar now yields 3 packages instead of 4).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
`Symbol.getFlag`, 'Symbol.hasFlag`, `Symbol.hasAllFlags`, `Symbol.annotations`
and `Symbol.privateWithin` now trigger automatic initialization of symbols
if they are used in a runtime reflection universe and some other conditions
are met (see `Symbol.needsInitialize` for details).
As the performance testing in https://github.com/scala/scala/pull/1380 shows,
this commit introduces a ~2% performance regression of compilation speed.
Unfortunately all known solutions to the bug at hand (A, B & C - all of those)
introduce perf regressions (see the pull request linked above for details).
However we're under severe time pressure, so there's no more time to explore.
Therefore I suggest this is reasonable to accept this performance hit,
because we've just gained 6% from removing scala.reflect.base,
and even before that we were well within our performance goal for 2.10.0-final.
|
|\
| |
| | |
Fixes SI-5822 & SI-6305 - OSGi tests + fixes
|
| |
| |
| |
| |
| |
| |
| | |
* migrates scala.tools.nsc.io portions into scala.reflect.io
* marks all classes in scala.reflect.io experimental/internal
* rewires src/reflect to use new io locations
* creates forwarders in scala.tools.nsci.io package object.
|
|/
|
|
|
| |
As the experience has shown, there's no need for a separate layer of reflection
in scala-library.jar. Therefore I'm putting an end to it.
|
|
|
|
| |
Because classes can also be implicit.
|
|
|
|
|
|
|
|
|
| |
Internal face of AnnotationInfos is bound by backward compatibility
with compiler plugins and possibly SBT, but the public face can
be shaped in whatever fashion we like.
Hence I cleaned up the names: AnnotationInfo itself got renamed to
just Annotation, AnnotArgs got renamed to just Arguments and so on.
|
|
|
|
| |
It's clearly redundant and also is susceptible to initialize-based bugs.
|
|
|
|
|
|
| |
Hard to come up with a good name, would need extensive documentation
to justify its purpose => no go. If necessary we can always reintroduce
it later in 2.10.1.
|
|\
| |
| | |
further polishing of reflection
|