summaryrefslogtreecommitdiff
path: root/src/compiler
Commit message (Collapse)AuthorAgeFilesLines
* [nomaster] macro expansions are now auto-duplicatedEugene Burmako2013-08-141-3/+5
| | | | | | | | | | | | | | The fix still requires macro developers to be careful about sharing trees by references, because attributed DefTrees will still bring trouble. However this is an improvement, because it doesn't make matters worse and automatically fixes situations similar to one in the test. A much more thorough discussion with a number of open questions left: http://groups.google.com/group/scala-internals/browse_thread/thread/492560d941b315cc Was fixed ages ago in master in one of the paradise backports. Never got to 2.10.x, but it's very useful, so I'm backporting it now.
* SI-7331 tb.parse returns unpositioned treesDen Shabalin2013-08-081-5/+5
| | | | | | | | | | | | | | | This commit gets rid off code wrapping that was previously used by toolbox to get into correct parsing mode. Instead combination of templateStats/accept(EOF) is used. This is the same solution as the one used in repl and built-in scriptRunner This pull request doesn't attempt to generalize this approach in any way and re-use it all over the place due to the caution of possible accidental compatibility breakage. I plan to do it separately against master. Additionally there are a few more changes that make importers be aware of positions and a test for that (via @jedesah).
* Merge pull request #2767 from gourlaysama/t4907Adriaan Moors2013-08-051-2/+66
|\ | | | | SI-4907 SI-4615 scala.bat now honors -J and -D options.
| * SI-4907 SI-4615 scala.bat honors -J and -D options.Antoine Gourlay2013-07-281-2/+66
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This makes scala.bat parse and use -J and -D arguments. Specifically: - Parameters starting with -J are stripped of the prefix, unquoted if necessary and appended to %JAVA_OPTS% or default values. - Parameters starting with -D are unquoted if necessary and then appended to the others. The right-hand side of a property can be quoted or not. - All of those are given to `java` before any other parameters. - The above only happens on parameter preceding the first parameter that does not start with "-" (usually a class name). - The exact arguments passed to scala.bat are also given as-is to the scala launcher (including -J and -D arguments). set JAVA_OPTS=-Xmx512m scala -J-Xmx128m -Dprop1=42 -Dprop2="hello world" "-Dprop3=bar" "-J-Xms64m" Test foo will result in java -Xmx512m -Xmx128m -Dprop1=42 -Dprop2="hello world" -Dprop3=bar -Xms64m [cp, scala main] -J-Xmx128m -Dprop1=42 -Dprop2="hello world" "-Dprop3=bar" "-J-Xms64m" Test foo
* | Merge pull request #2750 from retronym/ticket/7455-2.10.xGrzegorz Kossakowski2013-07-271-2/+11
|\ \ | | | | | | SI-7455 Drop dummy param for synthetic access constructor
| * | SI-7455 Drop dummy param for synthetic access constructorJason Zaugg2013-07-281-2/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Java synthesizes public constructors in private classes to allow access from inner classes. The signature of that synthetic constructor (known as a "access constructor") has a dummy parameter appended to avoid overloading clashes. javac chooses the type "Enclosing$1" for the dummy parameter (called the "access constructor tag") which is either an existing anonymous class or a synthesized class for this purpose. In OpenJDK, this transformation is performed in: langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java (Incidentally, scalac would just emits a byte-code public constructor in this situation, rather than a private constructor / access constructor pair.) Scala parses the signature of the access contructor, and drops the $outer parameter, but retains the dummy parameter. This causes havoc when it tries to parse the bytecode for that anonymous class; the class file parser doesn't have the enclosing type parameters of Vector in scope and crash ensues. In any case, we shouldn't allow user code to see that constructor; it should only be called from within its own compilation unit. This commit drops the dummy parameter from access constructor signatures in class file parsing.
* | | Merge pull request #2738 from retronym/ticket/7636Grzegorz Kossakowski2013-07-271-0/+2
|\ \ \ | | | | | | | | SI-7636 Fix a NPE in typing class constructors
| * | | SI-7636 Fix a NPE in typing class constructorsChristopher Vogt2013-07-161-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | If we encountered an erroneous super call due to a failure in parent type argument inference, we must avoid inspecting the untyped children of erroneous trees.
* | | | Merge pull request #2762 from gourlaysama/t7687Grzegorz Kossakowski2013-07-271-1/+1
|\ \ \ \ | | | | | | | | | | SI-7687 Handle spaces in %COMSPEC% path in scala.bat.
| * | | | SI-7687 Handle spaces in %COMSPEC% path in scala.bat.Antoine Gourlay2013-07-231-1/+1
| | |_|/ | |/| | | | | | | | | | | | | | Double quoted %COMSPEC% to allow for spaces in the path to the default interpreter (cmd.exe or equivalent).
* / | | [backport] SI-7569 Fix end position in PostfixSelect treeFrançois Garillot2013-07-241-1/+1
|/ / / | | | | | | | | | | | | | | | | | | introduced in 5b54681: the end position of Postfix operators should take the operator length into account. review by @som-snytt
* / / SI-7657 clarifies the "macro overrides method" ruleEugene Burmako2013-07-141-2/+2
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently we allow macros to override non-abstract methods (in order to provide performance enhancements such as foreach for collections), and we also disallow macros to override abstract methods (otherwise downcasting might lead to AbstractMethodErrors). This patch fixes an oversight in the disallowing rule that prohibited macros from overriding a concrete method if that concrete method itself overrides an abstract method. RefCheck entertains all overriding pairs, not only the immediate ones, so the disallowing rule was triggered. Now macros can override abstract methods if and only if either the base type or the self type contain a matching non-abstract method.
* | Merge pull request #2721 from retronym/ticket/7649Adriaan Moors2013-07-121-8/+8
|\ \ | | | | | | SI-7649 Fix positions for reshaped tag materializers
| * | SI-7649 Fix positions for reshaped tag materializersJason Zaugg2013-07-111-8/+8
| |/ | | | | | | | | | | | | | | | | | | Calls to `materializeClassTag[T]` are replaced during reification with `implicitly[ClassTag[T]]` in the `reify` macro. This is done to avoid referring to symbols in scala-compiler.jar. Class- and Type-Tag materialization is treated in the same way. This commit positions the replacement trees to avoid triggering assertions under -Yrangepos.
* | Merge pull request #2689 from scalamacros/ticket/7617Adriaan Moors2013-07-121-3/+6
|\ \ | | | | | | SI-7617 typedAssign no longer expands lhs
| * | SI-7617 typedAssign no longer expands lhsEugene Burmako2013-07-091-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This makes sure that setter and updateDynamic macros work as intended rather than in some cases expanding incorrectly or prematurely. Setter invocations are desugared from assignments of values to getters. If a typecheck of an assignment's lhs yields an invocation of a getter, then the assignment is rewritten into an invocation of a setter. However if a getter is a macro, then it just expands, destroying the prerequisite for desugaring. Therefore we need to disable expansion for the typecheck of an lhs. Similar thing happens to updateDynamic that first desugars a getter invocation into q"$target.updateDynamic($fieldName)" and then expects typedAssign to rewrite the corresponding Assign node into an additional application of a partially applied updateDynamic to a rhs. Here we also need to disable the typecheck of an lhs, because macros cannot be partially applied.
| * | makes it more convenient to work with SuppressMacroExpansionAttachmentEugene Burmako2013-06-281-2/+2
| | |
* | | SI-7638 Superaccessor lookup after specializationVlad Ureche2013-07-081-1/+1
| |/ |/| | | | | | | | | | | | | | | | | | | | | | | The crash was caused by a symbol lookup to rewire the super calls, done after pickler, but specialization added new traits and new members, thus making the super rewiring impossible. To avoid such problems, this patch moves symbol lookup after specialization, so the changes done by specialization (and miniboxing) become visible to mixin. NOTE: This patch will be followed by a similar patch to master. Review by @adriaanm or @retronym.
* | Merge pull request #2680 from retronym/ticket/7603Adriaan Moors2013-06-271-3/+12
|\ \ | | | | | | SI-7603 Speculative fix for annotation binding error
| * | SI-7603 Speculative fix for annotation binding errorJason Zaugg2013-06-241-3/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Reports of: error: trait Test is abstract; cannot be instantiated 11:09:50 [ant:scalac] @Test def testClientRequestNum = { 11:09:50 [ant:scalac] ^ Suggest that the deferred processing of a LazyAnnotationInfo is binding the identifier `Test` to the wrong symbol. Inspection of the code shows that the closure also defers capture of the (mutable) field `Namer#typer.context`. This commit captures the context eagerly, and adds logging to let us know if that eagerly captured context ever differs from the its value at the point when the annotation info is forced. I spent a few hours trying to craft a test to back this up, but to no avail. Here's what the log output will look like: [log typer] The var `typer.context` in scala.tools.nsc.typechecker.Namers$NormalNamer@1f5ebb08 was mutated before the annotation new a() was forced. current value = Context(C@Import unit=<console> scope=123861466 errors=false, reportErrors=true, throwErrors=false) original value = Context(C@Import unit=<console> scope=123861466 errors=false, reportErrors=true, throwErrors=false) This confirms the hypothesis for the cause of SI-7603. If you see this message, please comment on that ticket.
* | | Merge pull request #2655 from VladUreche/issue/7344Adriaan Moors2013-06-261-24/+94
|\ \ \ | | | | | | | | SI-7344 Specialize methods in private scopes
| * | | SI-7344 Specialize methods in private scopesVlad Ureche2013-06-251-24/+94
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This performs method specialization inside a scope other than a {class, trait, object}: could be another method or a value. This specialization is much simpler, since there is no need to record the new members in the class signature, their signatures are only visible locally. It works according to the usual logic: - we use normalizeMember to create the specialized symbols - we leave DefDef stubs in the tree that are later filled in by tree duplication and adaptation The solution is limited by SI-7579: since the duplicator loses the sym annotations when duplicating, this expansion and rewiring can only take place in code that has not been subject to duplication. You can see the test case for an example. Review by @dragos, @paulp or @axel22.
* | | Merge pull request #2648 from retronym/ticket/7571Grzegorz Kossakowski2013-06-251-2/+2
|\ \ \ | |/ / |/| | SI-7571 Allow nesting of anonymous classes in value classes
| * | SI-7571 Allow nesting of anonymous classes in value classesJason Zaugg2013-06-191-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 5d9cde105e added deep prohibition of nested classes within a value class. This has the undesirable side effect of prohibiting partial functions literals in method bodies of a value class. The intention of that prohibition was to avoid problems in code using Type Tests, such as: class C(val inner: A) extends AnyVal { class D } def foo(a: Any, other: C) = a match { case _ : other.D } Here, the pattern usually checks that `a.$outer == other`. But that is incongruent with the way that `other` is erased to `A`. However, not all nested classes could lead us into this trap. This commit slightly relaxes the restriction to allow anonymous classes, which can't appear in a type test. The test shows that the translation generates working code.
* | | SI-7343 Fixed phase ordering in specializationVlad Ureche2013-06-122-2/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Specialization rewires class parents during info transformation, and the new info then guides the tree changes. But if a symbol is created during duplication, which runs after specialization, its info is not visited and thus the corresponding tree is not specialized. One manifestation is the following: ``` object Test { class Parent[@specialized(Int) T] def spec_method[@specialized(Int) T](t: T, expectedXSuper: String) = { class X extends Parent[T]() // even in the specialized variant, the local X class // doesn't extend Parent$mcI$sp, since its symbol has // been created after specialization and was not seen // by specialzation's info transformer. ... } } ``` We can fix this by forcing duplication to take place before specialization. Review by @dragos, @paulp or @axel22.
* | | Removed redundant `retypedMethod` in `Duplicators`Vlad Ureche2013-06-121-18/+2
|/ / | | | | | | | | | | It was never used since its introduction in 3ee6b3653 by @dragos. Review by @dragos or @axel22 or @paulp.
* | Merge pull request #2611 from retronym/ticket/6481Paul Phillips2013-06-081-1/+4
|\ \ | |/ |/| SI-6841 Fix bug at the intersection of DelayedInit and named args
| * SI-6841 Fix bug at the intersection of DelayedInit and named argsJason Zaugg2013-05-301-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The DelayedInit transformation analyses the constructor to partition regular initialization from calls to super constructors / trait initializers. It failed to find such super calls if they were nested in a Block, which can happens when using named or default arguments. This commit makes that code peer into Blocks to correctly partition the constructor statements. This change doesn't affect the result of run/t4680.scala, which was mentioned in nearby comments and which chronicles bugs with DelayedInit when used in inheritance hierarchies.
* | Merge pull request #2619 from scalamacros/ticket/7375Eugene Burmako2013-06-021-2/+5
|\ \ | |/ |/| SI-7375 ClassTag for value class aliases
| * SI-7375 ClassTag for value class aliasesEugene Burmako2013-05-311-2/+5
| | | | | | | | reifyRuntimeClass now always dealiases its argument prior to processing.
* | Merge pull request #2578 from retronym/ticket/6138Adriaan Moors2013-05-292-7/+1
|\ \ | |/ |/| SI-6138 Centralize and refine detection of `getClass` calls
| * SI-6138 Centralize and refine detection of `getClass` callsJason Zaugg2013-05-232-7/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `getClass` is special cased in the compiler; this is described in in the comments on `Definitions.Any_getClass`. Part of this happens in `Typer#stabilize`. This was trying to determine if an Ident or Select node was a call to `getClass` by merits of the name of the tree's symbol and by checking that the its type (if it was a MethodType or PolyType) had no parameters in the primary parameter list. Overloaded user defined `getClass` methods confused this check. In the enclosed test case, the tree `definitions.this.getClass` had an `OverloadedType`, and such types always report an empty list of `params`. This commit: - changes `stabilize` to use `isGetClass`, rather than the homebrew check - changes `isGetClass` to consider a `Set[Symbol]` containing all `getClass` variants. This moves some similar code from `Erasure` to `Definitions` - keeps a fast negative path in `isGetClass` based on the symbol's name
* | SI-7473 Bad for expr crashes postfixSom Snytt2013-05-232-5/+10
|/ | | | | | This commit makes building PostfixSelect robust against a bad pos on its operand, which can happen if a bad for expression results in an EmptyTree.
* Merge pull request #2506 from scalamacros/ticket/7461Eugene Burmako2013-05-202-2/+2
|\ | | | | c.typeCheck(silent = true) now suppresses ambiguous errors
| * c.typeCheck(silent = true) now suppresses ambiguous errorsEugene Burmako2013-05-092-2/+2
| | | | | | | | | | | | Otherwise use cases like the one shown in the attached test (trying to typecheck something, which leads to an ambiguous overload error) will mysteriously fail compilation.
* | Merge pull request #2530 from kzys/jira-6424Adriaan Moors2013-05-171-9/+25
|\ \ | | | | | | SI-6424 Scaladoc: Use mapNodes.get(_) to avoid NoSuchElementException
| * | SI-6424 Scaladoc: Use mapNodes.get(_) to avoid NoSuchElementExceptionKato Kazuyoshi2013-05-151-9/+25
| | | | | | | | | | | | Use mapNodes.get(_) instead of mapNodes(_) to avoid NoSuchElementException.
* | | Merge pull request #2549 from vigdorchik/slash_slashAdriaan Moors2013-05-171-4/+1
|\ \ \ | | | | | | | | Prevent slash duplication.
| * | | Prevent slash duplication.Eugene Vigdorchik2013-05-171-4/+1
| | | | | | | | | | | | | | | | | | | | Don't add trailing slash to external doc URL if it already ends with one.
* | | | SI-7486 regression in implicit resolution.Paul Phillips2013-05-171-3/+7
|/ / / | | | | | | | | | What a touchy beast the compiler is.
* | | Merge pull request #2497 from scalamacros/topic/macro-qqqJason Zaugg2013-05-173-21/+33
|\ \ \ | | | | | | | | easy way of writing not implemented macros
| * | | easy way of writing not implemented macrosEugene Burmako2013-05-123-21/+33
| |/ / | | | | | | | | | | | | | | | Even though it's easy to mark regular method bodies as stubs (using ???), there's no simple way of doing the same for macro methods. This patch fixes the inconvenience.
* | | Fix for unreachable code warning.Paul Phillips2013-05-161-2/+1
| | | | | | | | | | | | Oops, I miss when unreachable code was an error.
* | | Merge pull request #2537 from adriaanm/ticket-5886Paul Phillips2013-05-161-22/+1
|\ \ \ | | | | | | | | SI-5886 Remove check for packed type conformance.
| * | | SI-5886 Remove check for packed type conformance.Jason Zaugg2013-05-151-22/+1
| |/ / | | | | | | | | | | | | | | | | | | Nothing breaks. Why did by-name arguments have this extra check? What's the difference to a () => T? The check was added originally in 8414eba.
* / / Actual SI-6555 fix, Scaladoc filter works WITH keyboard shortcuts tooHeather Miller2013-05-121-7/+10
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit daefab18b8b0c170c372991022357413ec69b2af attempted to fix a bug related to Scaladoc filtering, meanwhile breaking Scaladoc keyboard shortcuts. Before commit daefab18b8b0c170c372991022357413ec69b2af, Scaladoc's filter wouldn't consider the last character of a search term entered into the (left) Scaladoc filter pane, but toggling with the `tab` key between filter panes did work. After daefab18b8b0c170c372991022357413ec69b2af, Scaladoc's left pane filter correctly searches for the full search term, but pressing the `tab` key causes the "focus" of the input bar to be stuck on the filter panel in the right Scaladoc filter pane, rendering it useless. End result: annoying Scaladoc interface bug present in 2.10.1, but which wasn't present in 2.10.0. This pull request fixes this, enabling both behaviors. The `tab` key toggle needed to be triggered on a `keydown` event (currently it's not), while everything else is fine to be triggered on a `keyup` event. This pull request enables the correct behavior by binding both a `keydown` and a `keyup` event rather than lumping everything all together in a `keyup` event (as was the case before).
* | Merge pull request #2494 from scalamacros/ticket/5923Eugene Burmako2013-05-1112-69/+248
|\ \ | | | | | | makes sense of implicit macros!
| * | [nomaster] removes duplication in inferImplicitValueEugene Burmako2013-05-113-50/+28
| | | | | | | | | | | | Shame-driven development at its best.
| * | [nomaster] SI-7166 catches DivergentImplicit in c.inferImplicitXXXEugene Burmako2013-05-112-20/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | Despite inferImplicit usually being nice and buffering errors, apparently it can also throw DivergentImplicit exception. This patch catches it and only reports it if silent is set to false. NOTE: we no longer have the DivergentImplicit exception in master, so this commit only makes sense in 2.10.x.
| * | [nomaster] SI-7047 fixes silent for c.inferImplicitXXXEugene Burmako2013-05-112-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | silent = true now throws a TypecheckException even if we don't know why an implicit search has failed (i.e. if context.hasErrors is false). NOTE: this commit is a part of a pull request for 2.10.x, which makes sense of implicit macros. Everything in that pull request is [nomaster] due to one reason or another. This commit would work equally well in both 2.10.x and master, but I'm marking it as [nomaster] as well, because I'm anyway going to resubmit the whole pull request into master soon, so there's no reason to introduce additional confusion.