summaryrefslogtreecommitdiff
path: root/src/reflect/scala/reflect/internal/Mirrors.scala
Commit message (Collapse)AuthorAgeFilesLines
* Minor style cleanups, no changes in logicLukas Rytz2016-10-271-21/+0
|
* Don't follow type aliases in getClassByName and friendsLukas Rytz2016-10-261-1/+0
| | | | | | | | | | | | | | | | | | This makes getClassByName fail / getClassIfDefined return NoSymbol when querying an alias. The current behavior can confuse the classfile parser: when parsing a class, a cross-check verifies that `pool.getClassSymbol(nameIdx)` returns the symbol of the class currently being parsed. If there's a type alias that shadows the linked class, following the alias would return an unrelated class. (The cross-check didn't fail because there are some other guards around it) The logic to follow aliases was was added in ff98878, without a clear explanation. Note that `requiredClass[C]` works if `C` is an alias, it is expanded by the compiler.
* Remove TopLevelCreationFlagsLukas Rytz2016-06-061-1/+1
|
* Lower-case spelling of @deprecated messagesSimon Ochsenreither2016-05-281-1/+1
|
* Merge remote-tracking branch 'origin/2.11.x' into ↵Jason Zaugg2015-01-291-1/+1
|\ | | | | | | | | | | | | | | | | merge/2.11.x-to-2.12.x-20150129 Conflicts: build.number src/library/scala/concurrent/Future.scala versions.properties
| * Fix many typos in docs and commentsmpociecha2014-12-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | More uniform treatment of package objectsJason Zaugg2014-11-071-10/+1
|/ | | | | | | | | | | | | | | | | | | - Introduce `Symbol#packageObject` and `Type#packageObject` to lookup the member package object of a package class/module, and use this far and wide. - Replace the overly complicated (and still buggy) implementation of `Context#isInPackageObject` with a one liner. The simplifying insight is that if we select a symbol from a package prefix that does not own that symbol, it *must* have really been selected from the package object. - Change implicit search to use the cache in `ModuleSymbol#implicitMembers` via `Type#implicitMembers`, which lets the client code read more naturally. Fixes a bug with `adapt::insertApply` that Adriaan spotted in a feat of lateral thinking. This is tested in t8862b.scala. alladin763.scala adds the test case from the bug originally remedied by `insertApply` to check we haven't regressed.
* introduces Mirror.typeOfEugene Burmako2014-03-251-0/+2
| | | | | | | | | I just realized that our tag-based shortcuts were incomplete, because they only work with root mirrors (doing just u.typeTag[T].tpe means that the type is going to be resolved in u.rootMirror because that's the default). This commit fixes this oversight. I'm hoping for 2.11.0-RC3, but also feel free to reschedule to 2.12.0-M1 if it becomes clear that RC3 isn't happening.
* staticXXX now throw ScalaReflectionExceptionEugene Burmako2014-02-151-3/+6
| | | | | Previously this was scala.reflect.internal.MissingRequirementError, but that's not good enough for the public API.
* SI-6732 deprecates internal#Symbol.isPackageEugene Burmako2014-02-141-6/+6
| | | | | | | | This is the first step in disentangling api#Symbol.isPackage, which is supposed to return false for package classes, and internal#Symbol.isPackage, which has traditionally being used as a synonym for hasPackageFlag and hence returned true for package classes (unlike isModule which is false for module classes).
* SI-8133 Fix regression with package objects, overloadingJason Zaugg2014-01-141-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | Regressed in f5c336d56, a refactoring of `typedIdent`. In that commit, an (ostensibly) accidental change arrived, equivalent to: - val pre1 = if (qual == EmptyTree) NoPrefix else if (sym.isTopLevel) sym.owner.thisType else qual.tpe + val pre1 = if (sym.isTopLevel) sym.owner.thisType else if (qual == EmptyTree) NoPrefix else qual.tpe Here, `qual` is a tree returned in the successful result of `Context#lookup`. This change itself looks innocuous (top level symbols can be prefixed with a qualifier or not, right?), but it exposed us to a bug in `makeAccessible`. It is responsible for rewriting, e.g, `scala.List` to `scala.package.List`. It has a few cases, but one of them relies relies on typechecking `Ident(nme.PACKAGE)`, and hoping that it will bind to the right place. That's fraught with danger, and breaks in the enclosed tests. This commit binds that Ident symbolically, and in the process factors a tiny bit of code in common with `TreeGen`. (More work is still needed here!) In the next commit, I'm going to revert the change to `pre1`. That would have also fixed the regression, albeit symptomatically.
* makes well-known packages and package classes consistent with each otherEugene Burmako2013-12-291-1/+2
| | | | | | As discovered in https://groups.google.com/forum/#!topic/scala-user/RckXE90LoXo, RootClass.sourceModule and EmptyPackageClass.sourceModule used to incorrectly return NoSymbol instead of RootModule and EmptyPackage. This is now fixed.
* Removing deprecated code.Paul Phillips2013-11-181-10/+2
| | | | | Code which has been deprecated since 2.10.0 and which allowed for straightforward removal.
* cleans up initialization of runtime reflectionEugene Burmako2013-10-181-0/+13
| | | | | | | | | | | | | | | | | | | | | At first I just tried to remove syntheticCoreClasses from missingHook and put them into the initializer of freshly created mirrors in order to reduce the non-determinism in mutations of the global symbol table. And then it didn't work, crashing on me claiming that AnyRef is missing. Apparently we still need AnyRefClass in missingHook, just because it's impossible to initialize (i.e. unpickle) ScalaPackageClass without it. And then it still didn't work, whining about multiple overloaded defs of some synthetic symbols. That was really tricky, but I figured it out as well by initializing ScalaPackageClass first before forcing any synthetic symbols (see the details in comments). And then it worked, but stopped working half a year later when Jason and I came to revisit this old pull request. The final twist was pre-initializing ObjectClass, because it's a dependency of AnyRefClass, which is a critical dependency of ScalaPackageClass (full information can be found in comments).
* synchronizes symbolsEugene Burmako2013-10-181-12/+23
| | | | | | | | | | | | | | | Synchronization via decoration would be neat if it actually worked. Unfortunately, root symbols never got decorated, therefore their children also never got decorated and all the way down to the very turtles. This commit fixes this sad issue by turning root symbols from objects to lazy vals. Yes, this is going to induce a performance penalty, which will hopefully not be high enough to invalidate this cornerstone of our synchronization strategy. Now when root symbols are lazy vals, they can be overridden in the runtime reflexive universe and decorated with SynchronizedSymbol, which makes their children sync and sound.
* Set scene for Predef.$scope's demise.Jason Zaugg2013-06-201-0/+3
| | | | | | | | | | | When there's no Predef.$scope but xml is being used, the compiler aliases scala.xml.TopScope to $scope. There must be a scala.xml package when xml literals were parsed. For compatibility with the old library, which relied on $scope being in scope, synthesize a `import scala.xml.{TopScope => $scope}` when xml is needed, but there's no Predef.$scope and the old library is detected (scala.xml.TopScope exists).
* Absolutized paths involving the scala package.Paul Phillips2013-05-031-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* SI-7261 Implicit conversion of BooleanSetting to Boolean and BooleanFlagSom Snytt2013-03-271-1/+1
| | | | | | | This commit shortens expressions of the form `if (settings.debug.value)` to `if (settings.debug)` for various settings. Rarely, the setting is supplied as a method argument. The conversion is not employed in simple definitions where the Boolean type would have to be specified.
* Doc -> C-style comments for local symbols to avoid "discardingEugene Vigdorchik2013-03-211-2/+2
| | | | | unmoored doc comment" warning when building distribution for scala itself.
* adds c.introduceTopLevelEugene Burmako2013-01-051-1/+1
| | | | | | | | | | | | | | | | | | | The first in the family of mutators for the global symbol table, `introduceTopLevel` is capable of creating synthetic top-level classes and modules. The addition of nme.EMPTY_PACKAGE_NAME is necessary to let programmers insert definitions into the empty package. That's explicitly discouraged in the docs, but at times might come in handy. This patch introduce workarounds to avoid incompatibilities with SBT. First of all SBT doesn't like VirtualFiles having JFile set to null. Secondly SBT gets confused when someone depends on synthetic files added by c.introduceTopLevel. Strictly speaking these problems require changes to SBT, and that will be done later. However the main target of the patch is paradise/macros, which needs to be useful immediately, therefore we apply workarounds.
* Remove TermName -> String implicit.Paul Phillips2012-12-021-6/+7
| | | | | | | | | These implicits were crutches going back to a much Stringier time. Of course "with great type safety comes great verbosity" and no doubt this could be cleaned up significantly further. At least the underpinnings are consistent now - the only implicits involving name should be String -> TypeName and String -> TermName.
* Merge commit 'refs/pull/1574/head' into merge-210Paul Phillips2012-11-051-2/+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-2/+1
| |
* | Removing unused locals and making vars into vals.Paul Phillips2012-11-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | According to "git diff" the difference from master to this commit includes: Minus: 112 vals, 135 vars Plus: 165 vals, 2 vars Assuming all the removed ones were vals, which is true from 10K feet, it suggests I removed 80 unused vals and turned 133 vars into vals. There are a few other -Xlint driven improvements bundled with this, like putting double-parentheses around Some((x, y)) so it doesn't trigger the "adapting argument list" warning.
* | Fix performance bug in GenASM.Paul Phillips2012-10-311-1/+3
| | | | | | | | | | | | It was going through missingHook looking for android classes every time something was compiled, which means four failing missingHook calls for every line in the repl.
* | Fix for -Xcheckinit failures.Paul Phillips2012-10-311-0/+5
|/ | | | | | | | | | | | | | | | | | | | | | | The GenASM phase had an eager val which required loading a bunch of symbols, which meant an earlier call to isPastTyper could lead to a cycle of the form: new Run new GenASM rootMirror.getRequiredClass findMember defineBaseClassesOfCompoundType isPastTyper currentRun.typerPhase and the opening "new Run" hasn't yet caught up to where currentRun.typerPhase is set. This was remedied by making the eager val lazy, and substantially hardened against recurrence via a method on global "isGlobalInitialized" which verifies that both the definitions object and the root mirror have completed their init methods.
* MirrorOf => MirrorEugene Burmako2012-09-271-1/+1
| | | | | The name looks weird in the scaladoc overview panel, so I decided to do a last-minute rename.
* fixes mirrorThatLoaded in JavaMirrorsEugene Burmako2012-09-241-3/+9
| | | | | | | | | | | | | | | | | | `mirrorThatLoaded(sym: Symbol): Mirror` in JavaMirrors used to iterate over `lazy val mirrors = new WeakHashMap[ClassLoader, WeakReference[JavaMirror]]()` to find out what mirror has loaded a certain symbol. It worked okay until yesterday when I noticed failing tests, which crashed when weak references in mirrors were dereferenced with get.get. Apparently some mirrors were collected, and the logic in JavaMirror didn't account for that possibility. When fixing this bug, I noticed that mirrors can become unreachable even if there are still reachable symbols created by those mirrors. That doesn't make sense, therefore I fixed this bug as well by introducing a strong ref from root symbols to the enclosing mirror. Therefore, any active symbol will have a strong reference to the enclosing mirror by the virtue of the owner chain.
* SI-6201 minor fixes in key pointsEugene Burmako2012-08-111-2/+1
| | | | | | | | Fixes several oversights that led to 6201. RootPackage should have been static, refactored implementation of hasSymbolWhich shouldn't have checked hasSymbol. Full discussion is here: http://groups.google.com/group/scala-internals/browse_thread/thread/9500348f273a8aa.
* update and normalize copyright noticeAdriaan Moors2012-08-071-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 ```
* SI-5999 a real fix to the packageless problemEugene Burmako2012-07-201-41/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | After a discussion on a reflection meeting on Jul 17 we concluded that we should split staticModule into staticModule and staticPackage to remove the ambiguity between packageless objects and packageless packages (more in the comments in the body of the commit). The motivation is verbosely outlined in the comments, but the bottom line is that Scala allows packages and packageless objects to have the same name within the same program. Therefore at times we need to disambiguate, hence the introduction of the staticPackage method. As of such staticModule no longer works for packages. In the same fashion staticPackage doesn't work for modules. This is done to ensure robustness of reification. I would like to do the same for getModule in Definitions, but we have to maintain backward compatibility. That's why I retained the old behavior, but replaced getModule invocations with getPackage where appropriate to be in line with staticModule and staticPackage. Another important thing that follows from the discussion is that both staticClass and staticModule prefer parent packages over parent objects in cases of ambiguity. Say, if we have the following snippet of code: object B { class C } next to package B { class C } then staticClass("B.C") will never even consider a C inside the object B. This is how scalac operates, so we decided to be consistent here. Finally reification logic got changed to distinguish between staticModule and staticPackage, and to allow for the fact that staticClass and staticModule prefer parent packages to parent objects.
* SI-5999 staticXXX is now friendly to packagelessEugene Burmako2012-07-201-47/+77
|
* more meaningful name for a missing hook methodEugene Burmako2012-07-201-2/+2
|
* SI-5939 resident compilation of sources in empty packageMartin Odersky2012-07-191-2/+1
| | | | Empty packages can now be cleanly invalidated.
* SI-6036 yet again makes sense of magic symbolsEugene Burmako2012-07-061-2/+2
|
* SI-5990 u.build now correctly invokes missing symbol hooksEugene Burmako2012-07-031-1/+3
|
* Introduces scala-reflect.jarEugene Burmako2012-06-081-0/+243