summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/ast
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #5402 from som-snytt/issue/8040-unusedSeth Tisue2017-04-102-16/+20
|\ | | | | SI-8040 Improve unused warnings
| * SI-8040 Warn patvars in casedefsSom Snytt2017-03-111-20/+15
| | | | | | | | | | | | | | | | Collect bindings in casedefs unless "@-bound to _". Also minor refactor to make it easier to see the cases of `id @ _`. Tupled matching is supposed to be efficient either now or soon.
| * SI-8040 Warn unused flagsSom Snytt2017-03-112-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Introduce `-Ywarn-unused:x,y,z` and exploit `-Ywarn-unused:patvars`. Although the tree attachment for shielding patvars from warnings is not structural, sneaking the settings flag into the reflection internal TreeGen is awkward. Add test to ensure isolation of patvars warning from others. `-Ywarn-unused-import` is an alias for `-Ywarn-unused:imports`. `-Xlint:unused` is an alias for `-Ywarn-unused`, but not enabled yet. The help text advises to use `-Ywarn-unused`. The future can decide if `-Xlint:unused-imports` is warranted.
| * SI-8040 Heeding -Ywarn-unusedSom Snytt2017-03-111-3/+2
| | | | | | | | | | | | | | Polish notation, as in shoe-shine, as recommended by the warning. Minor clean-ups as advocated by `Ywarn-unused` and `Xlint`.
| * SI-8040 Warn unused pattern varsSom Snytt2017-03-111-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | Warn for unused `case X(x) =>` but, as an escape hatch, not for `case X(x @ _) =>`. The latter form is deemed documentary. (Named args could serve a similar purpose, `case X(x = _) =>`.) An attachment is used to mark the bound var, and the symbol position is used to correlate the identifier with the variable that is introduced. This mechanism doesn't work yet when only a single var is defined.
* | Fix Greek Mythology references in compiler packageJanek Bogucki2017-04-103-4/+4
|/ | | | | | | Improve documentation some packages and correct some typos in these directories, - compiler - library
* Revert "SI-10133 Require escaped single quote char lit"Adriaan Moors2017-02-211-18/+6
|
* Merge pull request #5629 from som-snytt/issue/10120-quote-errAdriaan Moors2017-02-201-6/+18
|\ | | | | SI-10133 Require escaped single quote char lit
| * SI-10120 Extra advice on unclosed char literalSom Snytt2017-01-081-6/+13
| | | | | | | | | | | | | | | | | | | | Folks from other languages might mistakenly enclose a string in single quotes. Since this presents as a symbol literal followed by the unpaired single quote, we can add a syntax reminder. Also polish the wording for bad string interpolation.
| * SI-10133 Require escaped single quote char litSom Snytt2017-01-081-0/+5
| | | | | | | | | | | | The spec specifically requires `'\''` and not `'''`. The error consumes all consecutive single quotes.
* | SI-10148 Accept verbose zeroSom Snytt2017-02-181-4/+4
| | | | | | | | The test for non-zero must recognize `-0e+00f` and variants.
* | Merge pull request #5648 from som-snytt/issue/10148Seth Tisue2017-02-162-8/+30
|\ \ | | | | | | SI-10148 Follow Java for float literals
| * | SI-10148 Follow Java for float literalsSom Snytt2017-01-182-8/+30
| |/ | | | | | | | | Use `Float.parseFloat` instead of converting from Double. Error when a value rounds to zero.
* | Merge pull request #5245 from dwijnand/trailing-commasAdriaan Moors2017-02-081-0/+11
|\ \ | | | | | | SI-4986 The glorious return of Comma McTraily
| * | SIP-27 Tweak and test wildstar in REPLDale Wijnand2017-01-081-2/+5
| | | | | | | | | | | | From https://github.com/scala/scala/pull/5245#issuecomment-266658070
| * | SI-4986 SIP-27 Trailing Comma (multi-line only) supportDale Wijnand2016-12-111-0/+8
| |/
* | SI-10097 Adapt unless -Xsource:2.13Som Snytt2016-12-141-3/+12
| | | | | | | | | | | | For 2.12 migration, insert missing case class param section, strip caseaccessor from implicit paramsection, and deprecate the adaptation.
* | SI-8704 Also warn if effectively multiple implicitSom Snytt2016-12-141-0/+6
| | | | | | | | | | | | | | | | | | | | | | Current semantics are that leading implicit param turns the parameter section into an implicit section (though without making other params implicitly implicit). Warn if more than one head of a param section is implicit, since that results in multiple implicit param sections.
* | SI-8704 Error on bad implicit sectionsSom Snytt2016-12-141-13/+19
| | | | | | | | | | | | | | Instead of aborting when a class def has extra parameter section, take all parameter sections and sanity check the use of leading implicit to indicate an implicit parameter section.
* | SI-10097 Error if no non-implicit case class paramSom Snytt2016-12-141-5/+10
|/ | | | | | | | | | Case class must have a non-implicit param list. Error early, error often. Also update spec to say that class implicitly gets a non-implicit parameter section if it doesn't have one, and that a case class must have one.
* Merge pull request #5440 from som-snytt/issue/9944Lukas Rytz2016-11-161-2/+11
|\ | | | | SI-9944 Scan after interp expr keeps CR
| * SI-9944 Scan after interp expr keeps CRSom Snytt2016-10-011-2/+11
| | | | | | | | | | | | In an interpolated expression `s"""${ e }"""`, the scanner advances input past the RBRACE. If a multiline string as shown, get the next raw char, because CR is significant.
* | Factor out some more into ScaladocScannerAdriaan Moors2016-10-191-1/+1
| |
* | DocScanner has doc-comment scanning hooks.Adriaan Moors2016-10-191-15/+30
|/ | | | | | | Align the Scala and Java doc comment scanning methods a bit. The Scala one especially had gotten a bit messy, with regular block comments being kind of accumulated, but never actually registered as DocComments.
* Double-checked locking for modules.Adriaan Moors2016-08-291-20/+1
| | | | Inline `mkSynchronizedCheck`, whose abstraction obscured rather than clarified.
* [refactor] lazy val expansion in mixins/lazyvalsAdriaan Moors2016-08-291-9/+8
| | | | Towards expanding lazy vals and modules during fields phase.
* Javadoc: fix problems in community buildJakob Odersky2016-08-131-0/+8
| | | | | | | - fix initialization NPE in doc headers - fix assertion errors for java fields - ignore comments when deciding where to put interface methods - consider DocDefs when checking for constructors
* Fields phaseAdriaan Moors2016-08-111-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | One step towards teasing apart the mixin phase, making each phase that adds members to traits responsible for mixing in those members into subclasses of said traits. Another design tenet is to not emit symbols or trees only to later remove them. Therefore, we model a val in a trait as its accessor. The underlying field is an implementation detail. It must be mixed into subclasses, but has no business in a trait (an interface). Also trying to reduce tree creation by changing less in subtrees during tree transforms. A lot of nice fixes fall out from this rework: - Correct bridges and more precise generic signatures for mixed in accessors, since they are now created before erasure. - Correct enclosing method attribute for classes nested in trait fields. Trait fields are now created as MethodSymbol (no longer TermSymbol). This symbol shows up in the `originalOwner` chain of a class declared within the field initializer. This promoted the field getter to being the enclosing method of the nested class, which it is not (the EnclosingMethod attribute is a source-level property). - Signature inference is now more similar between vals and defs - No more field for constant-typed vals, or mixed in accessors for subclasses. A constant val can be fully implemented in a trait. TODO: - give same treatment to trait lazy vals (only accessors, no fields) - remove support for presuper vals in traits (they don't have the right init semantics in traits anyway) - lambdalift should emit accessors for captured vals in traits, not a field Assorted notes from the full git history before squashing below. Unit-typed vals: don't suppress field it affects the memory model -- even a write of unit to a field is relevant... unit-typed lazy vals should never receive a field this need was unmasked by test/files/run/t7843-jsr223-service.scala, which no longer printed the output expected from the `0 to 10 foreach` Use getter.referenced to track traitsetter reify's toolbox compiler changes the name of the trait that owns the accessor between fields and constructors (`$` suffix), so that the trait setter cannot be found when doing mkAssign in constructors this could be solved by creating the mkAssign tree immediately during fields anyway, first experiment: use `referenced` now that fields runs closer to the constructors phase (I tried this before and something broke) Infer result type for `val`s, like we do for `def`s The lack of result type inference caused pos/t6780 to fail in the new field encoding for traits, as there is no separate accessor, and method synthesis computes the type signature based on the ValDef tree. This caused a cyclic error in implicit search, because now the implicit val's result type was not inferred from the super member, and inferring it from the RHS would cause implicit search to consider the member in question, so that a cycle is detected and type checking fails... Regardless of the new encoding, we should consistently infer result types for `def`s and `val`s. Removed test/files/run/t4287inferredMethodTypes.scala and test/files/presentation/t4287c, since they were relying on inferring argument types from "overridden" constructors in a test for range positions of default arguments. Constructors don't override, so that was a mis-feature of -Yinfer-argument-types. Had to slightly refactor test/files/presentation/doc, as it was relying on scalac inferring a big intersection type to approximate the anonymous class that's instantiated for `override lazy val analyzer`. Now that we infer `Global` as the expected type based on the overridden val, we make `getComment` private in navigating between good old Skylla and Charybdis. I'm not sure why we need this restriction for anonymous classes though; only structural calls are restricted in the way that we're trying to avoid. The old behavior is maintained nder -Xsource:2.11. Tests: - test/files/{pos,neg}/val_infer.scala - test/files/neg/val_sig_infer_match.scala - test/files/neg/val_sig_infer_struct.scala need NMT when inferring sig for accessor Q: why are we calling valDefSig and not methodSig? A: traits use defs for vals, but still use valDefSig... keep accessor and field info in synch
* Merge pull request #5296 from retronym/ticket/SD-186Lukas Rytz2016-07-221-1/+1
|\ | | | | SD-186 Fix positions in trait method bytecode
| * SD-186 Fix positions in trait method bytecodeJason Zaugg2016-07-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Concrete, non private methods in traits are translated into a static method with an explicit `$this` parameter. After this translation, the references to `$this` (subistuted for `this` in user written code) where being positioned at the position of the method, which makes debugging unpleasant. This commit leaves the `Ident($this)` trees unpositioned. This is analagous to what we do in the body of extension methods, which is the other user of `ThisSubstitutor`. It would be more correct to copy the position of each `This` tree over to the substituted tree. That would let us set a breakpoint on a line that _only_ contained `this`. But in 99% of cases users won't be able to spot the difference, so I've opted for the tried and tested approach here.
* | SD-120 Non FunctionN lambdas should not be universally serializableJason Zaugg2016-07-221-8/+10
| | | | | | | | | | | | | | | | Instead, we follow the example set by javac, and predicate serializability of bot anon-class and invokedynamic-based lambdas on whether or not the SAM type extends java.io.Serializable. Fixes https://github.com/scala/scala-dev/issues/120
* | Retain javadoc comments in scaladocJakob Odersky2016-07-151-1/+1
|/ | | | | * Hook into java parser to generate doc comments * Generate empty trees for java implementation bodies
* Emit trait method bodies in staticsJason Zaugg2016-06-281-1/+2
| | | | | | | | | | | | | | | | | | | | And use this as the target of the default methods or statically resolved super or $init calls. The call-site change is predicated on `-Yuse-trait-statics` as a stepping stone for experimentation / bootstrapping. I have performed this transformation in the backend, rather than trying to reflect this in the view from Scala symbols + ASTs. We also need to add an restriction related to invokespecial to Java parents: to support a super call to one of these to implement a super accessor, the interface must be listed as a direct parent of the class. The static method names has a trailing $ added to avoid duplicate name and signature errors in classfiles.
* Merge commit '91b6944' into merge-2.11-to-2.12-june-19Lukas Rytz2016-06-191-1/+1
|\
| * SI-9245 Fresher name in Try and testSom Snytt2016-06-071-1/+1
| | | | | | | | | | | | | | | | Fresh name for catcher gets a dollar. "Here, have a dollar." Test due to retronym demonstrates possible conflict. Over the lifetime of the universe, surely at least one code monkey would type in that identifier to catch a banana.
* | Merge pull request #5157 from retronym/topic/lambda-staticsJason Zaugg2016-06-061-3/+47
|\ \ | | | | | | Lambda impl methods static and more stably named
| * | Drop local suffix in lambda impl method nameJason Zaugg2016-06-021-1/+1
| | |
| * | Treat self parameter as non-null in the optimizerLukas Rytz2016-06-011-1/+1
| | |
| * | Lambda impl methods static and more stably namedJason Zaugg2016-06-011-3/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The body of lambdas is compiled into a synthetic method in the enclosing class. Previously, this method was a public virtual method named `fully$qualified$Class$$anonfun$n`. For lambdas that didn't capture a `this` reference, a static method was used. This commit changes two aspects. Firstly, all lambda impl methods are now emitted static. An extra parameter is added to those that require a this reference. This is an improvement as it: - allows, shorter, more readable names for the lambda impl method - avoids pollution of the vtable of the class. Note that javac uses private instance methods, rather than public static methods. If we followed its lead, we would be unable to support important use cases in our inliner Secondly, the name of the enclosing method has been included in the name of the lambda impl method to improve debuggability and to improve serialization compatibility. The serialization improvement comes from the way that fresh names for the impl methods are allocated: adding or removing lambdas in methods not named "foo" won't change the numbering of the `anonfun$foo$n` impl methods from methods named "foo". This is in line with user expectations about anonymous class and lambda serialization stability. Brian Goetz has described this tricky area well in: http://cr.openjdk.java.net/~briangoetz/eg-attachments/lambda-serialization.html This commit doesn't go as far a Javac, we don't use the hash of the lambda type info, param names, etc to map to a lambda impl method name. As such, we are more prone to the type-1 and -2 failures described there. However, our Scala 2.11.8 has similar characteristics, so we aren't going backwards. Special case in the naming: Use "new" rather than "<init>" for constructor enclosed lambdas, as javac does. I have also changed the way that "delambdafy target" methods are identifed. Rather than relying on the naming convention, I have switched to using a symbol attachment. The assumption is that we only need to identify them from within the same compilation unit. This means we can distinguish impl metbods for expanded functions (ones called from an `apply` method of an ahead-of-time expanded anonfun class), from those that truly end up as targets for lambda metafactory. Only the latter are translated to static methods in this patch.
* | | Merge commit 'cba585d' into merge-2.11-to-2.12-june-1Lukas Rytz2016-06-011-44/+64
|\ \ \ | |/ / |/| / | |/
| * SI-4625 Warn on first non-toplevel onlySom Snytt2016-05-171-42/+46
| | | | | | | | | | | | Fixed the warning when main module is accompanied by snippets. Minor clean-up so even I can follow what is returned.
| * SI-4625 Warn when discarding script objectSom Snytt2016-05-171-4/+11
| | | | | | | | | | | | It's pretty confusing when your script object becomes a local and then nothing happens. Such as when you're writing a test and it takes forever to figure out what's going on.
| * SI-4625 Permit arbitrary top-level in scriptSom Snytt2016-05-161-1/+3
| | | | | | | | | | | | | | In an unwrapped script, where a `main` entry point is discovered in a top-level object, retain all top-level classes. Everything winds up in the default package.
| * SI-4625 App is a thingSom Snytt2016-05-161-1/+4
| | | | | | | | Scripting knows it by name.
| * SI-4625 Recognize App in scriptSom Snytt2016-05-161-1/+5
| | | | | | | | | | | | | | | | | | Cheap name test: if the script object extends "App", take it for a main-bearing parent. Note that if `-Xscript` is not `Main`, the default, then the source is taken as a snippet and there is no attempt to locate an existing `main` method.
* | Add since arg to deprecationWarning and use itSimon Ochsenreither2016-05-292-18/+18
| |
* | Merge pull request #4935 from som-snytt/issue/8044-tickvarAdriaan Moors2016-05-241-8/+8
|\ \ | | | | | | SI-8044 Allow binding backquoted varid in patterns
| * | SI-8044 Allow any id in explicit pattern bindingSom Snytt2016-05-201-4/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Allows arbitrary identifier in `X @ pat`, including non-varids. This goes to regularity. Users of this syntax are not likely to be confused by the "backquoted var id is stable" rule. Also for sequence pattern, `X @ _*`.
| * | SI-8044 Allow binding backquoted varid in patternsSom Snytt2016-05-201-7/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, a varid could not be backquoted, so that it was not possible to introduce variables with names such as `type` in a match expression. This commit allows backquoted varids in `case x @ _` and `case x: Int`. In neither position is a stable id accepted, that is, an id with leading uppercase. Therefore, this commit merely relaxes the backquoted varid to be taken as a normal varid in these contexts.
* | | Merge pull request #4988 from som-snytt/issue/backtick-barAdriaan Moors2016-05-201-2/+2
|\ \ \ | |/ / |/| | SI-9665 Backquoted vbar in extractor pattern