| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Unlike module classes that are going to be pickled (which are reified
as `<their module reification>.moduleClass), module classes of
local modules need to be reified as symbol defs.
Otherwise we get a stack overflow:
1) Local modules are deemed to be free terms,
2) All free symbols are reified together with their type signature (so that they
can be a) inspected by anyone interested, b) compiled at runtime),
3) Reifying a type signature of a module involves reifying its module class,
4) Reifying a module class involves reifying a module and calling its module class,
<ad infinitum>
This stack overflow doesn't happen for locatable modules, because they don't need
to have their type signatures reified (these signatures can later be loaded from
pickles if it becomes necessary).
|
|\
| |
| | |
Removes AnyRef specialization from library
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
As discussed in #999, #1025 and
https://groups.google.com/forum/?hl=en&fromgroups#!topic/scala-internals/5P5TS9ZWe_w
instrumented.jar is generated from the current source, there's no need
for a bootstrap commit.
Review by @paulp.
|
|\ \
| | |
| | | |
Ultimate reflection pull request #2
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Since Scala reflection relies on Java reflection to perform member invocations,
it inherits some of the quirks of the underlying platform.
One of such quirks is returning null when invoking a void-returning method.
This is now fixed by introducing a check after calling invoke.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Previously `checkMemberOf` was blocking base fields and methods
that are overriden in receiver.getClass. Now this is fixed.
The fix also uncovered an issue with field mirrors. Currently
their `get` and `set` methods don't respect overriding and always
return field values from a base class.
After discussing this on a reflection meeting, we decided that this
behavior is desirable and that for overriding people should use
reflectMethod and then apply on getters/setters. See the discussion at:
https://github.com/scala/scala/pull/1054.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
In 911bbc4 I've completely overlooked the fact that
reflectConstructor exists and that is also needs sanity checks.
Now reflectConstructor checks that the incoming symbol is actually a ctor,
and that it is actually a ctor of the class reflected by the current mirror.
|
| | |
| | |
| | |
| | |
| | | |
Arguments provided in by-name positions are now automatically wrapped
in Function0 instances by method mirrors.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
mirrors now carry a class tag of the receiver, so that they can detect
value classes being reflected upon and adjust accordingly (e.g. allow
Int_+ for ints, but disallow it for Integers).
Surprisingly enough derived value classes (SIP-15 guys that inherit from AnyVal)
have been working all along, so no modification were required to fix them.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
In Scala there are some methods that only exist in symbol tables,
but don't have corresponding method entries in Java class files.
To the best of my knowledge, these methods can be subdivided into five groups:
1) stuff weaved onto Any, AnyVal and AnyRef (aka Object),
2) magic methods that Scala exposes to fix Java arrays,
3) magic methods declared on Scala primitive value classes,
4) compile-time methods (such as classOf and all kinds of macros),
5) miscellaneous stuff (currently only String_+).
To support these magic symbols, I've modified the `checkMemberOf` validator
to special case Any/AnyVal/AnyRef methods and adjusted MethodMirror and
ConstructorMirror classes to use special invokers for those instead of
relying on Java reflection.
Support for value classes will arrive in the subsequent commit, because
it requires some unrelated changes to the mirror API (currently mirrors
only support AnyRefs as their targets).
|
|\ \ \
| |_|/
|/| | |
SI-5788 Tailcalls LabelDefs correctly duplicated
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
... in specialization.
This is a quick hack to get SI-5788 fixed in 2.10.x. The full patch,
which fixes the tailcalls LabelDefs will be merged into trunk, as it's
too late for big changes.
For reference, the complete fix is: e86afe65c8
|
|\ \ \
| | | |
| | | | |
SI-6063, SI-4945 and restore :warnings in the REPL
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
As seen here.
scala> class A { @deprecated("foo") def a = 1 }
warning: there were 1 deprecation warnings; re-run with -deprecation for details
defined class A
scala> :warnings
<console>:7: warning: @deprecated now takes two arguments; see the scaladoc.
class A { @deprecated("foo") def a = 1 }
^
scala> val x = 5 toString
warning: there were 1 feature warnings; re-run with -feature for details
x: String = 5
scala> :warnings
<console>:7: warning: postfix operator toString should be enabled
by making the implicit value language.postfixOps visible.
This can be achieved by adding the import clause 'import language.postfixOps'
or by setting the compiler option -language:postfixOps.
See the Scala docs for value scala.language.postfixOps for a discussion
why the feature should be explicitly enabled.
val x = 5 toString
^
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
Other breakage had accumulated among Settings. I determined
that once upon a time, "MultiStringSetting" accepted arguments
like this:
scala -foo bip bop bar
Somewhere this was changed to force a : argument, like
scala -foo:bip,bop,bar
This incurs breakage. The repl has always advertised its -i
option without a colon and it has always been a MultiStringSetting.
Forcing everything into the : seemed like the wrong thing,
especially because it will stomp on any whitespace containing
arguments, whereas in the original form
scala -foo bip "bop bar" baz
will yield its arguments as given.
So lacking any good ideas and knowing something probably depends
on each way already, I made it work both ways.
|
| | |/
| |/|
| | |
| | | |
Have to rule out access boundaries as well as private/protected.
|
|\ \ \
| |/ /
|/| | |
SI-6102 Wrong bytecode in lazyval + no-op finally clause
|
| |/ |
|
|\ \
| |/
|/| |
SI-6188
|
| | |
|
| | |
|
|\ \
| |/
|/| |
SI-6175 reflect over classes with symbolic names
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Top-level classes with symbolic names (having binary names like $colon$colon)
have previously been incorrectly treated as local classes by Scala reflection.
As a result they were loaded as if they weren't pickled (i.e. as Java classes).
Moreover this bug also had a more subtle, but more dangerous manifestation.
If such a class has already been loaded indirectly by unpickling another class
(which refers to it in its pickle) and then someone tried to load it explicitly
via classToScala, then it would be loaded twice (once as a Scala artifact and
once as a Java artifact). This is a short route to ambiguities and crashes.
The fix first checks whether a class with a suspicious name (having dollars)
can be loaded as a Scala artifact (by looking it up in a symbol table).
If this fails, the class is then loaded in Java style (as it was done before).
Ambiguous names that can be interpreted both ways (e.g. foo_$colon$colon)
are first resolved as Scala and then as Java. This prioritization cannot lead
to errors, because Scala and Java artifacts with the same name cannot coexist,
therefore loading a Scala artifact won't shadow a homonymous Java artifact.
|
|\ \
| | |
| | | |
SI-6074 disallow implicit enrichment with constructor
|
| | |
| | |
| | |
| | |
| | | |
When selecting a non-accessible constructor, don't infer a view to
something with an accessible constructor.
|
|\ \ \
| | | |
| | | | |
Promote unchecked warnings into being emitted by default.
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
To make that viable, suppression of unchecked warnings is now available
on a per-type-argument basis. The @unchecked annotation has hereby been
generalized beyond exhaustiveness to mean context-dependent "disable further
compiler checking on this entity." Example of new usage:
def f(x: Any) = x match {
case xs: List[String @unchecked] => xs.head // no warning
case xs: List[Int] => xs.head // unchecked warning
}
It turns out -unchecked has been put to other noisy uses such as
the pattern matcher complaining about its budget like a careworn spouse.
This actually simplified the path forward: I left -unchecked in place
for that and general compatibility, so those warnings can be enabled
as before with -unchecked. The erasure warnings I turned into regular
warnings, subject to suppression by @unchecked.
Review by @odersky.
|
|\ \ \ \
| | | | |
| | | | | |
Fix for SI-6084, type alias crasher.
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
"no need for pt.normalize here, is done in erasure"
ORLY? Review by @adriaanm.
|
|\ \ \ \ \
| | | | | |
| | | | | | |
Fixes SI-6172.
|
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
All the credit for fixing magical constants in the encoding algorithm goes to @magarciaEPFL.
This time provided a test case that exercises GenASM.
|
| |_|_|/ /
|/| | | | |
|
|\ \ \ \ \
| |_|_|_|/
|/| | | | |
SI-5930 SI-5897 reduce redundant warnings in matches, fix flags usage
|
| | | | | |
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
the pattern matching analysis should be more precise anyway
(don't warn twice)
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
Instead of trying to serialize the entire universe and failing miserably
(which happens now), exprs and type tags will now serialize their creators
and deserialize into scala.reflect.basis.
Since creators produced by reification are not serializable right now,
serialization will crash. That's a small improvement over state of the art
functionality-wise, but it's a step forward robustness-wise.
Next step in this direction is generation of serialization code for creators.
Related issues: SI-5919 and SI-5908. Also see the discussion at scala-internals
http://groups.google.com/group/scala-internals/browse_thread/thread/ef63f8b5bd194c7c
|
| | | | |
| | | | |
| | | | |
| | | | | |
Removes the stubs left out to appease the old starr, fixes macro tests.
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
These options were meant to be used to bootstrap macros defined in our codebase
However we can bootstrap perfectly without any additional effort, because
library classpath classloader can delegate to tool classpath classloader to
load macro implementations from starr.
Since then (for several months) this functionality hasn't proven to be useful,
neither anyone on the mailing list or stackoverflow asked questions about it
(even despite it was explicitly mentioned in the "cannot load macro impl"
error message).
Hence I suggest that it is totally unnecessary and should be removed.
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
Added a bunch of test methods to symbols to cover public flags:
(e.g. isPrivate, isFinal, isOverride, isImplicit, etc). I'd argue that
the API duplication w.r.t flag sets is trumped by unified interface
to tests and better encapsulation.
Also updated the API to be easier to understand after prior exposure
to Java or .NET reflection APIs:
1) Added typeParams to TypeSymbol and ClassSymbol.
2) Renamed MethodSymbol.resultType to returnType.
3) Removed the distinction between MethodSymbol.params vs MethodSymbol.allParams
now we just have MethodSymbol.params: List[List[Symbol]].
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
Adds informative toString for InstanceMirror, FieldMirror,
MethodMirror (for methods and constructors), ClassMirror and ModuleMirror.
Universe mirrors (e.g. JavaMirrors or compiler mirrors) already have good
toString methods that show their affiliation and/or classpaths.
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
This renaming arguably makes the intent of `asType` more clear,
but more importantly it shaves 6 symbols off pervasive casts that
are required to anything meaningful with reflection API
(as in mirror.reflectMethod(tpe.member(newTermName("x")).asMethodSymbol)).
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
1) Removed unnecessary (i.e. implementable with pattern matching) type APIs.
2) Renamed isHigherKinded to takesTypeArgs making it easier to understand.
2) typeParams and resultType have been moved from MethodType to MethodSymbol
Strictly speaking they are superfluous, but they are used very often.
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
This works around SI-5736 that's been deemed too risky to be fixed in 2.10.0.
A reflection newbie will be unlikely to acquire a field symbol from its name,
but the `accessed` method provides an easy way to navigate to it from a getter.
|
| |/ / /
|/| | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
Firstly this unifies the reflection API - now both decls and members
return Scope (not Scope and List[Symbol] as it were before).
Secondly this fixes SI-5732 without having to sort the result of members.
Type.members now returns Scope, a distinguished type, which has the
`sorted` method, which does the required sorting if necessary.
Also removes nonPrivateMembers and nonPrivateDeclarations to keep the API
minimalistic (as can be seen from their implementation in internal.Types
they are just members and decls with bridges and private members removed).
|
|\ \ \ \
| | | | |
| | | | | |
SI-5751 cleans up toolboxes for the release
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
Removes the `freeTypes` parameters on `typeCheckExpr` and `runExpr`,
since we now have public `substituteTypes` on both trees and types.
Also implements long-awaited `inferImplicitValue` and `inferImplicitView`
(thanks to Miles Sabin for nudging me!)
|
|\ \ \ \ \
| |/ / / /
|/| | | | |
Fixed maddening "..." lately in printed types.
|
| | |/ /
| |/| |
| | | |
| | | |
| | | |
| | | | |
I screwed around with type printing for a long time and now I have
to be done, so I suggest we accept the imperfection in here for now
because it's still way ahead of "..." as types go.
|
|\ \ \ \
| | | | |
| | | | | |
SI-5866 Support casting null to value classes
|
| | | | |
| | | | |
| | | | |
| | | | | |
The fix now supports null.asInstanceOf[C] where C is a value class that wraps a primitive type.
|