summaryrefslogtreecommitdiff
path: root/spec/05-classes-and-objects.md
Commit message (Collapse)AuthorAgeFilesLines
* Improvements based on reviews by Lukas & JasonAdriaan Moors2017-04-061-3/+2
|
* Clarify spec of interaction of existing vs synthetic apply/unapplyAdriaan Moors2017-04-061-11/+10
| | | | | When matching user-defined apply/unapply members exist in a case class's companion object, don't add clashing synthetic ones.
* Merge pull request #5660 from som-snytt/issue/9464-specAdriaan Moors2017-02-201-4/+6
|\ | | | | SI-9464 Clarify spec on no final trait
| * SI-9464 Clarify spec on no final traitSom Snytt2017-01-241-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | Without being too finicky with syntax, say that `final abstract class` is OK (even as a nested class, where it would be an incomplete member) but not `final trait`. Such a class might be a standard lib primitive, or might be an implicit value that is only a ludicrous marker and, if present, need only have the null value.
* | SI-10097 Error if no non-implicit case class paramSom Snytt2016-12-141-6/+7
|/ | | | | | | | | | 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.
* Add language to code blocks in spec (#5502)Daniel Barclay2016-11-161-1/+1
| | | | | | | | | | | | | | | * Add "scala" language code to pure-Scala code blocks. * Add "java" language code to Java code block. * Add "scala" language code to almost-pure-Scala code blocks. Add "scala" language code to two code blocks whose content was Scala except for containing ellipses (\ldots). * Add "scala" language code to non-literal-Scala code blocks. Add "scala" language code to code blocks that contain Scala but also special elements, such as identifiers that are italicized or have prime marks (e.g., e′, e′′), ellipses (\ldots), etc.
* Typo and spelling correctionsJanek Bogucki2016-11-111-2/+2
|
* Change `...' to ‘...’ (Unicode quotes) in ENBF (per intent per README.md).Daniel Barclay2016-10-031-32/+32
| | | | Also added a missing closing quote in SimplePattern production involving StableId.
* Merge pull request #5355 from dsbos/dsbos-SpecEditsAdriaan Moors2016-08-221-3/+3
|\ | | | | Italicize more defining occurrences of terms in Scala lang. spec.
| * Editorial: Italicized more defining occurrences of terms.Daniel Barclay2016-08-211-3/+3
| |
* | Fields phaseAdriaan Moors2016-08-111-2/+2
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 remote-tracking branch 'origin/2.11.x' into 2.12.xSeth Tisue2015-09-081-1/+1
| | | | | | | | 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 pull request #4570 from marconilanna/patch-1Seth Tisue2015-06-241-1/+1
|\ | | | | Traits mistakenly set as 'Case Classes' subsection
| * Traits mistakenly set as 'Case Classes' subsectionMarconi Lanna2015-06-211-1/+1
| | | | | | | | | | Instead of being its own section, a minor formatting issue causes 'Traits' to be rendered and numbered as a subsection of the section 'Case Classes'. This patch changes the numbering on both 'Traits' and 'Object Definitions' sections.
* | Spec: Add lost references, cleanupSimon Ochsenreither2015-06-221-14/+12
|/
* Clarify the definition of inheritance closureYawarRaza73492015-06-051-0/+1
| | | | The definition now specifically mentions that C is an element of the inheritance closure of C.
* SI-9321 Clarify spec for inheritance of qualified privateJason Zaugg2015-05-221-4/+3
| | | | | | | | | I checked the intent with Martin, who said: > [...] qualified private members are inherited like other members, > it’s just that their access is restricted. I've locked this in with a test as well.
* Spec improvementsSimon Ochsenreither2015-04-251-5/+5
|
* Move all modifiers to the same levelsoc2015-03-191-7/+7
|
* 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.
* spec: fix broken links and anchors, including examplesAntoine Gourlay2014-09-171-1/+2
| | | | | | | For examples, the "name" of the example (like "Example Ordered") is only used to derived its html id so that one can link to it (see `layouts/default.yml`). Ideally all examples should have a name; here I only added enough to satisfy existing links.
* spec: remove trailing whitespace everywhereAntoine Gourlay2014-09-171-66/+44
|
* spec: fix latex formatting all over the placeAntoine Gourlay2014-09-171-10/+11
| | | | | | | | | Two things worth mentioning: - `\em` and `emph` are not supported by MathJax, - and things like `\mathcal{C}_0` require escaping the `_`, otherwise markdown sees it as the beginning of `_some string_`. It doesn't happen without the closing bracket in front, e.g. in `b_0`.
* Number files like chapters. Consolidate toc & preface.Adriaan Moors2014-03-281-0/+1173
Aside from the consolidation of title & preface in index.md, this commit was produced as follows: ``` cd spec/ g mv 03-lexical-syntax.md 01-lexical-syntax.md g mv 04-identifiers-names-and-scopes.md 02-identifiers-names-and-scopes.md g mv 05-types.md 03-types.md g mv 06-basic-declarations-and-definitions.md 04-basic-declarations-and-definitions.md g mv 07-classes-and-objects.md 05-classes-and-objects.md g mv 08-expressions.md 06-expressions.md g mv 09-implicit-parameters-and-views.md 07-implicit-parameters-and-views.md g mv 10-pattern-matching.md 08-pattern-matching.md g mv 11-top-level-definitions.md 09-top-level-definitions.md g mv 12-xml-expressions-and-patterns.md 10-xml-expressions-and-patterns.md g mv 13-user-defined-annotations.md 11-user-defined-annotations.md g mv 14-the-scala-standard-library.md 12-the-scala-standard-library.md g mv 15-syntax-summary.md 13-syntax-summary.md g mv 16-references.md 14-references.md perl -pi -e 's/03-lexical-syntax/01-lexical-syntax/g' *.md perl -pi -e 's/04-identifiers-names-and-scopes/02-identifiers-names-and-scopes/g' *.md perl -pi -e 's/05-types/03-types/g' *.md perl -pi -e 's/06-basic-declarations-and-definitions/04-basic-declarations-and-definitions/g' *.md perl -pi -e 's/07-classes-and-objects/05-classes-and-objects/g' *.md perl -pi -e 's/08-expressions/06-expressions/g' *.md perl -pi -e 's/09-implicit-parameters-and-views/07-implicit-parameters-and-views/g' *.md perl -pi -e 's/10-pattern-matching/08-pattern-matching/g' *.md perl -pi -e 's/11-top-level-definitions/09-top-level-definitions/g' *.md perl -pi -e 's/12-xml-expressions-and-patterns/10-xml-expressions-and-patterns/g' *.md perl -pi -e 's/13-user-defined-annotations/11-user-defined-annotations/g' *.md perl -pi -e 's/14-the-scala-standard-library/12-the-scala-standard-library/g' *.md perl -pi -e 's/15-syntax-summary/13-syntax-summary/g' *.md perl -pi -e 's/16-references/14-references/g' *.md ```