| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
| |\ \ \
| | | | |
| | | | | |
Fix SI-8202 and improve support for splicing patterns into vals
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
This commits adds construction-only support for splicing patterns into
vals (a.k.a. PatDef). Due to non-locality of the desugaring it would
have been quite expensive to support deconstruction as the only way to
do it with current trees is to perform implodePatDefs transformation on
every single tree.
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
Previously construction logic used to be in Parsers and deconstruction in
Placeholders making it easy to forget one if you change the other.
|
| | | | | |
|
| |\ \ \ \
| | |_|/ /
| |/| | | |
SI-8266 Deprecate octal escapes in f-interpolator
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
Also turns the f-interpolator into a migration
assistant by suggesting alternatives for the
standard escapes.
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
As per Denys's request, renames methods in ReificationSupport that are
eponymous to methods in Universe, so that we don't get nasty name
intersections.
This change is not source/binary-compatible, because we don't make any
promises about the contents of the build API. Feedback welcome.
|
| | | | | |
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
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 Denys’s request, this commit exposes the hack that we use to
obtain subpatterns of UnApply nodes. This is useful when writing
quasiquoting macros that do pattern matching.
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
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.
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
As per multiple user requests, this commit introduces a shortcut
to typecheck trees under multiple different modes: terms (EXPRmode,
was exposed in Scala 2.10) and types (TYPEmode).
Looking into the rest of a dozen of internal typechecker modes, to the
best of my knowledge, I can’t find other modes that we could expose.
FUNmode is useful, but very situational. PATTERNmode is useful, but
also situational, because we don’t expand macros inside patterns
except for whitebox extractor macros. The rest (e.g. POLYmode or TAPPmode)
are too low-level.
|
|/ / / /
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
Introduces a test that iterates all abstract types in reflection API
and makes sure that every one of them has an associated class tag.
After being introduced, the test has immediately failed exposing
the lack of tags for TreeCopier, Mirror and RuntimeClass, which has been
subsequently fixed in this commit.
|
|/ / /
| | |
| | |
| | |
| | |
| | | |
Previously pq used pattern1 which required parens to be used in
alternative pattern. This commit tweaks it to allow pq"a | b"
syntax. Also adds some tests for alternative syntax.
|
|\ \ \
| | | |
| | | | |
SI-7570 top-level codegen for toolboxes
|
| | | | |
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
Provides a way to inject top-level classes, traits and modules into
toolbox universes.
Previously that was impossible, because compile and eval both wrap their
arguments into an enclosing method of a synthetic module, which makes it
impossible to later on refer to any definitions from the outside.
|
|\ \ \ \
| |_|_|/
|/| | | |
SI-6411 SI-7328 value class fixes for runtime reflection
|
| |/ /
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
The `transformedType` method, which is used to bring Scala types to Java
world, was written in pre-valueclass times. Therefore, this method only
called transforms from erasure, uncurry and refChecks.
Now runtime reflection becomes aware of posterasure and as a consequence
methods, which have value classes in their signatures, can be called
without having to wrap them in catch-a-crash clause.
Another facet to this fix was the realization that value classes need
to be unwrapped, e.g. C(2) needs to be transformed to just 2, when they
are used naked in method signatures (i.e. `c` in `def foo(c: C)` needs
to be unwrapped, whereas `cs: List[C]`, `cs: C*` and even `cs: Array[C]`
do not).
|
|\ \ \
| |_|/
|/| | |
kills resetAllAttrs
|
| | |
| | |
| | |
| | |
| | | |
Now when resetAllAttrs is gone, we can use a shorter name for the one
and only resetLocalAttrs.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
This commit removes resetAllAttrs from the public reflection API.
This method was previously deprecated, but on a second thought that
doesn't do it justice. People should be aware that resetAllAttrs is just
wrong, and if they have code that uses it, this code should be rewritten
immediately without beating around the bush with deprecations. There's
a source-compatible way of achieving that (resetLocalAttrs), so that
shouldn't bring much trouble.
Secondly, resetAllAttrs in compiler internals becomes deprecated. In subsequent
commits I'm going to rewrite the only two locations in the compiler that
uses it, and then I think we can remove it from the compiler as well.
|
|\ \ \
| | | |
| | | | |
SI-8092 More verify for f-interpolator
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
No crazyquoting. Use global.abort on total fail.
Remove unnecessary usage of varargs Apply, per review.
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
A denshish refactor makes the FormatInterpolator a nice bundle
that destructures its input and flattens out the classes to
give the code some elbow room. Everything shifts left.
The `checkType` method is refolded and renamed `pickAcceptable`.
An additional test case captures the leading edge test, that
a % should follow a hole, and which is the most basic
requirement.
|
| | |/
| |/|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Attempt to verify the nooks and crannies of the format string.
Allows all syntax in the javadoc, including arg indexes. If the
specifier after an arg has an index that doesn't refer to the arg,
a warning is issued and the missing `%s` is prepended (just as
for a part with a leading `%n`).
Other enhancements include detecting that a `Formattable` wasn't
supplied to `%#s`.
Error messages attempt to be pithy but descriptive.
|
| | | |
|
| |/
|/|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Such representation codifies the fact that type tree that doesn't have
embedded syntactic equivalent must have been inferred or otherwise
provided by the compiler rather than specified by the end user.
Additionally it also ensures that we can still match trees without
explicit types (e.g. vals without type) after typechecking. Otherwise
the same quote couldn't be used in situations like:
val q"val x = 42" = typecheck(q"val x = 42")
|
|\ \
| | |
| | | |
Fix inconsistent binding in patterns with 10+ holes
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Previously a map that was storing bindings of fresh hole variables with
their contents (tree & cardinality) used to be a SortedMap which had
issues with inconsistent key ordering:
"$fresh$prefix$1" < "$fresh$prefix$2"
...
"$fresh$prefix$8" < "$fresh$prefix$9"
"$fresh$prefix$9" > "$fresh$prefix$10"
This issue is solved by using a LinkedHashMap instead (keys are inserted
in the proper order.)
|
|/ /
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Adds support for patterns like:
val q"{ ..$init; $last }" = q"{ a; b; c }"
// init == List(q"a", q"b")
// last == q"c"
Which under the hood get compiled as `:+` patterns:
SyntacticBlock(init :+ last)
|
|\ \
| | |
| | | |
SI-6844 SI-8076 improve handling of function parameters in quasiquotes
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
This adds support for construction and deconstruction
of implicit argument list which was originally suggested
by @cvogt.
1. Splicing vale into implicit argument list automatically
adds implicit flag to them:
val x = q"val x: Int"
q"def foo(implicit $x)"
// <=> q"def foo(implicit x: Int)"
2. One might extract implicit argument list separately from
other argument lists:
val q”def foo(...$argss)(implicit ..$impl)" =
q"def foo(implicit x: Int)
// argss is Nil, impl contains valdef for x
But this doesn't require you to always extract it separatly:
val q”def foo(...$argss)" =
q"def foo(implicit x: Int)
// argss contains valdef for x
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Previously were a bit too permissive on how splicing in function
parameter position worked. This made confusing things like
possible:
val x = TermName(“x”)
q”def foo($x)”
Now you can either splice trees in that position (ValDefs) or
you have to provide type if you splice a name.
|
|\ \ \
| | | |
| | | | |
SI-7275 allow flattening of blocks with ..$
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
1. Adds tests for new synthetic unit stripping.
2. Marks implementation-specific parts of Holes as private.
3. Trims description of iterated method a bit.
4. Provides a bit more clear wrapper for q interpolator.
5. Refactors SyntacticBlock, adds documentation.
6. Makes q"{ ..$Nil }" return q"" to be consist with extractor.
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
Previous version of the pattern wasn't precise enough due to the
fact that synthetic units are now erased by syntactic block and
this could cause incorrect reification for cases like:
val x = { val y = 1 }
Here syntactic block would extract one element but we still need to
reify it through syntactic block endpoint. So we can't filter based
on the number of elements extracted but rather filter on type of a
tree.
|
| | | | |
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
This commit extends current splicing rules to allow flattening of
trees into other trees.
Without such support it is impossible to correctly create vals with
patterns and use it in other location as they could expand into
multiple-statement blocks:
scala> q"val (a, b) = (1, 2)"
res0: reflect.runtime.universe.Tree =
{
<synthetic> <artifact> private[this] val x$1 = scala.Tuple2(1, 2):
@scala.unchecked match {
case scala.Tuple2((a @ _), (b @ _)) => scala.Tuple2(a, b)
};
val a = x$1._1;
val b = x$1._2;
()
}
scala> q"..$res0; println(a + b)"
res1: reflect.runtime.universe.Tree =
{
<synthetic> <artifact> private[this] val x$1 = scala.Tuple2(1, 2):
@scala.unchecked match {
case scala.Tuple2((a @ _), (b @ _)) => scala.Tuple2(a, b)
};
val a = x$1._1;
val b = x$1._2;
println(a.$plus(b))
}
|
| | | |
| | | |
| | | |
| | | |
| | | | |
New approach makes iterated function much more clear through aggressive
code reuse, recursion and large descriptive comment on top of it.
|
| | |/
| |/|
| | |
| | |
| | |
| | |
| | |
| | | |
This makes it easy to differentiate unit inserted by a compiler vs unit
written by the user. Useful for quasiquotes and pretty printing.
Additionally SyntacticBlock extractor is changed to treat EmptyTree as
zero-element block.
|
|/ / |
|
|\ \
| | |
| | | |
deprecates resetAllAttrs and resetLocalAttrs in favor of the new API
|
| |/
| |
| |
| |
| |
| |
| |
| |
| |
| | |
We now have c.untypecheck, which is supposed to be a counterpart of c.typecheck
in the sense that it goes back from typed trees to untyped ones:
http://stackoverflow.com/questions/20936509/scala-macros-what-is-the-difference-between-typed-aka-typechecked-an-untyped.
Let’s hope that c.untypecheck will soon be able to solve our problems
with partially/incorrectly attributed trees emitted by macros:
https://groups.google.com/forum/#!topic/scala-internals/TtCTPlj_qcQ.
|
| | |
|
|\ \
| | |
| | | |
A few minor changes to standard liftable instances and liftable support
|
| | |
| | |
| | |
| | |
| | | |
Previous ones were inscrutable but thankfully @xeno_by
helped me out to find better alternatives.;
|
| |/
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Previous encoding of Liftables which had universe passed in
as a parameter required a cast to solve path-dependant
madness problems:
trait OldLiftable[T] { def apply(u: Universe, v: T): u.Tree }
In this case compiler wasn't smart enough to find out that
liftFoo(universe, foo)
returns the same type of tree we were working with (universe.Tree)
and we had to cast to make it work:
liftFoo(universe, foo).asInstanceOf[universe.Tree]
Now this cast is redundant as universe is not a parameter of
Liftable's apply.
|
|/
|
|
|
|
|
|
|
|
|
| |
Quasiquotes used to fail to generate proper fresh identifiers for
anonymous functions like:
q"_ + _"
Due to improper initialization of FreshNameCreator in quasiquote
parser which was erroneously not preserved throughout parsing of
the code snippet but re-created on every invocation.
|
|\
| |
| | |
SI-8047 change fresh name encoding in quasiquotes to avoid symbol owner corruption
|