summaryrefslogtreecommitdiff
path: root/src/reflect/scala/reflect/internal/Names.scala
Commit message (Collapse)AuthorAgeFilesLines
* Fix SIOOBE in Name#pos for substrings of length 1Jason Zaugg2017-01-101-2/+4
|
* Manually inlined all other instances of Platform.arraycopy to System.arraycopyRex Kerr2016-11-091-2/+2
| | | | | to avoid the same kind of slowdowns that Vector was experiencing due to the less aggressive inlining by scalac.
* Remove unused imports and other minor cleanupsSimon Ochsenreither2015-12-181-2/+2
| | | | | | | | | | - Language imports are preceding other imports - Deleted empty file: InlineErasure - Removed some unused private[parallel] methods in scala/collection/parallel/package.scala This removes hundreds of warnings when compiling with "-Xlint -Ywarn-dead-code -Ywarn-unused -Ywarn-unused-import".
* Fix many typos in docs and commentsmpociecha2014-12-141-2/+2
| | | | | | | | | | | | | This commit corrects many typos found in scaladocs, comments and documentation. It should reduce a bit number of PRs which fix one typo. There are no changes in the 'real' code except one corrected name of a JUnit test method and some error messages in exceptions. In the case of typos in other method or field names etc., I just skipped them. Obviously this commit doesn't fix all existing typos. I just generated in IntelliJ the list of potential typos and looked through it quickly.
* Re-use the exsiting range of the name table when using subName.Lukas Rytz2014-05-211-4/+10
| | | | The sub-name can just point to a smaller range of the array.
* Cleanups in Names.scalaLukas Rytz2014-05-211-53/+38
| | | | | | | | | | | Enter only fully constructed Name objects into the hash table, this should make lookupTypeName thread-safe. Clean up lookupTypeName - the hash code for a type name is the same as for its correspondent term name. Going from a type name toTermName should never create a new TermName instance. Assert that.
* Minor cleanups and commenting around BType.Lukas Rytz2014-05-211-3/+6
| | | | Use `length` instead of `size` on arrays in `reflect/internal/Names`.
* SI-8190 erasure identities for types in reflection APIEugene Burmako2014-02-141-2/+2
| | | | | | | | | | | Makes sure that almost every abstract type declared in reflection API erases to a unique class, so that they can be adequately used for method overloading to the same extent that tags allow them to be used in pattern matching. The only two exceptions from this rule are the types whose implementations we do not control: FlagSet that is implemented as Long and RuntimeClass that is implemented as java.lang.Class[_].
* Avoid needless Name creationJason Zaugg2014-01-311-10/+25
| | | | | - Don't create names just to perform prefix/suffix checks - Don't create names, decode, *and* intern strings in ICode
* Rework cff8b569 to heal the windows build.Jason Zaugg2013-10-031-2/+4
| | | | | | | | | - change newTermName to fix negative length names rather than reject them - restore the old logic in unspecializedName for names that result from AnyRef specialized type parameters. Why does fix the windows build? I remain none the wiser.
* SI-7841 More robust unspecialization of namesJason Zaugg2013-09-161-0/+2
| | | | | | | | | | | | | | | | | | | | Names like `T1$sp`, which can arise from `AnyRef` specialization, were leading to negative length Names if they ever passed through `unspecializedName` or `splitSpecializedName`. This code path was touched when printing the tree of a certain AnyRef specialized classes after specialization, such as `AbstractPartialFunction` (which had such specialization until a few commits ago.) This commit handles that case correctly, and generally hardens against unexpected names, which could pop up from third party classes. The documentation for `splitSpecializedName` transposed the class and method specializations. The things you discover when you turn examples in documentation in to test cases! In addition, we now require non-negative length and offset in `newTermName`
* Lock down methods in NamesJason Zaugg2013-08-311-11/+14
| | | | | | | | Marking some methods as final. Once known to be overriden in scala-ide are instead marked with @deprecatedOveriding. This is to signal the new means of synchronization to subclasses.
* SI-6240 Synchronizes NamesJason Zaugg2013-08-221-29/+56
| | | | | | | | | | | | | | | | | | | | | Previously we didn't have all possible name creation facilities covered with locks, so some of them silently misbehaved and caused much grief: http://groups.google.com/group/scala-internals/browse_thread/thread/ec1d3e2c4bcb000a. This patch gets all the name factories under control. Rather than relying on subclasses to override mutating methods and add synchronization, they should instead override `synchronizeNames` to return true and leave the placement of the locks up to `reflect.internal.Names`. These locks are placed around sections that mutate `typeHashtable` and `termHashtable`. This is done in the reflection universe, and in the interactive compiler. The latter change will obviate an incomplete attempt do to the same in `ScalaPresentationCompiler` in the scala-ide project.
* new bytecode emitter, GenBCode, for now under a flagMiguel Garcia2013-06-011-0/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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).
* Absolutized paths involving the scala package.Paul Phillips2013-05-031-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Confusing, now-it-happens now-it-doesn't mysteries lurk in the darkness. When scala packages are declared like this: package scala.collection.mutable Then paths relative to scala can easily be broken via the unlucky presence of an empty (or nonempty) directory. Example: // a.scala package scala.foo class Bar { new util.Random } % scalac ./a.scala % mkdir util % scalac ./a.scala ./a.scala:4: error: type Random is not a member of package util new util.Random ^ one error found There are two ways to play defense against this: - don't use relative paths; okay sometimes, less so others - don't "opt out" of the scala package This commit mostly pursues the latter, with occasional doses of the former. I created a scratch directory containing these empty directories: actors annotation ant api asm beans cmd collection compat concurrent control convert docutil dtd duration event factory forkjoin generic hashing immutable impl include internal io logging macros man1 matching math meta model mutable nsc parallel parsing partest persistent process pull ref reflect reify remote runtime scalap scheduler script swing sys text threadpool tools transform unchecked util xml I stopped when I could compile the main src directories even with all those empties on my classpath.
* Overhauled local/getter/setter name logic.Paul Phillips2013-03-251-13/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Sifted through extraneous methods trying to find consistency, consolidating and deprecating as I went. The original motivation for all this was the restoration of LOCAL_SUFFIX to originalName, because: It looks like in an attempt to make originalName print consistently with decodedName, I went a little too far and stripped invisible trailing spaces from originalName. This meant outer fields would have an originalName of '$outer' instead of '$outer ', which in turn could have caused them to be mis-recognized as outer accessors, because the logic of outerSource hinges upon "originalName == nme.OUTER". I don't know if this affected anything - I noticed it by inspection, improbably enough. Deprecated originalName - original, compared to what? - in favor of unexpandedName, which has a more obvious complement. Introduced string_== for the many spots where people have given up and are comparing string representations of names. A light dusting of types is still better than nothing. Editoral note: LOCAL_SUFFIX is the worst. Significant trailing whitespace! It's a time bomb.
* Address some ScaladocrotJason Zaugg2013-02-251-3/+3
| | | | | | - @param tags whose name drifted from the corresponding parameter - Remove or complete a few stray stub comments (@param foo ...) - Use @tparam where appropriate.
* Banish needless semicolons.Jason Zaugg2013-02-241-4/+4
|
* Adds extractors for TypeName, TermName and ModifiersDen Shabalin2012-12-251-0/+10
| | | | | | | | | | | This change allows to pattern match over type names, term names and modifiers. Otherwise it can be quite painful to match over complex trees as each name or modifiers requires a guard. This pull request also changes the name of default constructor for term and type names i.e. TypeName(s) instead of newTermName(s). This is shorter to type, more consistent with the rest of reflection api and consistent with the way it will be pattern matched later on.
* Remove Name -> TermName implicit.Paul Phillips2012-12-011-16/+5
| | | | And simplify the name implicits.
* Remove code from compiler central.Paul Phillips2012-11-201-2/+2
| | | | | All those old-timey methods whose melodies have become unfashionable.
* Members removed in scala.reflect.Paul Phillips2012-11-201-42/+2
| | | | | Not a bad showing for a newcomer. Of course most of this code predates scala.reflect by a lot.
* Revert "Commenting out unused members."Paul Phillips2012-11-191-32/+32
| | | | This reverts commit 951fc3a486.
* Commenting out unused members.Paul Phillips2012-11-191-32/+32
| | | | | | | | | | | | | | | | | | I want to get this commit into the history because the tests pass here, which demonstrates that every commented out method is not only unnecessary internally but has zero test coverage. Since I know (based on the occasional source code comment, or more often based on knowing something about other source bases) that some of these can't be removed without breaking other things, I want to at least record a snapshot of the identities of all these unused and untested methods. This commit will be reverted; then there will be another commit which removes the subset of these methods which I believe to be removable. The remainder are in great need of tests which exercise the interfaces upon which other repositories depend.
* Merge commit 'refs/pull/1574/head' into merge-210Paul Phillips2012-11-051-1/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * commit 'refs/pull/1574/head': (24 commits) Fixing issue where OSGi bundles weren't getting used for distribution. Fixes example in Type.asSeenFrom Fix for SI-6600, regression with ScalaNumber. SI-6562 Fix crash with class nested in @inline method Brings copyrights in Scaladoc footer and manpage up-to-date, from 2011/12 to 2013 Brings all copyrights (in comments) up-to-date, from 2011/12 to 2013 SI-6606 Drops new icons in, replaces abstract types placeholder icons SI-6132 Revisited, cleaned-up, links fixed, spelling errors fixed, rewordings Labeling scala.reflect and scala.reflect.macros experimental in the API docs Typo-fix in scala.concurrent.Future, thanks to @pavelpavlov Remove implementation details from Position (they are still under reflection.internal). It probably needs more cleanup of the api wrt to ranges etc but let's leave it for later SI-6399 Adds API docs for Any and AnyVal Removing actors-migration from main repository so it can live on elsewhere. Fix for SI-6597, implicit case class crasher. SI-6578 Harden against synthetics being added more than once. SI-6556 no assert for surprising ctor result type Removing actors-migration from main repository so it can live on elsewhere. Fixes SI-6500 by making erasure more regular. Modification to SI-6534 patch. Fixes SI-6559 - StringContext not using passed in escape function. ... Conflicts: src/actors-migration/scala/actors/migration/StashingActor.scala src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala src/compiler/scala/tools/nsc/settings/AestheticSettings.scala src/compiler/scala/tools/nsc/transform/Erasure.scala src/library/scala/Application.scala src/library/scala/collection/immutable/GenIterable.scala.disabled src/library/scala/collection/immutable/GenMap.scala.disabled src/library/scala/collection/immutable/GenSeq.scala.disabled src/library/scala/collection/immutable/GenSet.scala.disabled src/library/scala/collection/immutable/GenTraversable.scala.disabled src/library/scala/collection/mutable/GenIterable.scala.disabled src/library/scala/collection/mutable/GenMap.scala.disabled src/library/scala/collection/mutable/GenSeq.scala.disabled src/library/scala/collection/mutable/GenSet.scala.disabled src/library/scala/collection/mutable/GenTraversable.scala.disabled src/library/scala/collection/parallel/immutable/ParNumericRange.scala.disabled
| * Brings all copyrights (in comments) up-to-date, from 2011/12 to 2013Heather Miller2012-11-021-1/+1
| |
* | Remove unused private members.Paul Phillips2012-11-011-3/+7
|/ | | | | | | | | That's a lot of unused code. Most of this is pure cruft; a small amount is debugging code which somebody might want to keep around, but we should not be using trunk as a repository of our personal snippets of undocumented, unused, unintegrated debugging code. So let's make the easy decision to err in the removing direction. If it isn't built to last, it shouldn't be checked into master.
* Changed implementation comments from /** */ to /* */, so ScalaDoc remains ↵smessmer2012-09-211-1/+1
| | | | reasonable
* Eliminate breaking relative names in source.Paul Phillips2012-09-141-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These things are killing me. Constructions like package scala.foo.bar.baz import foo.Other DO NOT WORK in general. Such files are not really in the "scala" package, because it is not declared package scala package foo.bar.baz And there is a second problem: using a relative path name means compilation will fail in the presence of a directory of the same name, e.g. % mkdir reflect % scalac src/reflect/scala/reflect/internal/util/Position.scala src/reflect/scala/reflect/internal/util/Position.scala:9: error: object ClassTag is not a member of package reflect import reflect.ClassTag ^ src/reflect/scala/reflect/internal/util/Position.scala:10: error: object base is not a member of package reflect import reflect.base.Attachments ^ As a rule, do not use relative package paths unless you have explicitly imported the path to which you think you are relative. Better yet, don't use them at all. Unfortunately they mostly work because scala variously thinks everything scala.* is in the scala package and/or because you usually aren't bootstrapping and it falls through to an existing version of the class already on the classpath. Making the paths explicit is not a complete solution - in particular, we remain enormously vulnerable to any directory or package called "scala" which isn't ours - but it greatly limts the severity of the problem.
* Worked around SI-6161 by annotating abstract type.Paul Phillips2012-09-011-4/+8
|
* Made hashCode a method on Type to avoid megamorphic dispatchMartin Odersky2012-08-201-3/+0
| | | | | | | | | profiling data shows that accessing the hashCode field has a cost of about 10% of fully hot running times. We speculate that it's megamorphic dispatch which is costing us this much. Rewrote code so that UniqueType is not an abstract base class with the hashCode field. Also removed fingerPrinting bloom filter on findMember because it caused complexity and did not gain us anything accdoring to the tests. Made TypeVar an abstract case class to avoid extractor calls in TypeMap.
* update and normalize copyright noticeAdriaan Moors2012-08-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These are the regexp replacements performed: Sxcala -> Scala Copyright (\d*) LAMP/EPFL -> Copyright $1-2012 LAMP/EPFL Copyright (\d*)-(\d*)(,?) LAMP/EPFL -> Copyright $1-2012 LAMP/EPFL Copyright (\d*)-(\d*) Scala Solutions and LAMP/EPFL -> Copyright $1-2012 Scala Solutions and LAMP/EPFL \(C\) (\d*)-(\d*) LAMP/EPFL -> (C) $1-2012 LAMP/EPFL Copyright \(c\) (\d*)-(\d*)(.*?)EPFL -> Copyright (c) $1-2012$3EPFL The last one was needed for two HTML-ified copyright notices. Here's the summarized diff: Created using ``` git diff -w | grep ^- | sort | uniq | mate git diff -w | grep ^+ | sort | uniq | mate ``` ``` - <div id="footer">Scala programming documentation. Copyright (c) 2003-2011 <a href="http://www.epfl.ch" target="_top">EPFL</a>, with contributions from <a href="http://typesafe.com" target="_top">Typesafe</a>.</div> - copyright.string=Copyright 2002-2011, LAMP/EPFL - <meta name="Copyright" content="(C) 2002-2011 LAMP/EPFL"/> - * Copyright 2002-2011 LAMP/EPFL - * Copyright 2004-2011 LAMP/EPFL - * Copyright 2005 LAMP/EPFL - * Copyright 2005-2011 LAMP/EPFL - * Copyright 2006-2011 LAMP/EPFL - * Copyright 2007 LAMP/EPFL - * Copyright 2007-2011 LAMP/EPFL - * Copyright 2009-2011 Scala Solutions and LAMP/EPFL - * Copyright 2009-2011 Scxala Solutions and LAMP/EPFL - * Copyright 2010-2011 LAMP/EPFL - * Copyright 2012 LAMP/EPFL -# Copyright 2002-2011, LAMP/EPFL -* Copyright 2005-2011 LAMP/EPFL -/* NSC -- new Scala compiler -- Copyright 2007-2011 LAMP/EPFL */ -rem # Copyright 2002-2011, LAMP/EPFL ``` ``` + <div id="footer">Scala programming documentation. Copyright (c) 2003-2012 <a href="http://www.epfl.ch" target="_top">EPFL</a>, with contributions from <a href="http://typesafe.com" target="_top">Typesafe</a>.</div> + copyright.string=Copyright 2002-2012 LAMP/EPFL + <meta name="Copyright" content="(C) 2002-2012 LAMP/EPFL"/> + * Copyright 2002-2012 LAMP/EPFL + * Copyright 2004-2012 LAMP/EPFL + * Copyright 2005-2012 LAMP/EPFL + * Copyright 2006-2012 LAMP/EPFL + * Copyright 2007-2012 LAMP/EPFL + * Copyright 2009-2012 Scala Solutions and LAMP/EPFL + * Copyright 2010-2012 LAMP/EPFL + * Copyright 2011-2012 LAMP/EPFL +# Copyright 2002-2012 LAMP/EPFL +* Copyright 2005-2012 LAMP/EPFL +/* NSC -- new Scala compiler -- Copyright 2007-2012 LAMP/EPFL */ +rem # Copyright 2002-2012 LAMP/EPFL ```
* Merge pull request #906 from adriaanm/optimize-findmemberAdriaan Moors2012-07-191-0/+3
|\ | | | | Optimize findmember
| * Attempt #3 to optimize findMemberMartin Odersky2012-07-141-0/+3
| | | | | | | | Fixed fingerPrinting scheme to work with rehashes, also added finger prints to typedIdent searches.
* | Avoid conflict with String's apply.Paul Phillips2012-07-131-5/+5
| | | | | | | | | | | | This brought to light that Name extends (Int => Char), and that small convenience was not paying for itself. I updated the places taking advantage of it to use Name#charAt.
* | Implicits to encourage more Name-dropping.Paul Phillips2012-07-061-6/+17
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This creates implicits in cakes across the land from: String => TermName String => TypeName And also from: Name => NameOps[Name] // lower priority TermName => NameOps[TermName] TypeName => NameOps[TypeName] What this is all about, using "drop" as a motivating example, is that these should all work: "abc" drop 1 // "bc": String ("abc": TermName) drop 1 // "bc": TermName ("abc": TypeName) drop 1 // "bc": TypeName (("abc": TypeName): Name) drop 1 // "bc": Name But this should not: ("bc": Name) // ambiguity error This requires drop not being directly on Name; peer implicits from String => TermName and String => TypeName; implicit classes to install drop on TermName and TypeName; and a lower priority implicit class to allow ops on Names. Review by @xeno.by .
* Introduces scala-reflect.jarEugene Burmako2012-06-081-0/+527