summaryrefslogtreecommitdiff
path: root/test/junit
Commit message (Collapse)AuthorAgeFilesLines
* Merge commit 'bb3ded3' into merge-2.11-to-2.12-oct-5Lukas Rytz2015-10-051-0/+19
|\
| * Improve presentation compilation of annotationsJason Zaugg2015-09-241-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| * Support completion in erroneous string interpolation.Jason Zaugg2015-09-241-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Merge pull request #4764 from lrytz/sd-33Jason Zaugg2015-09-241-25/+43
|\ \ | | | | | | SD-33 Consider methods annotated @CallerSensitive not safe to inline
| * | SD-33 Consider methods annotated @CallerSensitive not safe to inlineLukas Rytz2015-09-231-25/+43
| | | | | | | | | | | | | | | | | | | | | 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.
* | | Rename the Analyzers backend component to BackendUtilsLukas Rytz2015-09-233-3/+3
|/ / | | | | | | | | Until now, there was no good place to hold various utility functions that are used acrosss the backend / optimizer.
* | Merge commit '03aaf05' into merge-2.11-to-2.12-sep-22Lukas Rytz2015-09-223-0/+191
|\|
| * Merge pull request #4725 from retronym/topic/completely-2.11Lukas Rytz2015-09-211-0/+161
| |\ | | | | | | Topic/completely 2.11
| | * Fix REPL completion of symbolic identifiersJason Zaugg2015-09-101-1/+8
| | | | | | | | | | | | | | | | | | | | | 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.
| | * Fix completion for synthetic case modules and methodsJason Zaugg2015-09-101-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| | * Hide some completion candidates on the first TABJason Zaugg2015-09-091-0/+9
| | | | | | | | | | | | | | | | | | 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.
| | * More liberal matching in REPL autocompletionJason Zaugg2015-09-091-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 ```
| | * Camel Case and JavaBean completionJason Zaugg2015-09-081-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| | * Sort completion proposalsJason Zaugg2015-09-031-0/+3
| | |
| | * Don't offer `asInstanceOf` et al as completions in a fresh REPLJason Zaugg2015-09-031-0/+4
| | | | | | | | | | | | | | | Trying harder to keep the synthetic interpretter wrapper classes behind the curtain
| | * Add the prefix the autocompletion results (Scope-, TypeMember)Jason Zaugg2015-09-031-0/+3
| | | | | | | | | | | | | | | This makes life easier for clients of these APIs, we use this to avoid passing this around in the wrapper result `TypeMembers`.
| | * Use the presentation compiler to drive REPL tab completionJason Zaugg2015-09-021-0/+109
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| * | Merge pull request #4716 from Ichoran/issue/9388Lukas Rytz2015-09-211-0/+24
| |\ \ | | | | | | | | SI-9388 Fix Range behavior around Int.MaxValue
| | * | SI-9388 Fix Range behavior around Int.MaxValueRex Kerr2015-09-191-0/+24
| | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 seqTomas Janousek2015-09-211-0/+6
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| * SI-8346 Re-established soundness of toSet (element type widening)Rex Kerr2015-08-261-0/+81
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| * Fix typos in spec, docs and commentsMichał Pociecha2015-08-231-1/+1
| |
| * SI-9393 fix modifiers of ClassBTypes for Java annotationsLukas Rytz2015-07-241-0/+89
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The Scala classfile and java source parsers make Java annotation classes (which are actually interfaces at the classfile level) look like Scala annotation classes: - the INTERFACE / ABSTRACT flags are not added - scala.annotation.Annotation is added as superclass - scala.annotation.ClassfileAnnotation is added as interface This makes type-checking @Annot uniform, whether it is defined in Java or Scala. This is a hack that leads to various bugs (SI-9393, SI-9400). Instead the type-checking should be special-cased for Java annotations. This commit fixes SI-9393 and a part of SI-9400, but it's still easy to generate invalid classfiles. Restores the assertions that were disabled in #4621. I'd like to leave these assertions in: they are valuable and helped uncovering the issue being fixed here. A new flag JAVA_ANNOTATION is introduced for Java annotation ClassSymbols, similar to the existing ENUM flag. When building ClassBTypes for Java annotations, the flags, superclass and interfaces are recovered to represent the situation in the classfile. Cleans up and documents the flags space in the area of "late" and "anti" flags. The test for SI-9393 is extended to test both the classfile and the java source parser.
| * [backport] Prevent infinite recursion in ProdConsAnalyzerLukas Rytz2015-07-231-0/+42
| | | | | | | | | | | | When an instruction is its own producer or consumer, the `initialProducer` / `ultimateConsumer` methods would loop. While loops or @tailrec annotated methods can generate such bytecode.
* | Merge pull request #4711 from lrytz/opt/heuristicsLukas Rytz2015-09-2210-153/+412
|\ \ | | | | | | Inliner heuristic for higher-order methods
| * \ Merge remote-tracking branch 'upstream/2.12.x' into opt/heuristicsLukas Rytz2015-09-184-1/+155
| |\ \
| * | | Test inliner warnings for callsites not annotated @inlineLukas Rytz2015-09-181-2/+31
| | | | | | | | | | | | | | | | | | | | Test that no warning is issued with the default flags when an inlining fails and the callee is not annotated @inline.
| * | | First version of inliningh heuristics that prefer higher-order methosLukas Rytz2015-09-181-0/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| * | | Run computeMaxLocalsMaxStack less oftenLukas Rytz2015-09-176-13/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| * | | Cleanups and performance fixes in Nullness analysisLukas Rytz2015-09-171-39/+58
| | | |
| * | | Avoid re-computing argInfos after inlining and closure optimizationLukas Rytz2015-09-171-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The call graph holds an argInfos field for every callsite, which contains additional information about the argument passed to the callee. For example, an argInfo specifies if the argument is a function literal or a parameter of the callsite method. Computing the argInfo requires running an ASM analyzer, which is not cheap. This change assembles the argInfos for callsites that are created or changed by the inliner / closure optimizer from the available information instead of just running the analyzer again.
| * | | In the call graph, rename higherOrderParams to samParamTypesLukas Rytz2015-09-171-1/+1
| | | | | | | | | | | | | | | | | | | | Because that's what the field holds: the parameter types that are SAM types.
| * | | Reduce component nesting in backendLukas Rytz2015-09-171-2/+2
| | | | | | | | | | | | | | | | | | | | Make InlinerHeuristics a backend component like the others, instead of nested within the Inliner component.
| * | | Store information about function literals in call graphLukas Rytz2015-09-172-9/+59
| | | | | | | | | | | | | | | | | | | | Remember in the call graph if a function literal is passed as an argument to a higher-order function.
| * | | Include information about higher-order methods in the call graphLukas Rytz2015-08-281-1/+2
| | | | | | | | | | | | | | | | | | | | For higher order methods, the call graph contains a map from parameter positions to SAM types.
| * | | Inline post-inlining requestsLukas Rytz2015-08-281-34/+98
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Inline requests have a list of post-inline requests: callsites within the inlined method that should be inlined into the initial callee. This commit changes the inliner to actually perform post-inline requests.
| * | | Fix maxStack after inliningLukas Rytz2015-08-281-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The computed value was too large previously: inlining stores receiver and argument values of the inlined method into locals. A too large value doesn't cause any bugs, but data flow analyses would allocate too large frames. The test (InlinerTest.maxLocalsMaxStackAfterInline) didn't catch the bug because it tested the methods of the wrong ClassNode. The CodeGenTools.compileClasses method returns a ClassNode that is created from the classfile byte array emitted by the compiler. This ClassNode is a new object and unrelated to the ClassNode used in the compiler backend. The test now takes the correct ClassNode from the hash map in the backend's byteCodeRepository.
| * | | Store SAM information in ClassBTypesLukas Rytz2015-08-271-4/+50
| | | | | | | | | | | | | | | | | | | | If a class (trait) is a SAM type, store the name and descriptor of the SAM in the ClassBType's InlineInfo.
| * | | Separate hash maps in the code repo for classes being compiled or notLukas Rytz2015-08-185-5/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Store classes being compiled in a separate hash map. This allows efficiently traversing all classes being compiled. It also simplifies limiting the size of the cache of class nodes parsed from classfiles. Also change the cache of class nodes parsed from classfiles to LRU instead of FIFO.
| * | | Group call graph by methodLukas Rytz2015-08-172-52/+38
| | | | | | | | | | | | | | | | | | | | | | | | Change the hash maps in the call graph to index callsites and closure instantiations by the containing method. This is beneficial for implementing inliner heuristics and the closure optimizer.
* | | | Merge pull request #4749 from retronym/ticket/9473Lukas Rytz2015-09-222-1/+54
|\ \ \ \ | | | | | | | | | | SI-9473 Cleaner references to statically owned symbols
| * | | | SI-9473 Cleaner references to statically owned symbolsJason Zaugg2015-09-222-1/+54
| | |/ / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Ever wonder why `identity("")` typechecks to `scala.this.Predef.identity("")`? It turns out that `mkAttributedRef` was importing `q"$scalaPackageClass.this.Predef._"` for all these years, rather than `q"$scalaModule.Predef._"`. This commit makes `mkAttributedRef` special case static owners by referring the the corresponding module, instead.
* | | | Merge pull request #4719 from Ichoran/issue/8647Lukas Rytz2015-09-181-0/+7
|\ \ \ \ | | | | | | | | | | SI-8647 Used immutable scheme for mutable.BitSet to resolve canBuildFrom
| * | | | SI-8647 Used immutable scheme for mutable.BitSet to resolve canBuildFromRex Kerr2015-08-301-0/+7
| | |/ / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | mutable.BitSet had a conflict between its own implicit canBuildFrom and the one inherited from SortedSetFactory in mutable.SortedSet. The immutable hierarchy already had a workaround; this just copies it on the mutable side. Test written to verify compilation.
* | | | Merge pull request #4689 from retronym/topic/trait-default-specializationLukas Rytz2015-09-182-0/+60
|\ \ \ \ | |_|/ / |/| | | Preparation for using default methods in traits
| * | | Allow BCode to emit default interface methodsJason Zaugg2015-08-112-0/+60
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | A DefDef owned by a trait may now have have a method body. Such a method must be emitted without ACC_ABSTRACT, and with the code attribute. Tested by intercepting the compile pipeline and adding the DEFAULTMETHOD flag and a method body before running the backend.
* | | Merge remote-tracking branch 'origin/2.11.x' into 2.12.xSeth Tisue2015-09-082-1/+82
| | | | | | | | | | | | | | | | | | | | | | | | only trivial merge conflicts here. not dealing with PR #4333 in this merge because there is a substantial conflict there -- so that's why I stopped at 63daba33ae99471175e9d7b20792324615f5999b for now
* | | Merge pull request #4718 from Ichoran/issue/9379Seth Tisue2015-09-021-0/+16
|\ \ \ | | | | | | | | SI-9379 Added toString to .zipped to allow Stream etc to short-circuit
| * | | SI-9379 Added toString to .zipped to allow Stream etc to short-circuitRex Kerr2015-08-301-0/+16
| |/ / | | | | | | | | | | | | | | | Tuple2Zipped and Tuple3Zipped would try to compute a hash code when .toString was called on them. This overrides toString to print (collection1, collection2).zipped instead, using the collection's own toString method. This allows collections that have a toString but not a hashCode (such as Iterator.from(0) and s = 1 #:: s) to print out as they usually do. JUnit test to verify the deferral to collections' .toString.
* | | Merge pull request #4691 from ↵Adriaan Moors2015-08-311-0/+57
|\ \ \ | |/ / |/| | | | | | | | nicolasstucki/2.12.x-ScalaRunntime-fix-for-Scala.js Remove unnecessary dependency on parallel collections in ScalaRunTime.