| Commit message (Collapse) | Author | Age | Files | Lines |
|\
| |
| | |
Make AnyRefMap serializable
|
| | |
|
|/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Typechecking a pattern that defines a pattern type variable
initially assigns abstract type symbol with open type bounds.
Later on, pattern type inference kicks in to sharpen the type
of the variable based on constraints imposed by the expected
type (ie, the type of scrutinee of the pattern.)
However, before inference does this, a `TypeRef` to the abstract
type symbol can be queried for its base type with respect to some
class, which leads to it populating an internal cache. This cache
becomes stale when the underlying symbol has its type mutated.
The repercussions of this meant that a subsequent call to `baseType`
gave the wrong result (`NoType`), which lead to an `asSeenFrom`
operation to miss out of substitution of a type variable. Note the
appearance of `A` in the old type errors in the enclosed test case.
This commit takes an approach similar to 286dafbd to invalidate
caches after the mutation. I've routed both bandaids through the
same first aid kit: I'm sure over time we'll add additional calls
to this method, and additional cache invalidations within it.
|
|\
| |
| | |
SD-33 Consider methods annotated @CallerSensitive not safe to inline
|
| |
| |
| |
| |
| |
| |
| | |
Fixes https://github.com/scala/scala-dev/issues/33
Methods annotated `sun.reflect.CallerSensitive` should not be inlined,
their implementation may depend on the call stack.
|
| |
| |
| |
| |
| |
| |
| |
| | |
Fixes https://github.com/scala/scala-dev/issues/39
When inlining an indyLambda closure instantiation into a class, and
the closure type is serializable, make sure that the target class has
the synthetic `$deserializeLambda$` method.
|
|/
|
|
|
| |
Until now, there was no good place to hold various utility functions
that are used acrosss the backend / optimizer.
|
|\ |
|
| |\
| | |
| | | |
Topic/completely 2.11
|
| | |\ |
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
Recover part of the identifier that preceded the cursor from the
source, rather than from the name in the `Select` node, which might
contains an encoded name that differs in length from the one in
source.
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
I'm pretty sure the `isSynthetic` call added in 854de25ee6 should
instead be `isArtifact`, so that's what I've implemented here.
`isSynthetic` used to also filter out error symbols, which are
created with the flags `SYNTHETIC | IS_ERROR`. I've added an addition
test for `isError`, which was needed to keep the output of
`presentation/scope-completion-import` unchanged.
The checkfile for `presentation/callcc-interpreter` is modified to
add the additional completion proposals: synthetic companion objects.
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
When `foo.<TAB>`, assume you don't want to see the inherited members
from Any_ and universally applicable extension methods like
`ensuring`. Hitting <TAB> a second time includes them in the results.
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
For the SHIFT-impaired: you can just write everything in lowercase,
(whisper-case?) and we'll try to DWYM.
We treat capital letters that you *do* enter as significant, they
can't match a lower case letter in an identifier.
Modelled after IntellIJ's completion.
I still don't fall into this mode if you enter an exact prefix of
a candidate, but we might consider changing that.
```
scala> classOf[String].typ<TAB>
getAnnotationsByType getComponentType getDeclaredAnnotationsByType getTypeName getTypeParameters
scala> classOf[String].typN<TAB>
scala> classOf[String].getTypeName
res3: String = java.lang.String
scala> def foo(s: str<TAB>
scala> def foo(s: String
String StringBuffer StringBuilder StringCanBuildFrom StringContext StringFormat StringIndexOutOfBoundsException
scala> def foo(s: string<TAB>
scala> def foo(s: String
String StringBuffer StringBuilder StringCanBuildFrom StringContext StringFormat StringIndexOutOfBoundsException
```
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
This is just too useful to leave on the cutting room floor.
```
scala> classOf[String].enclo<TAB>
scala> classOf[String].getEnclosing
getEnclosingClass getEnclosingConstructor getEnclosingMethod
scala> classOf[String].simpl<TAB>
scala> classOf[String].getSimpleName
type X = global.TTWD<TAB>
scala> type X = global.TypeTreeWithDeferredRefCheck
```
I revised the API of `matchingResults` as it was clunky to reuse
the filtering on accessibility and term/type-ness while providing
a custom name matcher.
|
| | | | |
|
| | | |
| | | |
| | | |
| | | |
| | | | |
Trying harder to keep the synthetic interpretter wrapper classes
behind the curtain
|
| | | |
| | | |
| | | |
| | | |
| | | | |
This makes life easier for clients of these APIs, we use this
to avoid passing this around in the wrapper result `TypeMembers`.
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
The old implementation is still avaiable under a flag, but we'll
remove it in due course.
Design goal:
- Push as much code in src/interactive as possible to enable reuse
outside of the REPL
- Don't entangle the REPL completion with JLine. The enclosed test
case drives the REPL and autocompletion programatically.
- Don't hard code UI choices, like how to render symbols or
how to filter candidates.
When completion is requested, we wrap the entered code into the
same "interpreter wrapper" synthetic code as is done for regular
execution. We then start a throwaway instance of the presentation
compiler, which takes this as its one and only source file, and
has a classpath formed from the REPL's classpath and the REPL's
output directory (by default, this is in memory).
We can then typecheck the tree, and find the position in the synthetic
source corresponding to the cursor location. This is enough to use
the new completion APIs in the presentation compiler to prepare
a list of candidates.
We go to extra lengths to allow completion of partially typed
identifiers that appear to be keywords, e.g `global.def` should offer
`definitions`.
Two secret handshakes are included; move the the end of the line,
type `// print<TAB>` and you'll see the post-typer tree.
`// typeAt 4 6<TAB>` shows the type of the range position within
the buffer.
The enclosed unit test exercises most of the new functionality.
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
Transcript paste mode invites the user to keep typing like
regular paste mode, but really you must enter more transcript.
This matters if the script ends in the middle of incomplete
code that the user wants to complete by hand.
Previously,
```
scala> scala> def f() = {
// Detected repl transcript paste: ctrl-D to finish.
// Replaying 1 commands from transcript.
scala> def f() = {
scala> scala> def f() = {
// Detected repl transcript paste: ctrl-D to finish.
| }
// Replaying 1 commands from transcript.
scala> def f() = {
}
f: ()Unit
```
Now,
```
scala> scala> def f() = {
// Detected repl transcript. Paste more, or ctrl-D to finish.
// Replaying 1 commands from transcript.
scala> def f() = {
| 42
| }
f: ()Int
scala> f()
res0: Int = 42
```
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
The classic banner is available under -Dscala.repl.power.banner=classic.
```
scala> :power
Power mode enabled. :phase is at typer.
import scala.tools.nsc._, intp.global._, definitions._
Try :help or completions for vals._ and power._
```
|
| |\ \ \
| | | | |
| | | | | |
SI-9388 Fix Range behavior around Int.MaxValue
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
terminalElement (the element _after_ the last one!) was used to terminate foreach loops and sums of non-standard instances of Numeric. Unfortunately, this could result in the end wrapping around and hitting the beginning again, making the first element bad.
This patch fixes the behavior by altering the loop to end after the last element is encountered. The particular flavor was chosen out of a few possibilities because it gave the best microbenchmarks on both large and small ranges.
Test written. While testing, a bug was also uncovered in NumericRange, and was also fixed. In brief, the logic around sum is rather complex since division is not unique when you have overflow. Floating point has its own complexities, too.
Also updated incorrect test t4658 that insisted on incorrect answers (?!) and added logic to make sure it at least stays self-consistent, and fixed the range.scala test which used the same wrong (overflow-prone) formula that the Range collection did.
|
| |\ \ \ \
| | | | | |
| | | | | | |
Fix NPE in PagedSeq.slice at end of seq
|
| | |/ / /
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
See https://github.com/scala/scala-parser-combinators/issues/70
Basically the same thing as SI-6615, including the fact everything
works okay if the PagedSeq is printed before calling slice.
It might seem strange that this allows taking slices that start beyond
the end, but
- this was possible anyway if one forced the entire sequence, and
- it is reasonable to be able to take a slice at the very end (not
beyond it) and get an empty sequence, which is exactly what
StreamReader in scala-parser-combinators does and gets an NPE.
|
| |\ \ \ \
| | | | | |
| | | | | | |
fix partest on Cygwin
|
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
this hadn't been touched since 2013, and didn't work when I tried it
-- not surprisingly since the classpath stuff for partest changed a
lot when Scala was modularized.
the shell script works on Cygwin, so the bat file isn't needed.
further piece of evidence this file is abandoned and unused: at
https://issues.scala-lang.org/browse/SI-3290, in 2010, Lukas Rytz
wrote "i never heard somebody saying it was abandoned, but i never
heard of somebody using it either."
|
| | | |_|/
| | |/| |
| | | | |
| | | | |
| | | | | |
note that the code removed here is inside an `if $cygwin; then` block,
so it can't affect other environments.
|
| |\ \ \ \
| | | | | |
| | | | | | |
[backport] Include owner in ErrorNonExistentField message
|
| | | |/ /
| | |/| |
| | | | |
| | | | | |
This should be particularly helpful for synthetic field names like `evidence$21`.
|
|\| | | | |
|
| |/ / /
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
partest has custom code for -Xplugin handling (see
DirectCompiler.updatePluginPath for details). that code has its own
idea of what the syntax of -Xplugin is, different from Scalac's.
partest's idea is that multiple paths should be separated by the
platform classpath separator character, so : on Unix and ; on Windows.
the .flags file here was using a colon, and that confuses partest on
Windows, since partest was expecting a semicolon.
it might be nice to fix partest to accept comma as the separator
instead, which is standard for a scalac MultiStringSetting such
as -Xplugin. but it turns out we have an out: we can just provide
multiple -Xplugin flags.
what evidence do I have that this is the right change?
* the test still passes on both Windows and Mac OS X (manually
tested); if Travis likes it, we'll know it passes on Linux too
* I tried reverting Som's fix for SI-9370 (c32ba93) and the test failed,
as expected, both with and without my change
* I added a bunch of debugging output to
DirectCompiler.updatePluginPath in partest, built a new partest jar,
and used it to run the test on Windows with and without my fix, and
verified by eye that the logic there was operating as expected in
both cases
and in conclusion, for Som's benefit: <insert cryptic joke here>
|
| |/ /
| | |
| | |
| | | |
Such that uncurry can correctly un-dependify them.
|
| |\ \
| | | |
| | | | |
unset inappropriate execute bits
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
I imagine these date back to old Subversion days and are probably the
result of inadvertent commits from Windows users with vcs client
configs.
having the bit set isn't really harmful most of the time,
but it's just not right, and it makes the files stand out in directory
listings for no reason
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
A previous optimization (d44a86f432a7f9ca250b014acdeab02ac9f2c304) for
pattern matcher exhaustivity checks used a smarter encoding to ensure
that the scrutinee can be equal to one child only.
However, in case of traits between the root and leave type, a child can
be of several types and these types should not be in a mutually exclusive
group. A simple solution (hat tip to retronym) is to just put traits
and classes into separate groups.
|
| |\ \ \
| | |_|/
| |/| | |
SI-9442 Fix the uncurry-erasure types
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
Using the "uncurry-erased" type (the one after the uncurry phase) can
lead to incorrect tree transformations. For example, compiling:
```
def foo(c: Ctx)(l: c.Tree): Unit = {
val l2: c.Tree = l
}
```
Results in the following AST:
```
def foo(c: Ctx, l: Ctx#Tree): Unit = {
val l$1: Ctx#Tree = l.asInstanceOf[Ctx#Tree]
val l2: c.Tree = l$1 // no, not really, it's not.
}
```
Of course, this is incorrect, since `l$1` has type `Ctx#Tree`, which is
not a subtype of `c.Tree`.
So what we need to do is to use the pre-uncurry type when creating
`l$1`, which is `c.Tree` and is correct. Now, there are two
additional problems:
1. when varargs and byname params are involved, the uncurry
transformation desugares these special cases to actual
typerefs, eg:
```
T* ~> Seq[T] (Scala-defined varargs)
T* ~> Array[T] (Java-defined varargs)
=>T ~> Function0[T] (by name params)
```
we use the DesugaredParameterType object (defined in
scala.reflect.internal.transform.UnCurry) to redo this desugaring
manually here
2. the type needs to be normalized, since `gen.mkCast` checks this
(no HK here, just aliases have to be expanded before handing the
type to `gen.mkAttributedCast`, which calls `gen.mkCast`)
|
| |\ \ \
| | |_|/
| |/| | |
SI-6636 Fix macro expansion in toolboxes
|
| | | | |
|
| |\ \ \
| | | | |
| | | | | |
SI-9450 Fix triple quoted strings in REPL :power mode
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
Some extra synthetic code generated under this mode failed to escape
input before adding it to a literal string. It used to get away with
this most of the time by triple quoting the literal.
This commit reuses Scala string escaping logic buried in `Constant`
to do this properly. Actually, the proper approach would be to build
the synthetic code with trees and quasiquotes, and avoid the mess
of stringly-genererated code.
I threw in some defensive hygiene for the reference to `Nil` while
I was in the neighbourhood.
|
| |/ / /
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
toSet needs to rebuild some child classes, but not others, as toSet is
allowed to widen element types (which the invariant Set normally cannot do),
and some sets rely upon their invariance. Thus, sets that rely upon their
invariance now rebuild themselves into a generic set upon toSet, while those
that do not just sit there.
Note: there was a similar patch previously that fixed the same problem, but
this is a reimplementation to circumvent license issues.
Note: the newBuilder method was benchmarked as (surprisingly!) the most
efficient way to create small sets, so it is used where sets may need to
be rebuild.
|
| | |/
| |/| |
|
|\ \ \
| | | |
| | | | |
Inliner heuristic for higher-order methods
|
| |\ \ \ |
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
Test that no warning is issued with the default flags when an inlining
fails and the callee is not annotated @inline.
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
When invoking a higher-order method and the value passed for the
SAM type is either a function literal or a parameter of the callsite
method, inline the higher-order method into the callee.
This is a first version, the heuristics will be refined further.
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
Handler tables are lists of tuples (try-start, try-end,
handler-start, exception-type). When an instruction throws, the first
handler in the list that covers the instruction and matches the type
is executed. For nested handlers, it is the job of the compiler to
add them to the handler table in the correct order.
When inlining a method, the handlers of the callee are prepended to
the list of handlers in the callsite method. This ensures that the
callee's handlers are tested first if an exception is thrown in the
inlined code.
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
Introduce a cache to remember which methods have maxLocals and
maxStack already computed. Before we were computing these values
on every run of eliminateUnreachableCode.
Also update the implementation of eliminateUnreachableCode to keep
correct max values.
|