summaryrefslogtreecommitdiff
path: root/src/reflect
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #3487 from andy128k/masterAdriaan Moors2014-02-091-1/+1
|\ | | | | fix typo
| * fix typoAndrey Kutejko2014-02-071-1/+1
| |
* | Merge pull request #3471 from adriaanm/t6169Adriaan Moors2014-02-091-2/+49
|\ \ | | | | | | SI-6169 Refine java wildcard bounds using corresponding tparam
| * | SI-6169 initialize before .typeParams -- just in caseAdriaan Moors2014-02-051-1/+1
| | |
| * | SI-6169 more accurate check for raw java type encoded as existentialAdriaan Moors2014-02-051-1/+7
| | |
| * | SI-6169 Refine java wildcard bounds using corresponding tparamAdriaan Moors2014-02-051-2/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Also fixes part of SI-8197. Necessary complement to SI-1786 (#2518), because we now infer tighter bounds for RHSs to conform to. When opening an existential, Java puts constraints in the typing environment that are derived from the bounds on the type parameters of the existentially quantified type, so let's do the same for existentials over java-defined classes in skolemizeExistential... Example from test case: ``` public class Exist<T extends String> { // java helpfully re-interprets Exist<?> as Exist<? extends String> public Exist<?> foo() { throw new RuntimeException(); } } ``` In Scala syntax, given a java-defined `class C[T <: String]`, the existential type `C[_]` is improved to `C[_ <: String]` before skolemization, which models what Java does (track the bounds as type constraints in the typing environment) (Also tried doing this once during class file parsing or when creating the existential type, but that causes cyclic errors because it happens too early.)
* | | Merge pull request #3484 from retronym/ticket/8237Adriaan Moors2014-02-092-5/+27
|\ \ \ | | | | | | | | SI-8237 Avoid cyclic constraints when inferring hk type args
| * | | SI-8237 Avoid cyclic constraints when inferring hk type argsJason Zaugg2014-02-092-5/+27
| | |/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | An `AppliedTypeVars` spawned from `HKTypeVar#applyArgs` (necessarily) shares the same `TypeConstraints`. But, we can have multiple ATVs based on a single HKTV floating around during inference, and they can appear on both sides of type relations. An example of this is traced out in the enclosed test. This commit avoids registering upper/lower bound constraints when this is detected. In the enclosed test, we end up with an empty set of constraints for `?E`, which results in inference of Nothing, which is what we expect. I have also improved the printing of ATVs (to include the args) and sharpened the log message when `solve` leaves type variables instantiated to `NoType`, rather than some other type that doesn't conform to the bounds. Both of these changes helped me to get to the bottom of this ticket. The improved `ATV#toString` shows up in some updated checkfiles. The reported test has quite a checkered history: - in 2.10.0 it worked, but more by good luck than good planning - after the fix for SI-7226 / 221f52757aa6, it started crashing - from 3bd897ba0054f (a merge from 2.10.x just before 2.11.0-M1) we started getting a type inference failure, rather than a crash. "no type parameters for method exists [...] because cyclic instantiation". - It still crashes in `isGround` in 2.10.3.
* | | Merge pull request #3485 from xeno-by/topic/reset-all-attrsJason Zaugg2014-02-095-13/+8
|\ \ \ | | | | | | | | kills resetAllAttrs
| * | | renames resetLocalAttrs to resetAttrsEugene Burmako2014-02-071-1/+1
| | | | | | | | | | | | | | | | | | | | Now when resetAllAttrs is gone, we can use a shorter name for the one and only resetLocalAttrs.
| * | | further limits discoverability of resetAttrsEugene Burmako2014-02-075-13/+8
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | Merge pull request #3391 from xeno-by/ticket/8131Jason Zaugg2014-02-0812-143/+249
|\ \ \ | | | | | | | | SI-8131 fixes residual race condition in runtime reflection
| * | | turns off the gilSynchronizedIfNotInited optimizationEugene Burmako2014-02-011-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | According to Jason (https://github.com/scala/scala/pull/3391#issuecomment-32904460), this one is still causing trouble, so we have to turn it off until we have time to debug it.
| * | | SI-8131 fixes residual race condition in runtime reflectionEugene Burmako2014-01-2110-118/+224
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Apparently some completers can call setInfo while they’re not yet done, which resets the LOCKED flag, and makes anything that uses LOCKED to track completion unreliable. Unfortunately, that’s exactly the mechanism that was used by runtime reflection to elide locking for symbols that are known to be initialized. This commit fixes the problematic lock elision strategy by introducing an explicit communication channel between SynchronizedSymbol’s and their completers. Now instead of trying hard to infer whether it’s already initialized or not, every symbol gets a volatile field that can be queried to provide necessary information.
| * | | FromJavaClassCompleter is now flag-agnosticEugene Burmako2014-01-201-8/+10
| | | | | | | | | | | | | | | | | | | | A minor evolution of the notion of completion + also a small performance optimization.
| * | | Revert "synchronizes pendingVolatiles"Eugene Burmako2014-01-205-18/+7
| | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 000c18a8fac60065747652368dadcd7850532f3f, because Symbol.isStable is independent from Type.isVolatile since fada1ef6b315326ac0329d9e78951cfc95ad0eb0.
| * | | a note about Symbol.typeSignatureEugene Burmako2014-01-201-0/+7
| | | | | | | | | | | | | | | | | | | | No changes to behavior, just documenting internal workings of reflection a bit more thoroughly, one step at a time.
* | | | Add support for a more straightforward alternative to import selectorsDenys Shabalin2014-02-074-21/+170
| | | |
* | | | Use more specific return type for SyntacticFunctionDenys Shabalin2014-02-072-7/+4
| | | |
* | | | Better comment for SyntacticEmptyTypeTreeDenys Shabalin2014-02-071-3/+6
| | | |
* | | | Represent tq"" as SyntacticEmptyTypeTree rather than TypeTree()Denys Shabalin2014-02-073-2/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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")
* | | | Rename EmptyTypTree into SyntacticEmptyTypeTreeDenys Shabalin2014-02-071-11/+7
| |/ / |/| | | | | | | | | | | | | | 1. Change the name as Eugene believes previous name was misleading 2. Remove EmptyTree case as it's not needed any longer
* | | Merge pull request #3458 from densh/si/8173Eugene Burmako2014-02-061-25/+26
|\ \ \ | | | | | | | | SI-8173 add support for patterns like init :+ last to quasiquotes
| * | | SI-8173 add support for patterns like init :+ last to quasiquotesDenys Shabalin2014-02-021-25/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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)
* | | | Merge pull request #3449 from retronym/topic/opt11Grzegorz Kossakowski2014-02-052-11/+26
|\ \ \ \ | | | | | | | | | | Another grab bag of compiler optimizations
| * | | | Avoid needless Name creationJason Zaugg2014-01-312-11/+26
| |/ / / | | | | | | | | | | | | | | | | - Don't create names just to perform prefix/suffix checks - Don't create names, decode, *and* intern strings in ICode
* | | | Merge pull request #3400 from retronym/ticket/8170Adriaan Moors2014-02-051-5/+32
|\ \ \ \ | | | | | | | | | | SI-8170 Fix regression in TypeRef#transform w. PolyTypes
| * | | | SI-8170 Posing outstanding questions as TODOsJason Zaugg2014-02-051-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | We'll get to the bottom of this as soon as we get one of those Round Tuits.
| * | | | SI-8170 Fix regression in TypeRef#transform w. PolyTypesJason Zaugg2014-01-221-5/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Regressed in SI-8046 / edc9edb7, by my hand. At the time, I noticed the problem: transform wasn't accounting for the potential Poly-Type-ness of its argument, and this would lead to under-substituted types. The commit comment of edc9edb7 shows an example. But the remedy wasn't the right one. The root problem is that a TypeMap over a PolyType can return one with cloned type parameter symbols, which means we've lose the ability to substitute the type arguments into the result. This commit detects up front whether the type-under-transform is a PolyType with the current TypeRef's type parameters, and just runs the `asSeenFrom` over its result type.
* | | | | SI-8030 Restore thread safety to the parserJason Zaugg2014-02-051-1/+1
| |_|_|/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In addition to the invariant "parsing doesn’t enter new symbols", which was respected and tested in 760df9843a910d6, we also must ensure that "parsing doesn't call Symbol#info". That happend indirectly if we call `companionModule`. This commit just converts the name of `class TupleN` to a term name, rather than getting the name of its companion. No test is included. This is tested upstream in: https://jenkins.scala-ide.org:8496/jenkins/view/Memory%20Leak%20Tests/job/scalac-memory-leaks-test-2.11.0/
* | | | Merge pull request #3445 from retronym/topic/opt7Grzegorz Kossakowski2014-02-023-11/+16
|\ \ \ \ | | | | | | | | | | Grab bag of compiler optimizations
| * | | | Optimize lookup of tree/symbol attachment search.Jason Zaugg2014-02-011-1/+4
| | | | | | | | | | | | | | | | | | | | Use `hasAttachment` rather than `getAttachment.exists`
| * | | | Optimization in InstantiateDependentMapJason Zaugg2014-02-011-1/+1
| | | | | | | | | | | | | | | | | | | | Avoid creating a throwaway array in existentialsNeeded.
| * | | | Optimize TreeInfo#isMacroApplication.Jason Zaugg2014-01-311-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | It's called rather frequently. Tree#symbol is a megamorphic call, which featured in profiles.
| * | | | Optimize isSelfSuperCallJason Zaugg2014-01-311-7/+7
| | |/ / | |/| | | | | | | | | | | | | | | | | | Avoid the Applied extractor altogether, as that eagerly creates `argss` which we don't need and which is quite expensive.
* / | | Avoid generic collections operations hot pathsJason Zaugg2014-01-315-19/+50
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Use a specialized version of List#{map, collectFirst} These special case mapping over an empty list and avoid allocating. - Avoid nonEmpty in favor of `ne Nil` I see in the order of 2% speedup. Perhaps more useful is that these methods no longer dominate the YourKit profiles, even though profiler bias due to safepoints at allocation of the ListBuffer might have been overstating their significance.
* | | Merge pull request #3357 from retronym/ticket/8143Adriaan Moors2014-01-311-1/+1
|\ \ \ | | | | | | | | SI-8143 Regressions with override checks, private members
| * | | SI-8143 Regressions with override checks, private membersJason Zaugg2014-01-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These regressed in e609f1f20b, which excluded all private methods from overriding checks. We should only exclude private[this] members on the low end of a pair, as was done before that commit, and, we must also exclude private members on the high side. Why? Warning: reverse engineered intuition follows. We need to report an error when if a private method in a subclass has matches a less-private method in the super class and report an error, lest the user be fooled into thinking it might be invoked virtually. On the other hand, adding a private method to a super class shouldn't invalidate the choice names of public members in its superclasses. I've removed the test case added by that commit and will lodge a reworked version of it that Paul provided as a new issue. That shows a bug with qualified private + inheritance. In addition, the expectation of `neg/accesses.check` is reverted to its 2.10.3 version, which I believe is correct. When it was changed in e609f1f20b it sprouted a variation, `neg/accesses-2`, which has now changed behaviour. The intent of that test will be captured in the aforementioned issue covering qualified private inheritance.
* | | | SI-8205 Don't include CR in lineSom Snytt2014-01-291-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | More penance. Extend the unit test and don't include CR in the line text. This is obvious, which shows how dangerous it is to refactor without unit tests. My very favorite bugs are off-by-one and EOL handling, followed closely by off-by-Int.MaxValue.
* | | | Merge pull request #3427 from retronym/ticket/8205Jason Zaugg2014-01-291-3/+3
|\ \ \ \ | | | | | | | | | | Avoid long, slow march to AIIOBE in SourceFile#lineContent
| * | | | SI-8205 Avoid long, slow march to AIIOBE in SourceFile#lineContentJason Zaugg2014-01-291-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixing a regression from SI-8015. The failure mode is kind of amusing: a while loop in `lineToString` would count all the way to `Int.MaxValue`, and integer overflow would foil a bounds check when looking for the 'LF' in 'CR'-'LF'. Given that we're not a style checker to enforce that source files end in a new-line, this commit accounts for EOF, and fixed the overflow problem too. A JUnit test exercises the bug and a few other variations of `lineContent`. While i was in the neighbourhood, I opted for a more efficient means to slice out that line.
* | | | | Merge pull request #3426 from retronym/ticket/8199Grzegorz Kossakowski2014-01-291-4/+7
|\ \ \ \ \ | | | | | | | | | | | | SI-8199 Account for module class suffix in -Xmax-classfile-name
| * | | | | SI-8199 Account for module class suffix in -Xmax-classfile-nameJason Zaugg2014-01-291-4/+7
| |/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The class file name of an inner class is based on the flattened name of its owner chain. But, if this is going to be unreasonably long, it is shortened with the help of a MD5 hash. However, after this shortening takes place, we sneakily add one more character (the infamous '$') to the name when it is used for the module class. It is thus possible to exceed the limit by one. The enclosed test failed on Mac with "filename too long" because of this. I have also tested for trait implementatation classes, but these seem to be suffixed with "$class" before the name compactification runs, so they weren't actually a problem. This change is binary incompatible as separately compiled defintions and usages of named, inner classes need to agree on this setting. Most typically, however, these long names crop up for inner anonymous classes / functions, which are not prone to the binary incompatiblity, assuming that their creation hasn't be inlined to a separately compiled client.
* | | | | Merge pull request #3374 from densh/si/6844-8076Jason Zaugg2014-01-293-26/+53
|\ \ \ \ \ | | | | | | | | | | | | SI-6844 SI-8076 improve handling of function parameters in quasiquotes
| * | | | | SI-8076 improve support for implicit argument listDenys Shabalin2014-01-163-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * | | | | SI-6844 restrict splicing in parameter positionDenys Shabalin2014-01-163-26/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | | | | Merge pull request #3402 from densh/si/7275Eugene Burmako2014-01-297-8/+57
|\ \ \ \ \ \ | |_|/ / / / |/| | | | | SI-7275 allow flattening of blocks with ..$
| * | | | | Addresses feedback from JasonDenys Shabalin2014-01-272-10/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| * | | | | Address pull request feedbackDenys Shabalin2014-01-231-1/+1
| | | | | |
| * | | | | SI-7275 allow flattening of blocks with ..$Denys Shabalin2014-01-233-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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)) }