| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|\
| |
| | |
SI-9567 Fix pattern match on 23+ param, method local case class
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Typechecking constructor patterns of method local case classes
was only working because of the existence of the unapply method
in the companion, which is used if navigation to the case class
companion object fails.
We now support defintion of, and pattern matching on, case classes
with more than 22 parameters. These have no `unapply` method
in the companion, as we don't have a large enough tuple type to
return. So for such case classes, the fallback that we inadvertently
relied on would no longer save us, and we'd end up with a compile
error advising that the identifier in the constructor pattern was
neither a case class nor an extractor.
This is due to the propensity of `Symbol#companionXxx` to return
`NoSymbol` when in the midst of typechecking. That method should
only be relied upon after typechecking. During typechecking,
`Namers#companionSymbolOf` should be used instead, which looks in the
scopes of enclosing contexts for symbol companionship. That's
what I've done in this commit.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Under -optimize, the pattern matcher tries to avoid local variables
in favour of directly accessing to non-var case class accessors.
However, the code that analysed the patterns failed to account
properly for repeated parameters, which could either lead to
a compiler crash (when assuming that the n-th subpattern must have
a corresponding param accessor), or could lead to a correctness
problem (when failing to eagerly the bound elements from the
sequence.)
The test case that tried to cover seems only to have been working
because of a separate bug (the primary subject of SI-9567) related
to method-local case classes: they were treated during typechecking
as extractors, rather than native case classes.
The subsequent commit will fix that problem, but first we must
pave the way with this commit that emits local vals for bound
elements of case class repeated params.
|
|\ \
| | |
| | | |
SI-9581 Fix overflow on Vector take and drop methods
|
| |/
| |
| |
| |
| |
| | |
Fixes the index/length comparison in `Vector#take` and `Vector#drop` so that they handle all possible integer values.
Given the collection's invariants `startIndex >= endIndex` and `0 >= startIndex, endIndex`, it is sufficient to change the arithmetic in the comparison as done in this commit to avoid overflows. As cases when `n <= 0` are handled beforehand, `endIndex - n` cannot overflow, contrary to `startIndex + n`. If without the danger of overflows the condition yields true, on the other hand, `startIndex + n` cannot overflow as it is smaller than `endIndex` (as the previous formulation of the condition shows).
|
|/
|
|
|
|
|
|
|
|
|
|
| |
- Fix the scoping of files/lib/*.jar. These files were not on the
classpath when running partest from sbt.
- Pass the same standard Java options to partest as from the command
line. This requires new versions of scala-partest and
scala-partest-interface.
- Fix the classpath scanning in jvm/innerClassEnclMethodJavaReflection.
It only worked for JARs and relative directories but not for absolute
directory paths (which are produced by sbt).
|
|\
| |
| | |
Attacking exponential complexity in TypeMaps
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
- Don't normalize existentials during the `contain`-s type map;
`ExistentialType#normalize' calls contains internally and
an exponential blowup ensues.
- Ensure that the type map used in variance validation never
returns modified types in order to avoid needless cloning of
symbols.
The enclosed test case still gets stuck in Uncurry, thanks to
the way that `TypeMap#mapOver(List[Symbol])` recurses through the
type first to check whether the type map would be an no-op or not.
If not, it repeats the type map with cloned symbols. Doing the work
twice at each level of recursion blows up the complexity.
Removing that "fast path" allows the enclosed test to compile
completely. As at this commit, it gets stuck in uncurry, which
dealiases `s.List` to `s.c.i.List` within the type.
Some more background on the troublesome part of `TypeMap`:
http://lrytz.github.io/scala-aladdin-bugtracker/displayItem.do%3Fid=1210.html
https://github.com/scala/scala/commit/f8b2b21050e7a2ca0f537ef70e3e0c8eead43abc
|
|\ \
| | |
| | | |
less confusing wording for a dependent method type error
|
| |/
| |
| |
| |
| |
| |
| |
| | |
note to reviewers: the error messages in this file are over the place
about whether they're called "parameter sections", or "argument
lists", or what, so there's no point in being picky about that here
for context see SI-823
|
|\ \
| | |
| | | |
Multi output problem with delambdafied compilation
|
| |/ |
|
|\ \
| | |
| | | |
it's Scaladoc, not ScalaDoc
|
| |/
| |
| |
| |
| | |
renaming the existing ScalaDoc and ScalaDocReporter classes might
break stuff, sadly, but at least we can fix the rest
|
|\ \
| | |
| | | |
SI-9497 Fix SetLike#clear() default implementation
|
| | |
| | |
| | |
| | | |
When dealing with mutable collections, it is not safe to assume iterators will remain consistent when the collection is modified mid-traversal. The bug reported in SI-9497 is very similar to SI-7269, "ConcurrentModificationException when filtering converted Java HashMap". Then, only the `retain` method was fixed. This commit fixes `clear`, which had the same problem.
|
|\ \ \
| |_|/
|/| | |
[SI-9503] Deprecate scala.collection.immutable.PagedSeq
|
| | | |
|
| |/
|/|
| |
| |
| |
| | |
A session test with extra filtering best expresses the intentions.
No check file is required.
|
|\ \
| |/
|/| |
improvements to Windows build & test situation
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
this was failing because the expected output was:
res1: List[String] = List(shello, world.)
but the actual output was:
res1: List[String] = List(shello, world., Picked up _JAVA_OPTIONS: -Duser.home=y:\jenkins)
but the "Picked up..." part caused partest's filters feature to
ignore the entire line (it doesn't anchor matches to start of line.)
This was a tough one to track down.
|
|\ \
| | |
| | | |
SI-9513 decrement "deleted" count in OpenHashMap.put() when slot reused
|
| | | |
|
| |/ |
|
|\ \
| |/
|/| |
SI-9492 REPL paste here doc
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Simple here documentish syntax for REPL paste.
This makes it easier to paste a block of script
(as opposed to transcript).
It also means you won't accidentally ctl-D out
of the REPL and then out of SBT and then out of
the terminal window.
```
scala> :paste < EOF
// Entering paste mode (EOF to finish)
class C { def c = 42 }
EOF
// Exiting paste mode, now interpreting.
defined class C
scala> new C().c
res0: Int = 42
scala> :paste <| EOF
// Entering paste mode (EOF to finish)
|class D { def d = 42 }
EOF
// Exiting paste mode, now interpreting.
defined class D
scala> new D().d
res1: Int = 42
scala> :quit
```
|
|\ \
| |/
|/| |
SI-9029 Fix regression in extractor patterns
|
| |
| |
| |
| | |
Found these in an old review branch of mine.
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The unified treatment of classical and named-based pattern matching
does not correctly handle the generalization of "tuple capture".
By "tuple capture", I mean:
```
scala> object Extractor { def unapply(a: Any): Option[(Int, String)] = Some((1, "2")) }
defined object Extractor
scala> "" match { case Extractor(x: Int, y: String) => }
scala> "" match { case Extractor(xy : (Int, String)) => }
warning: there was one deprecation warning; re-run with -deprecation for details
scala> :warnings
<console>:9: warning: object Extractor expects 2 patterns to hold (Int, String) but crushing into 2-tuple to fit single pattern (SI-6675)
"" match { case Extractor(xy : (Int, String)) => }
^
```
Name based pattern matching, new in Scala 2.11, allows one to
deconstruct the elements that structurally resembles `ProductN`:
```
scala> class P2(val _1: Int, val _2: String)
defined class P2
scala> object Extractor { def unapply(a: Any): Option[P2] = Some(new P2(1, "2")) }
defined object Extractor
scala> "" match { case Extractor(x: Int, y: String) => }
```
However, attempting to extract the `P2` in its entirety leads to
an internal error:
```
scala> "" match { case Extractor(p2: P2) => }
<console>:10: warning: fruitless type test: a value of type (Int, String) cannot also be a P2
"" match { case Extractor(p2: P2) => }
^
<console>:10: error: error during expansion of this match (this is a scalac bug).
The underlying error was: type mismatch;
found : P2
required: (Int, String)
"" match { case Extractor(p2: P2) => }
^
```
Note that this match was legal and warning free in 2.10.
This commit avoids the hard-coded assumption that the "tuple capture"
results in a `TupleN`, and instead keeps track of the product-ish
type from which we extracted the element types. I have also opted not
to limit the deprecation warning to `TupleN` extractors.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
A trio of problems were hampering autocompletion of annotations.
First, given that that annotation is written before the annotated
member, it is very common to end parse incomplete code that has a
floating annotation without an anotatee.
The parser was discarding the annotations (ie, the modifiers) and
emitting an `EmptyTree`.
Second, the presetation compiler was only looking for annotations
in the Modifiers of a member def, but after typechecking annotations
are moved into the symbol.
Third, if an annotation failed to typecheck, it was being discarded
in place of `ErroneousAnnotation`.
This commit:
- modifies the parser to uses a dummy class- or type-def tree,
instead of EmptyTree, which can carry the annotations.
- updates the locator to look in the symbol annotations of the
modifiers contains no annotations.
- uses a separate instance of `ErroneousAnnotation` for each
erroneous annotation, and stores the original tree in its
`original` tree.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
In the code:
```
s"${fooo<CURSOR"
```
The parser treats `fooo` as a interpolator ID for the quote that
we actually intend to end the interpolated string.
Inserting a space (in addition to `__CURSOR__` that we already
patch in to avoid parsing a partial identifier as a keyword),
solves this problem.
|
|\ \
| | |
| | | |
[backport] SI-9375 add synthetic readResolve only for static modules
|
| |/
| |
| |
| |
| |
| |
| |
| |
| | |
For inner modules, the synthetic readResolve method would cause the
module constructor to be invoked on de-serialization in certain
situations. See the discussion in the ticket.
Adds a comprehensive test around serializing and de-serializing
modules.
|
|\ \
| | |
| | | |
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.
|