summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
Commit message (Collapse)AuthorAgeFilesLines
* 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.
* Merge pull request #5648 from som-snytt/issue/10148Seth Tisue2017-02-161-2/+2
|\ | | | | SI-10148 Follow Java for float literals
| * SI-10148 Follow Java for float literalsSom Snytt2017-01-181-2/+2
| | | | | | | | | | Use `Float.parseFloat` instead of converting from Double. Error when a value rounds to zero.
* | 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 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-291-9/+9
| |
* | 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
| * | SI-9665 Backquoted vbar in extractor patternSom Snytt2016-03-151-2/+2
| | | | | | | | | | | | Allow an infix extractor named `|`, when backquoted.
* | | Keep Function when CBN arg thunk targets a SAMAdriaan Moors2016-03-301-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The body of `def delay[T](v: => T) = (v _): F0[T]` becomes `() => v` during `typedEta`, and then uncurry considers whether to strip the function wrapper since `v` is known to be a `Function0` thunk. Stripping is sound when the expected type is `Function0` for this expression, but that's no longer a given, since we could be expecting any nullary SAM. Also sweep up a bit around `typedEta`. Encapsulate the, erm, creative encoding of `m _` as `Typed(m, Function(Nil, EmptyTree))`.
* | | Remove -Y settings that are no longer used in 2.12Lukas Rytz2016-02-161-5/+0
|/ / | | | | | | | | | | Added a deprecation warning for `-optimize`. Later we'll also graduate `-Yopt` to `-opt`, probably for 2.12.0-M5.
* | Merge commit 'cc6fea6' into merge/2.11.x-to-2.12.x-20160203Jason Zaugg2016-02-041-3/+54
|\| | | | | | | | | | | Conflicts: build.sbt scripts/jobs/integrate/bootstrap
| * SI-9572 Check for illegal tuple sizes in the parserStefan Zeiger2016-01-281-3/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit adds explicit checks with syntax errors for tuple literals and types of more than 22 elements. An alternative approach to fixing SI-9572 would be to revert to the old failure mode of Scala 2.10 where references to arbitrary `scala.TupleXY` would be generated in the parser, which then leads to “type/object not found” errors in the typechecker. This fix here is more intrusive but arguably provides a better user experience. Methods `stripParens` and `makeBinop` are moved from `TreeBuilder` to `Parsers` because they can now generate syntax errors. New methods `makeSafeTupleType` and `makeSafeTupleTerm` implement the error checking on top of `makeTupleType` and `makeTupleTerm`. They are overridden with no-op versions in the quasiquotes parser because it also overrides `makeTupleType` and `makeTupleTerm` in a way that supports arbitrary tuple sizes.
* | Remove unused imports and other minor cleanupsSimon Ochsenreither2015-12-181-3/+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".
* | Merge commit 'bb3ded3' into merge-2.11-to-2.12-oct-5Lukas Rytz2015-10-051-2/+8
|\|
| * Improve presentation compilation of annotationsJason Zaugg2015-09-241-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A trio of problems were hampering autocompletion of annotations. First, given that that annotation is written before the annotated member, it is very common to end parse incomplete code that has a floating annotation without an anotatee. The parser was discarding the annotations (ie, the modifiers) and emitting an `EmptyTree`. Second, the presetation compiler was only looking for annotations in the Modifiers of a member def, but after typechecking annotations are moved into the symbol. Third, if an annotation failed to typecheck, it was being discarded in place of `ErroneousAnnotation`. This commit: - modifies the parser to uses a dummy class- or type-def tree, instead of EmptyTree, which can carry the annotations. - updates the locator to look in the symbol annotations of the modifiers contains no annotations. - uses a separate instance of `ErroneousAnnotation` for each erroneous annotation, and stores the original tree in its `original` tree.
| * Fix typo in the name of a private methodMichał Pociecha2015-08-231-5/+5
| | | | | | | | Since it's a private method, it's safe to just rename it.
* | Merge remote-tracking branch 'origin/2.11.x' into 2.12.xSeth Tisue2015-09-081-5/+5
| | | | | | | | | | | | | | | | only trivial merge conflicts here. not dealing with PR #4333 in this merge because there is a substantial conflict there -- so that's why I stopped at 63daba33ae99471175e9d7b20792324615f5999b for now
* | Merge remote-tracking branch 'origin/2.11.x' into ↵Jason Zaugg2015-05-011-1/+1
|\| | | | | | | merge/2.11.x-to-2.12.x-20150501
| * Fix many typosMichał Pociecha2015-04-211-1/+1
| | | | | | | | | | This commit corrects many typos found in scaladocs and comments. There's also fixed the name of a private method in ICodeCheckers.
* | Merge commit '32f520f' into merge/2.11-to-2.12-apr-1Lukas Rytz2015-04-011-2/+2
|\|
| * Removed warningsEECOLOR2015-03-261-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Added `since` to deprecation statement - Added unit to parameter list - Removed usage of deprecated method polyType - Replaced deprecated `debugwarn` with `devWarning` - Changed switch statement to if else in order to remove a warning - Switched implementation of `init` and `processOptions` to prevent warning - Replaced deprecated `Console.readLine` with `scala.io.StdIn.readLine` - Replaced deprecated `startOrPoint` with `start` - Replaced deprecated `tpe_=` with `setType` - Replaced deprecated `typeCheck` with `typecheck` - Replaced deprecated `CompilationUnit.warning` with `typer.context.warning` - Replaced deprecated `scala.tools.nsc.util.ScalaClassLoader` with `scala.reflect.internal.util.ScalaClassLoader` - Replaced deprecated `scala.tools.ListOfNil` with `scala.reflect.internal.util.ListOfNil` - Replaced deprecated `scala.tools.utils.ScalaClassLoader` with `scala.reflect.internal.util.ScalaClassLoader` - Replaced deprecated `emptyValDef` with `noSelfType` - In `BoxesRunTime` removed unused method and commented out unused values. Did not delete to keep a reference to the values. If they are deleted people might wonder why `1` and `2` are not used. - Replaced deprecated `scala.tools.nsc.util.AbstractFileClassLoader` with `scala.reflect.internal.util.AbstractFileClassLoader`
* | SI-8918 Unary ids are plain idsSom Snytt2015-02-081-5/+17
|/ | | | | | | | Allow +,-,!,~ to be used as unprefixed identifiers. As prefix operators, they must be followed by a simple expression, so otherwise, consume the id itself as the start of a simple expression.
* SI-6856 Fix incorrect EBNF in comment in ParsersJason Zaugg2014-11-071-1/+1
| | | | '&' isn't a prefix operator, perhaps to the chagrin of the C crowd.
* SI-8459 fix incorrect positions for incomplete selection treesghik2014-09-171-1/+1
| | | | | | The mentioned issue is a presentation compiler issue, but its root cause is a bug in the parser which incorrectly assigned positions to incomplete selection trees (i.e. selections that lack an indentifier after dot and have some whitespace instead). In detail: for such incomplete selection trees, the "point" of the position should be immediately after the dot but instead was at the start of next token after the dot. For range positions, this caused a pathological situation where the "point" was greater than the "end" of the position. This position is later used by the typechecker during resolution of dynamic calls and causes it to crash. Of course, because a syntactically incorrect code is required for the bug to manifest, it only happens in the presentation compiler.
* Merge pull request #3886 from adriaanm/report-filterGrzegorz Kossakowski2014-08-261-1/+1
|\ | | | | part 2 of the big error reporting refactoring
| * Move more parsing hooks out of reporting.Adriaan Moors2014-07-171-1/+1
| | | | | | | | | | | | Create a trait Parsing, which, like Reporting, factors our functionality from Global (aka. "the cake"), that is related to global aspects of configuring parsing.
* | SI-6476 Unitize ALL the procedures!Som Snytt2014-07-191-9/+9
| |
* | SI-6476 Unitize procedures, readabilitySom Snytt2014-07-191-20/+16
| | | | | | | | | | | | | | | | Strictly trivial updates for readability. I used to prefer procedure syntax, but since it was scheduled for removal, I can't scan a def without an equals sign.
* | SI-6476 DocumentationSom Snytt2014-07-181-0/+2
|/ | | | And adjust the test.
* Rip out reporting indirection from CompilationUnitAdriaan Moors2014-07-041-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Inline the forwarders from CompilationUnit, which should not affect behavior. Since all forwarders lead to global.reporter, don't first navigate to a compilation unit, only to then forward back to global.reporter. The cleanup in the previous commits revealed a ton of confusion regarding how to report an error. This was a mechanical search/replace, which has low potential for messing things up, since the list of available methods are disjoint between `reporter` and `currentRun.reporting`. The changes involving `typer.context` were done previously. Essentially, there are three ways to report: - via typer.context, so that reporting can be silenced (buffered) - via global.currentRun.reporting, which summarizes (e.g., deprecation) - via global.reporter, which is (mostly) stateless and straightforward. Ideally, these should all just go through `global.currentRun.reporting`, with the typing context changing that reporter to buffer where necessary. After the refactor, these are the ways in which we report (outside of typer): - reporter.comment - reporter.echo - reporter.error - reporter.warning - currentRun.reporting.deprecationWarning - currentRun.reporting.incompleteHandled - currentRun.reporting.incompleteInputError - currentRun.reporting.inlinerWarning - currentRun.reporting.uncheckedWarning Before: - c.cunit.error - c.enclosingUnit.deprecationWarning - context.unit.error - context.unit.warning - csymCompUnit.warning - cunit.error - cunit.warning - currentClass.cunit.warning - currentIClazz.cunit.inlinerWarning - currentRun.currentUnit.error - currentRun.reporting - currentUnit.deprecationWarning - currentUnit.error - currentUnit.warning - getContext.unit.warning - getCurrentCUnit.error - global.currentUnit.uncheckedWarning - global.currentUnit.warning - global.reporter - icls.cunit.warning - item.cunit.warning - reporter.comment - reporter.echo - reporter.error - reporter.warning - reporting.deprecationWarning - reporting.incompleteHandled - reporting.incompleteInputError - reporting.inlinerWarning - reporting.uncheckedWarning - typer.context.unit.warning - unit.deprecationWarning - unit.echo - unit.error - unit.incompleteHandled - unit.incompleteInputError - unit.uncheckedWarning - unit.warning - v1.cunit.warning All these methods ended up calling a method on `global.reporter` or on `global.currentRun.reporting` (their interfaces are disjoint). Also clean up `TypeDiagnostics`: inline nearly-single-use private methods.
* SI-8325 Accept infix star type outside patternsSom Snytt2014-05-051-9/+21
| | | | | | | | | | | | | | | This is a follow-up to SI-5702 which enabled use of `*` in infix notation in patterns. Most of the work is in distinguishing infix from a sequence pattern. Also, do not take backticked star as the repeated parameter marker in postfix position. That is, `Int``*``` is not `Int*` -- I hope double-tick renders as tick. There is not a special use case except that backticks mean "I am an identifier, as is, and not a keyword."
* SI-8333 can't use modifiers if class is in a blockDenys Shabalin2014-02-281-4/+4
| | | | | | Was caused by the ordering of parser cases. Need to check for definition first due to the fact that modifiers unquote looks like identifier from parser point of view.
* Merge remote-tracking branch 'origin/master' into topic/palladium0Eugene Burmako2014-02-161-7/+4
|\ | | | | | | | | | | | | | | Conflicts: src/compiler/scala/reflect/macros/compiler/Resolvers.scala src/compiler/scala/reflect/macros/contexts/Typers.scala src/compiler/scala/tools/reflect/ToolBoxFactory.scala src/reflect/scala/reflect/api/BuildUtils.scala
| * Merge pull request #3455 from densh/topic/patdefEugene Burmako2014-02-161-1/+1
| |\ | | | | | | Fix SI-8202 and improve support for splicing patterns into vals
| | * SI-8202 bug compatibility with SI-8211 for quasiquotesDenys Shabalin2014-02-091-1/+1
| | |
| * | SI-7711 Do not emit extra argv in script bodySom Snytt2014-02-141-6/+3
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | Take away `argv` and make `args` the standard parameter name. This is a quick fix to avoid "unused local" lint error. All the examples use `args`; in particular, "Step 4. Write some Scala scripts" in "Programming in Scala" uses `args`. I see the footnote there is also where Odersky concatenation is specified, `"Hello, "+ args(0) +"!"` with no space next to the literals. Also removes `argv` from `StdNames`. Was torn whether just to add `argc`. Maybe start a new project to house Names, emeritus.
* / disambiguates uses of “local” in internal symbol APIEugene Burmako2014-02-121-1/+1
|/ | | | | | | | | | | | | | | | | There’s been a conflation of two distinct meanings of the word “local” in the internal symbol API: the first meaning being “local to this” (as in has the LOCAL flag set), the second meaning being “local to block” (as in declared in a block, i.e. having owner being a term symbol). Especially confusing is the fact that sym.isLocal isn’t the same as sym.hasFlag(LOCAL), which has led to now fixed SI-6733. This commit fixes the semantic mess by deprecating both Symbol.isLocal and Symbol.hasLocalFlag (that we were forced to use, because Symbol.isLocal had already been taken), and replacing them with Symbol.isLocalToThis and Symbol.isLocalToBlock. Unfortunately, we can’t remove the deprecated methods right away, because they are used in SBT, so I had to take small steps.
* Merge pull request #3424 from som-snytt/issue/7322Adriaan Moors2014-02-011-1/+1
|\ | | | | SI-7322 Interpolator idents must be encoded
| * SI-7322 Interpolator idents must be encodedSom Snytt2014-01-291-1/+1
| | | | | | | | | | | | | | | | | | | | Otherwise, they are not found. This matters for term names with a differential encoding. Footnote, normally ident() encodes, but INTERPOLATIONID is !isIdent, so that is not used here. Maybe that would be the better improvement.