| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
| |
`JavaMirror.constructorToJava` uses `getDeclaredConstructor` now
instead of `getConstructor`.
|
|\
| |
| | |
Deprecate early type defs
|
| |
| |
| |
| |
| |
| | |
This feature is neither properly supported by Scala compiler
nor a part of the language spec and therefore should be removed.
Due to source compatiblity with 2.10 we need to deprecate it first.
|
|\ \
| | |
| | | |
Merge 2.10.x into master
|
| |\ \
| | |/
| |/|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
After the merge, the test/run/t7733 started to fail on Jenkins.
I tried to reproduce it locally but I couldn't so I think it's
system dependent failure. Per @retronym's suggestion I moved it to pending
to not block the whole merge.
Conflicts:
bincompat-backward.whitelist.conf
bincompat-forward.whitelist.conf
src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala
src/compiler/scala/tools/nsc/typechecker/Macros.scala
src/compiler/scala/tools/nsc/typechecker/Namers.scala
src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala
src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
src/compiler/scala/tools/nsc/util/MsilClassPath.scala
src/compiler/scala/tools/reflect/ToolBoxFactory.scala
src/reflect/scala/reflect/internal/ClassfileConstants.scala
src/reflect/scala/reflect/internal/Importers.scala
src/reflect/scala/reflect/internal/Trees.scala
src/reflect/scala/reflect/runtime/JavaMirrors.scala
test/files/run/macro-duplicate/Impls_Macros_1.scala
test/files/run/t6392b.check
test/files/run/t7331c.check
|
| | |\
| | | |
| | | | |
[nomaster] macro expansions are now auto-duplicated
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
The fix still requires macro developers to be careful about sharing trees
by references, because attributed DefTrees will still bring trouble.
However this is an improvement, because it doesn't make matters worse
and automatically fixes situations similar to one in the test.
A much more thorough discussion with a number of open questions left:
http://groups.google.com/group/scala-internals/browse_thread/thread/492560d941b315cc
Was fixed ages ago in master in one of the paradise backports.
Never got to 2.10.x, but it's very useful, so I'm backporting it now.
|
| | |\ \
| | | | |
| | | | | |
SI-7733 reflective packages now more consistent with scalac
|
| | | |/
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
Previously PackageScopes from scala.reflect ignored all classes that
had $'s in non-rightmost positions in their names.
Unfortunately this behaviour is inconsistent with how scalac does things,
and I reconciled this as usual, by pulling corresponding logic into
scala-reflect.jar and sharing it between runtime reflection and compiler.
This change has seprate pull requests for 2.10.x and 2.11.0. The latter
deprecates `scala.tools.nsc.util.ClassPath.isTraitImplementation`
whereas the former (which you're looking at right now) does not, because
we can't deprecated members in minor releases.
|
| | |\ \
| | | | |
| | | | | |
showRaw now prints symbols of def trees
|
| | | | |
| | | | |
| | | | |
| | | | | |
A very useful addition that came in handy when hacking macro annotations
|
| | | |/
| | |/|
| | | |
| | | | |
Another random bug uncovered and extinguished when hacking macro annots.
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
This commit gets rid off code wrapping that was previously used by
toolbox to get into correct parsing mode. Instead combination of
templateStats/accept(EOF) is used. This is the same solution as the one
used in repl and built-in scriptRunner
This pull request doesn't attempt to generalize this approach in any
way and re-use it all over the place due to the caution of possible
accidental compatibility breakage. I plan to do it separately against
master.
Additionally there are a few more changes that make importers be aware
of positions and a test for that (via @jedesah).
|
| | |\ \
| | | | |
| | | | | |
Assorted toolbox fixes
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
Apparently there are still discrepancies between how the vanilla compiler
turns class files into symbols and how the reflective compiler does it.
Working on bringing these guys in sync, one bug at a time.
|
|\ \ \ \ \
| | | | | |
| | | | | | |
SI-7763 Avoid dropping casts in erasure
|
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
Even if the result isn't used, the potential ClassCastException
is observable, so we must retain them.
|
| |/ / / /
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
466b7d29f avoided quadratic complexity in Erasure's treatment
of chained `asInstanceOf` calls. It did so by using the typechecked
qualifier, rather than discarding it.
However, that also dropped the cast altogether! In many cases this
was masked by later inclusion of a cast to the expected type
by `adaptToType`:
at scala.tools.nsc.transform.Erasure$Eraser.cast(Erasure.scala:636)
at scala.tools.nsc.transform.Erasure$Eraser.scala$tools$nsc$transform$Erasure$Eraser$$adaptToType(Erasure.scala:665)
at scala.tools.nsc.transform.Erasure$Eraser.adapt(Erasure.scala:766)
at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5352)
This commit re-wraps the typechecked `qual` in its original
`<qual>.asInstanceOf[T]` to preserve semantics while avoiding
the big-O blowup.
The test includes the compiler option `-Ynooptimize` because dead code
elimination *also* thinks that this cast is superfluous. I'll follow up
on that problem seprately.
|
|\ \ \ \ \
| |/ / / /
|/| | | | |
(1 of 2) of the rest of the new bytecode emitter + feedback
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
GenBCode runs only under a flag, and moreover only if -optimise
is not present (see ScalaSettings for details).
Therefore during a nightly, when tests are run under -optimise,
we need -Ynooptimise to deactivate the optimizer.
With that, GenBCode can run and tackle the test case successfuly.
|
|/ / / /
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
As partest is now resolved from maven, `test/partest` uses `ant test.suite.init`
to determine the classpath (serialized to build/pack/partest.properties)
that's necessary to run `scala.tools.partest.nest.ConsoleRunner`.
Thus, partest gets exactly the same classpath, whether run from
the command line through `test/partest` or via `ant test`.
The version of partest we're using is specified by
properties defined in versions.properties (formerly `starr.number`).
Currently, we're using:
```
scala.binary.version=2.11.0-M4
partest.version.number=1.0-RC3
```
NOTES:
- The version of Scala being tested must be backwards binary compatible with
the version of Scala that was used to compile partest.
- Once 2.11 goes final, `scala.binary.version=2.11`, and `starr.version=2.11.0`.
- Need scalacheck on classpath for test/partest scalacheck tests.
- Removed atrophied ant tests (haven't been run/changed for at least two years
I checked 81d659141a as a "random" sample).
- Removed scalacheck. It's resolved as a partest dependency.
- For now, use a locally built scalap
- Kept the trace macro in the main repo (partest-extras)
- New targets for faster pr validation: test-core-opt, test-stab-opt
- Reused partest eclipse/intellij project to partest-extras
(note: the partest dependency is hard-coded)
|
|\ \ \ \
| | | | |
| | | | | |
SI-7740 Trim stack trace before printing in REPL
|
| | | | | |
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
Can't finnesse the drop method. Call it blindly for now, even
though in the long run you won't have to write drop.
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
There are a lot of details yet to be ironed out when it comes
to sequences, but at least here's a little evidence that the basic
mechanisms work.
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
Establishes a pattern that can be used to implement extractor macros
that give the programmer control over signatures of unapplications
at compile-time.
=== The pattern ===
In a nutshell, given an unapply method (for simplicity, in this
example the scrutinee is of a concrete type, but it's also possible
to have the extractor be polymorphic, as demonstrated in the tests):
```
def unapply(x: SomeType) = ???
```
One can write a macro that generates extraction signatures for unapply
on per-call basis, using the target of the calls (c.prefix) and the type
of the scrutinee (that comes with x), and then communicate these signatures
to the typechecker.
For example, here's how one can define a macro that simply passes
the scrutinee back to the pattern match (for information on how to
express signatures that involve multiple extractees, visit
https://github.com/scala/scala/pull/2848).
```
def unapply(x: SomeType) = macro impl
def impl(c: Context)(x: c.Tree) = {
q"""
new {
class Match(x: SomeType) {
def isEmpty = false
def get = x
}
def unapply(x: SomeType) = new Match(x)
}.unapply($x)
"""
}
```
In addition to the matcher, which implements domain-specific
matching logic, there's quite a bit of boilerplate here, but
every part of it looks necessary to arrange a non-frustrating dialogue
with the typer. Maybe something better can be done in this department,
but I can't see how, without introducing modifications to the typechecker.
Even though the pattern uses structural types, somehow no reflective calls
are being generated (as verified by -Xlog-reflective-calls and then
by manual examination of the produced code). That's a mystery to me, but
that's also good news, since that means that extractor macros aren't
going to induce performance penalties.
Almost. Unfortunately, I couldn't turn matchers into value classes
because one can't declare value classes local. Nevertheless,
I'm leaving a canary in place (neg/t5903e) that will let us know
once this restriction is lifted.
=== Use cases ===
In particular, the pattern can be used to implement shapeshifting
pattern matchers for string interpolators without resorting to dirty
tricks. For example, quasiquote unapplications can be unhardcoded now:
```
def doTypedApply(tree: Tree, fun0: Tree, args: List[Tree], ...) = {
...
fun.tpe match {
case ExtractorType(unapply) if mode.inPatternMode =>
// this hardcode in Typers.scala is no longer necessary
if (unapply == QuasiquoteClass_api_unapply) macroExpandUnapply(...)
else doTypedUnapply(tree, fun0, fun, args, mode, pt)
}
}
```
Rough implementation strategy here would involve writing an extractor
macro that destructures c.prefix, analyzes parts of StringContext and
then generates an appropriate matcher as outlined above.
=== Implementation details ===
No modifications to core logic of typer or patmat are necessary,
as we're just piggybacking on https://github.com/scala/scala/pull/2848.
The only minor change I introduced is a guard against misbehaving
extractor macros that don't conform to the pattern (e.g. expand into
blocks or whatever else). Without the guard we'd crash with an NPE,
with the guard we get a sane compilation error.
|
| | | | | |
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
An extractor is no longer required to return Option[T], and
can instead return anything which directly contains methods
with these signatures:
def isEmpty: Boolean
def get: T
If the type of get contains methods with the names of
product selectors (_1, _2, etc.) then the type and arity
of the extraction is inferred from the type of get. If
it does not contain _1, then it is a single value
extractor analogous like Option[T].
This has significant benefits and opens new territory:
- an AnyVal based Option-like class can be used which
leverages null as None, and no allocations are necessary
- for primitive types the benefit is squared (see below)
- the performance difference between case classes and
extractors should now be largely eliminated
- this in turn allows us to recapture great swaths of
memory which are currently squandered (e.g. every
TypeRef has fields for pre and args, even though these
are more than half the time NoPrefix and Nil)
Here is a primitive example:
final class OptInt(val x: Int) extends AnyVal {
def get: Int = x
def isEmpty = x == Int.MinValue // or whatever is appropriate
}
// This boxes TWICE: Int => Integer => Some(Integer)
def unapply(x: Int): Option[Int]
// This boxes NONCE
def unapply(x: Int): OptInt
As a multi-value example, after I contribute some methods to TypeRef:
def isEmpty = false
def get = this
def _1 = pre
def _2 = sym
def _3 = args
Then it's extractor becomes
def unapply(x: TypeRef) = x
Which, it need hardly be said, involves no allocations.
|
|/ / / / |
|
|\ \ \ \
| | | | |
| | | | | |
kills introduceTopLevel
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
As we've figured out from the practice, introduceTopLevel is seductively
useful but unfortunately not robust, potentially bringing compilation
order problems.
Therefore, as discussed, I'm removing it from the public macro API.
Alternatives are either: 1) delving into internals, or
2) using macro paradise and experimenting with macro annotations:
http://docs.scala-lang.org/overviews/macros/annotations.html.
|
|\ \ \ \ \
| | | | | |
| | | | | | |
SI-6507 do not call .toString on REPL results when :silent is on.
|
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
Member handlers used to always call .toString on REPL results, even when
:silent was on, which could force evaluation or cause unwanted side
effects.
This forwards the current value of `printResults` to the member
handlers (through Request) for them to decide what to do when the
results must not be printed.
2 handlers now do not return any extraction code when silent:
- ValHandler, so that it doesn't call toString on the val
- Assign, so that it doesn't call toString on the right-hand side
of the assignement.
|
|\ \ \ \ \ \
| | | | | | |
| | | | | | | |
SI-7630 [Avian] Skip test run/repl-javap-outdir-funs on Avian
|
| | |/ / / /
| |/| | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
The test fails, because the REPL command reports that no anonfuns were
found. I have spent a considerable amount of time to figure out what's
the issue here with no success.
Skip it for now, so that we don't lose sight of the big picture.
|
|\ \ \ \ \ \
| | | | | | |
| | | | | | | |
SI-7564 [Avian] Whitespace fixes to run/tailcalls.check
|
| | |/ / / /
| |/| | | |
| | | | | |
| | | | | |
| | | | | | |
Looks like the differences in the whitespace caused the test to fail
on Avian.
|
|\ \ \ \ \ \
| | | | | | |
| | | | | | | |
updated SI-7331, SI-6843, SI-7731, parser entry point refactoring, assertThrows utility function
|
| |/ / / / /
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
Change toolbox parsing to use `parseStats` parser entry point
instead of current code-wrappign technique that makes positions
much less useful to end users.
There is also no need to create a compiler `Run` for parsing.
|
|\ \ \ \ \ \
| | | | | | |
| | | | | | | |
SI-7715 String inpatternation s"$_" for s"${_}"
|
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | | |
In a pattern,
```
scala> implicit class RX(val sc: StringContext) {
| def rx = sc.parts.mkString("(.+)").r }
defined class RX
scala> "2 by 4" match { case rx"$a by $_" => a }
res0: String = 2
scala> val rx"$_ by $b" = "2 by 4"
b: String = 4
```
|
|\ \ \ \ \ \ \
| | | | | | | |
| | | | | | | | |
SI-7470 implements fundep materialization
|
| |/ / / / / /
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | | |
This fix provides implicit macros with an ability to affect type inference
in a more or less sane manner. That's crucial for materialization of
multi-parametric type class instances (e.g. Iso's from shapeless).
Details of the technique can be found in comments.
|
|\ \ \ \ \ \ \
| |_|_|/ / / /
|/| | | | | | |
SI-7544 Interpolation message for %% literal
|
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | | |
Since interpolator args are of type Any, it's easy
to write s(args) instead of s(args: _*). I wonder
if Xlint would have warned me about that.
|
| |/ / / / / |
|
|\ \ \ \ \ \
| |_|/ / / /
|/| | | | | |
SI-7265 javaSpecVersion, adjust isJava... tests for 2.11
|
| |/ / / /
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
Make this and related properties public, because they
are useful.
This change ought to have been committed at 2.11 and then
backported with restrictions, rather than vice-versa.
Note that they are defined in the order, version, vendor
and name, which is the order from the underlying javadoc.
It would be a neat feature of the PR validator, as previously
imagined, to run a "pending" test and then, on success and
merge, to move it automatically to the canonical suite.
|
|/ / / /
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
Check files split into conditional blocks with partest flags
have been broken since the new diff regime.
For some reason, no one noticed.
The clever scheme to "filter the diff" instead of just filtering
the check file is abandoned as futile and unnecessary.
Fix java6 checkfile for ifdiff fix.
|
|\ \ \ \ |
|