| Commit message (Collapse) | Author | Age | Files | Lines |
|\
| |
| | |
@compileTimeOnly: moved to scala-library.jar, got some fixes
|
| |
| |
| |
| |
| | |
Now that @compileTimeOnly is part of the standard library, why don't
we use it within the standard library.
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This is the notion that's come to be universally useful, so I suggest
we promote it to be universally accessible.
Note that the attached test incorrectly fails to report errors for
definitions coming from the empty package and for annotations. These
are bugs, and they are fixed in subsequent commits of this pull request.
|
|\ \
| | |
| | |
| | |
| | |
| | | |
Conflicts:
src/compiler/scala/tools/nsc/Global.scala
src/compiler/scala/tools/nsc/transform/patmat/MatchTranslation.scala
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Historically calling NoSymbol.owner has crashed the compiler.
With this commit, NoSymbol owns itself. This is consistent with
the way ownership chains are handled elsewhere in the compiler
(e.g. NoContext.owner is NoContext, NoSymbol.enclClass is
NoSymbol, and so on) and frees every call site which handles
symbols from having to perform precondition tests against
NoSymbol.
Since calling NoSymbol.owner sometimes (not always) indicates
a bug which we'd like to catch sooner than later, I have
introduced a couple more methods for selected call sites.
def owner: Symbol // NoSymbol.owner is self, log if -Xdev
def safeOwner: Symbol // NoSymbol.owner is self, ignore
def assertOwner: Symbol // NoSymbol.owner is fatal
The idea is that everyone can call sym.owner without undue anxiety
or paranoid null-like tests. When compiling under -Xdev calls to
`owner` are logged with a stack trace, so any call sites for which
that is an expected occurrence should call safeOwner instead to
communicate the intention and stay out of the log. Conversely, any
call site where crashing on the owner call was a desirable behavior
can opt into calling assertOwner.
This commit also includes all the safeOwner calls necessary to
give us a silent log when compiling scala.
|
| | |
| | |
| | |
| | |
| | |
| | | |
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.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
This fleshes out some of the slightly unfinished corners
of the adventure, especially for unapplySeq. There's still
an unhealthy amount of duplication and a paucity of
specification, but I think it's in eminently good shape
for a milestone.
|
| | |
| | |
| | |
| | |
| | | |
This makes it a lot less error prone and redundant to find the
part you need when unwrapping an UnApply tree.
|
| | | |
|
| | | |
|
| | |
| | |
| | |
| | | |
Motivated by pattern matcher work, also useful elsewhere.
|
| | | |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
It's a source of constant peril that sym.tpe on NoSymbol
is fine (it's NoType) but tpe memberType sym on NoSymbol throws
a NSDNHO. The last thing we should be doing is discouraging
people from using memberType in favor of sym.tpe, the latter
being almost always the wrong thing.
|
| | | |
|
|/ / |
|
|\ \
| | |
| | | |
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.
|
|\ \ \
| |/ /
|/| | |
updated SI-7331, SI-6843, SI-7731, parser entry point refactoring, assertThrows utility function
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Previously setPos, pos_=, setType, tpe_= all behaved inconsistently
between each other even though they all represent similar
attributes that cannot be changed on CannotHaveAttrs trees.
In order to simplify handling of such trees in compiler code each
of these fields now supports assignment to its current default
value: NoType for tpe and NoPosition for pos. Such assignments
don't mutate underlying trees.
|
| | | |
|
| | |
| | |
| | |
| | |
| | | |
in various places. This includes actors, compiler (mostly some new
macro parts) continuations, partest, scaladoc, scalap.
|
|/ /
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
I added a language.existential import to LazyCombiner.scala which
should not be necessary, but causes a spurious warning otherwise:
scala/src/library/scala/collection/parallel/mutable/LazyCombiner.scala:33:
warning: the existential type
scala.collection.parallel.mutable.LazyCombiner[_$1,_$2,_$3] forSome {
type _$1; type _$2; type _$3 <: scala.collection.generic.Growable[_$1] with scala.collection.generic.Sizing },
which cannot be expressed by wildcards, should be enabled by making the implicit value scala.language.existentials visible.
if (other.isInstanceOf[LazyCombiner[_, _, _]]) {
^
I created ticket SI-7750 to track this issue.
|
|\ \
| | |
| | | |
Making map2Conserve occupy constant stack space in spirit of SI-2411.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
I recently discovered a StackOverflowError, caused by this function:
https://gist.github.com/folone/7b2f2e2a16314ab28109
The circumstances are pretty extreme, still having a tail-recursive
function seems to be a good idea.
The function behaves the same way old function did (supported by tests),
which is not really how map2 behaves. I did not change this behavior to
not introduce any regression. I actually tried to make it behave like map2,
and it does introduce regression.
|
| |/ |
|
|/
|
|
|
| |
Now when there's no hope left for type macros, it's reasonable to provide
a more specific type for DefDef.name.
|
|\
| |
| | |
Refactor the cake so SymbolTable does not depend on Global
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This is rather large commit so I'll first explain the motivation
behind it and then go through all changes in detail explaining
the choices I made.
The motivation behind this refactoring was to make SymbolTable
unit testable. I wanted a lightweight way of initializing
SymbolTable and then writing unit tests for subtyping algorithm,
various functionality related to Symbols, etc.
All of that should be possible by precisely controlling what we
test, e.g., create types and symbols by hand and not have them
defined in source code as we normally do in partest (functional)
tests.
The other motivation was to reduce and clarify dependencies we
have in the compiler. Explicit dependencies lead to cleaner
design. Also, explicit and reduces dependencies help incremental
compilation which is a big problem for us in compiler's code
base at the moment.
One of the challenges I faced during that refactoring was
cyclic dependency between Platform and SymbolLoaders.
Platform depended on `SymbolLoaders.SymbolLoader` because it
would define a root loader. SymbolLoaders depended on Platform
for numerous reasons like deferring decision how to load a given
symbol based on some Platform-specific hooks.
I decided to break that cycle by removing methods related to
symbol loading from Platform interface. One could argue, that
better fix would be to make SymbolLoaders to not depend on Platform
(backend) concept but that would be much bigger refactoring. Also,
we have a new concept for dealing with symbol loading: Mirrors.
For those reasons both `newClassLoader` and `rootLoader`
were dropped from Platform interface.
Note that JavaPlatform still depends on Global so it can
access phases defined in Global to implement `platformPhases`
method.
Both GenICode and BCodeBodyBuilder have some Platform specific
logic that requires casting because pattern matcher doesn't narrow
types to give them a proper refinement. Check the changes for details.
Some logging utilities has been moved from Global to SymbolTable
because they are accessed by SymbolTable. Since Global inherits from
SymbolTable this should be a source compatible change.
The SymbolLoaders has dependency on `compileLate` method defined in Global.
The purpose behind `compileLate` is not clear to me but the dependency looks
a little bit dubious. At least we made that dependency explicit.
ScaladocGlobal and Global defined in interactive has been adapted in a way
that makes them compile both with quick.comp and 2.11.0-M4 so my refactorings
are not blocking the modularization effort.
|
|\ \
| | |
| | | |
Improve type printing (toString/debugging)
|
| | | |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
More consistency as to how to understand aliases,
singletons, specialized symbols, subclasses. Fewer
weird special casings, like normalizing tuples
and functions during type printing, but nothing else.
I avoid "normalize" entirely now, and do not make
special cases for dealiasing, which is already well
handled when printing error messages.
Look at the change to test/files/neg/t2641.check to get
a sense of why we should resist calling normalize during
the early days of a compilation run.
Anonymous and refinement classes can be printed far more
usefully by revealing their parents, and that too is here.
Hardened toString against undesirable side effects.
Make toString final to discourage any further rogue
toString overriders. Make safeToString a little safer.
|
|\ \ \
| | | |
| | | | |
SI-7681 Remove Phases, clean up TableDef
|
| | |/
| |/|
| | |
| | | |
... now that scala.tools.nsc.Phases is gone.
|
|/ / |
|
|/
|
|
|
| |
ClassfileAnnotArg becoming sealed brought tidings of not being
exhaustive.
|
|
|
|
|
|
|
|
| |
10229316db allowed macro impls to take and return values of type c.Tree
in addition to the usual c.Expr. However it didn't take into account that
it is often useful to return subtypes of trees (e.g. with quasiquotes
that expand into expressions typed as precisely as possible). This patch
fixes that oversight.
|
|
|
|
|
| |
This will help the pattern matcher to emit better code for this kind
of extractor that does nothing but wrap the extractee.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
- Additions to the reflection API:
- The Quasiquotes implicit class that defines `q`, `tq`, `pq` and `cq`
interpolators which now become a part of the `scala.reflect.api.
Universe`.
- Implementations of the interpolators are macro-based
and are hardwired through `FastTrack`.
- The `Liftable` class and the `StandardLiftables` slice of the cake
that provide a type class and a bunch of its instances that allow
to easily splice user-defined types into quasiquotes.
- Additional methods in `BuildUtils` that are used by the quasiquote
macro to generate trees, notably:
- `SyntacticClassDef`. An extractor/constructor that allows to
construct and deconstruct classes using arguments that mirror
syntactic form of ClassDefs (e.g. constructor outside of the
body).
- `TupleN`, `TupleTypeN`. Extractor/constructor for easy
construction of ast that represents a tuple term or type
with given amount of elements.
- Actual implementation of quasiquotes in the `scala.tools.reflect.
quasiquotes` package which is organized into a cake called
`Quasiquotes` with slices introducing core abstractions necessary to
splice into Scala syntax, routines for interfacing with the parser,
and customized reifiers for tree construction and deconstruction.
|
|
|
|
|
| |
This routine is going to be necessary in scala-reflect.jar to support
ClassDef construction/deconstruction in the upcoming quasiquote patch.
|
|\
| |
| | |
Lint-like fixes found by Semmle
|
| | |
|
| | |
|
| | |
|
|\ \
| | |
| | | |
new bytecode emitter, GenBCode (11th attempt)
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
GenBCode is a drop-in replacement for GenASM with several advantages:
- faster: ICode isn't necessary anymore.
Instead, the ASTs delivered by CleanUp (an expression language)
are translated directly into a stack-language (ASM Tree nodes)
- future-proofing for Java 8 (MethodHandles, invokedynamic).
- documentation included, shared mutable state kept to a minimum,
all contributing to making GenBCode more maintainable
than its counterpart (its counterpart being GenICode + GenASM).
A few tests are modified in this commit, for reasons given below.
(1) files/neg/case-collision
Just like GenASM, GenBCode also detects output classfiles
differing only in case. However the error message differs
from that of GenASM (collisions may be show in different order).
Thus the original test now has a flags file containing -neo:GenASM
and a new test (files/neg/case-collision2) has been added
for GenBCode. The .check files in each case show expected output.
(2) files/pos/t5031_3
Currently the test above doesn't work with GenBCode
(try with -neo:GenBCode in the flags file)
The root cause lies in the fix to
https://issues.scala-lang.org/browse/SI-5031
which weakened an assertion in GenASM
(GenBCode keeps the original assertion).
Actually that ticket mentions the fix is a "workaround"
(3) files/run/t7008-scala-defined
This test also passes only under GenASM and not GenBCode,
thus the flags file. GenASM turns a bling eye to:
An AbstractTypeSymbol (SI-7122) has reached the bytecode emitter,
for which no JVM-level internal name can be found:
ScalaClassWithCheckedExceptions_1.E1
The error message above (shown by GenBCode) highlights
there's no ScalaClassWithCheckedExceptions_1.E1 class,
thus shouldn't show up in the emitted bytecode
(GenASM emits bytecode that mentions the inexistent class).
|
|\ \ \
| | | |
| | | | |
SI-7584 Fix typer regression with by-name parameter types
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
The enclosed test case exercises by-name closures, which were
the subject of the previous commit. In the process, a spurious
warning was eliminated.
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
It regressed in fada1ef6b#L4L614. Partially reverting just
this change restores the correct behaviour:
```
- if (sym.isStable && pre.isStable && !isByNameParamType(tree.tpe) &&
+ if (treeInfo.admitsTypeSelection(tree) &&
```
This patch embeds the check for by-name parameter types into
`TreeInfo.isStableIdentifier`. That code already checks for
`Symbol#isStable`, which exludes direct references to by-name
parameters. But the additional check is required to deal with
by-name parameters in function types, e.g `(=> Int) => Any`.
Open question: should we go further and embed this check in `isStable`?
Currently:
final def isStable = isTerm && !isMutable && !(hasFlag(BYNAMEPARAM)) && (!isMethod || hasStableFlag)
Such function types are an underspecified corner of the language,
albeit one that is pretty useful writing, for example, in the
signature of a lazy foldRight that can operate over infinite
structures:
def foldRight[A, B](fa: F[A], z: => B)(f: (A, => B) => B): B
The next commit subjects them to a little testing.
|
|\ \ \ \
| |_|_|/
|/| | | |
Spin off xml library as scala-library-xml.
|
| |/ /
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
When there's no Predef.$scope but xml is being used,
the compiler aliases scala.xml.TopScope to $scope.
There must be a scala.xml package when xml literals were parsed.
For compatibility with the old library, which relied on $scope being in scope,
synthesize a `import scala.xml.{TopScope => $scope}` when xml is needed,
but there's no Predef.$scope and the old library is detected (scala.xml.TopScope exists).
|