Skip to content

Commit ecf9128

Browse files
committed
Merge branch '2.11.x' into 2.12.x
Transcript: ``` ➜ scala git:(2.12.x) export MB=$(git merge-base 2.12.x 2.11.x) ➜ scala git:(2.12.x) echo $MB 0e9525a ➜ scala git:(2.12.x) g log --oneline --graph $MB...2.11.x ``` Read this upside down :-). The last merge comes first, with merge commands interspersed in the git log. ``` ➜ scala git:(2.12.x) g merge 2.11.x Auto-merging versions.properties Auto-merging src/reflect/scala/reflect/internal/pickling/UnPickler.scala Auto-merging src/reflect/scala/reflect/internal/Types.scala Auto-merging src/reflect/scala/reflect/internal/TreeGen.scala Auto-merging src/library/scala/collection/immutable/Stream.scala Auto-merging src/library/scala/collection/convert/Wrappers.scala Auto-merging build.xml CONFLICT (content): Merge conflict in build.xml Auto-merging README.md Automatic merge failed; fix conflicts and then commit the result. ``` ``` * 928e689 (scala/2.11.x, 2.11.x) Merge pull request scala#4682 from adriaanm/jline-quick.bin |\ | * b763dbf (adriaanm/jline-quick.bin, jline-quick.bin) Include jline on quick.bin tool path * | ccded7d Merge pull request scala#4680 from janekdb/2.11.x-option |\ \ | |/ |/| | * 58ae3e5 Delegate null test to Option |/ * a745f06 Merge pull request scala#4670 from retronym/ticket/9422 |\ | * ec95e53 SI-9422 Fix incorrect constant propagation * 65fa73d Merge pull request scala#4669 from janekdb/2.11.x-scaladoc-reflect |\ | * e206a18 ScalaDoc fixes for reflect * | 8e7e3b4 Merge pull request scala#4667 from janekdb/2.11.x-scaladoc-library-library-aux |\ \ | |/ |/| | * 69c2c10 ScalaDoc fixes for library and library-aux * | 7de4cbc Merge pull request scala#4665 from lrytz/asm-504-3 |\ \ | * | cdc55c2 Upgrade scala-asm to 5.0.4-scala-3 |/ / * | d8da39a Merge pull request scala#4661 from retronym/ticket/9365 |\ \ | * | 0c99742 SI-9365 Don't null out dependencies of transient lazy vals | / * | 2279d3f Merge pull request scala#4662 from janekdb/2.11.x-redundant-val-modifier |\ \ | * | 173a6fa Remove redundant 'val' from case class params. * | | e0d2143 Merge pull request scala#4664 from SethTisue/remove-dead-link-in-readme |\ \ \ | |_|/ |/| | | * | 600fc4e fix readme for death of typesafe.artifactoryonline.com | |/ * | 7492bda Merge pull request scala#4636 from SethTisue/contributor-stuff-from-github-wiki |\ \ | |/ |/| | * ed5098d merge two reviewers lists in readme | * e136e4a tighten up CONTRIBUTING.md a little | * f9ca686 readme/contributor's guide tweaks | * 80e98b0 tiny readme fix | * 1978456 merge in text from pull request policy from old wiki | * e93ca40 drop in pull request policy from old wiki | * 951939d contributor guide: add a morsel salvaged from GitHub wiki * f682441 Merge pull request scala#4653 from lrytz/t9403 |\ | * 2678d34 SI-9403 fix ICodeReader for negative BIPUSH / SIPUSH values ``` ``` ➜ scala git:(2.12.x) g merge -s ours f2d7838 Merge made by the 'ours' strategy. ``` ``` * f2d7838 Merge pull request scala#4657 from lrytz/backports |\ | * 241bb9a Rename the ENUM / DEFAULTMETHOD flags to include JAVA_ | * 7a7f992 SI-9393 fix modifiers of ClassBTypes for Java annotations | * 8946d60 [backport] Fix bytecode stability when running the closure optimizer | * 3b6b2bf [backport] SI-9392 Clarify the workaround comment and introduce a devWarning | * 091c1e6 [backport] SI-9392 Avoid crash in GenBCode for incoherent trees | * 6177cb4 [backport] SI-9393 Temporarily disable two assertions in GenBCode | * a1d471f [backport] Refactor the ClosureOptimizer, run ProdCons only once per method | * f5e7276 [backport] SI-9387 Fix VerifyError introduced by indylambda | * 41b99e2 [backport] Integrate the LMFInvokeDynamic extractor into LambdaMetaFactoryCall | * fc1cda2 [backport] Small refactoring to the closure optimizer | * 8f272c0 [backport] Accessibility checks for methods with an InvokeDynamic instruction | * 1c1d825 [backport] Fix bytecode stability | * ef9d845 [backport] Support methodHandle / invokeDynamic constant pool entries in scalap | * 60747c7 [backport] Skip mirror class when invoking deserializeLambda | * 404e862 [backport] Prevent infinite recursion in ProdConsAnalyzer | * 1b0703e [backport] SI-9376 don't crash when inlining a closure body that throws. | * e511375 [backport] Fix superclass for Java interface symbols created in JavaMirrors | * 1b57723 [backport] `deserializeLambda` should not use encoded class name | * 8bafa8e [backport] Java parser: default methods in interfaces are not `DEFERRED` | * 44e2761 [backport] SI-6613 fixed in GenBCode ``` ``` ➜ scala git:(2.12.x) g merge 4c6dcfe Auto-merging src/scaladoc/scala/tools/nsc/doc/html/page/Template.scala Auto-merging doc/License.rtf Auto-merging doc/LICENSE.md Auto-merging build.xml Auto-merging build.sbt Merge made by the 'recursive' strategy. Auto packing the repository in background for optimum performance. See "git help gc" for manual housekeeping. build.sbt | 2 +- build.xml | 2 +- doc/LICENSE.md | 4 ++-- doc/License.rtf | 4 ++-- src/scaladoc/scala/tools/nsc/doc/html/page/Template.scala | 2 +- src/scalap/decoder.properties | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) ``` ``` * | 4c6dcfe Merge pull request scala#4656 from lrytz/filtersOpenJDK |\ \ | |/ |/| | * 0b35bc2 Ignore OpenJDK warnings in partest filters * 6eb0812 Merge pull request scala#4644 from SethTisue/copyright-2015 * e0aac7c bump copyright year to 2015 ```
2 parents b8744ba + 928e689 commit ecf9128

36 files changed

+259
-94
lines changed

CONTRIBUTING.md

Lines changed: 83 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,93 @@ Please make sure the JIRA ticket's fix version corresponds to the upcoming miles
3838

3939
#### Enhancement or New Feature
4040

41-
For longer-running development, likely required for this category of code contributions, we suggest you include "topic" or "wip" in your branch name, to indicate that this is work in progress, and that others should be prepared to rebase if they branch off your branch.
41+
For longer-running development, likely required for this category of code contributions, we suggest you include "topic/" or "wip/" in your branch name, to indicate that this is work in progress, and that others should be prepared to rebase if they branch off your branch.
4242

4343
Any language change (including bug fixes) must be accompanied by the relevant updates to the spec, which lives in the same repository for this reason.
4444

4545
A new language feature requires a SIP (Scala Improvement Process) proposal. For more details on submitting SIPs, see [how to submit a SIP](http://docs.scala-lang.org/sips/sip-submission.html).
4646

47-
#### Summary
47+
## Guidelines
4848

49-
1. We require regression tests for bug fixes. New features and enhancements must be supported by a respectable test suite.
50-
2. Documentation. Yep! Also required :-)
51-
3. Please follow these standard code standards, though in moderation (scouts quickly learn to let sleeping dogs lie):
52-
- Not violate [DRY](http://programmer.97things.oreilly.com/wiki/index.php/Don%27t_Repeat_Yourself).
53-
- [Boy Scout Rule](http://programmer.97things.oreilly.com/wiki/index.php/The_Boy_Scout_Rule) should be applied.
49+
Here is some advice on how to craft a pull request with the best possible
50+
chance of being accepted.
5451

55-
Please also have a look at our [Pull Request Policy](https://github.com/scala/scala/wiki/Pull-Request-Policy), as well as the [Scala Hacker Guide](http://www.scala-lang.org/contribute/hacker-guide.html) by @xeno-by.
52+
### Tests
53+
54+
Bug fixes should include regression tests -- in the same commit as the fix.
55+
56+
If testing isn't feasible, the commit message should explain why.
57+
58+
New features and enhancements must be supported by a respectable test suite.
59+
60+
Some characteristics of good tests:
61+
62+
* includes comments: what is being tested and why?
63+
* be minimal, deterministic, stable (unaffected by irrelevant changes), easy to understand and review
64+
* have minimal dependencies: a compiler bug test should not depend on, e.g., the Scala library
65+
66+
### Documentation
67+
68+
This is of course required for new features and enhancements.
69+
70+
Any API additions should include Scaladoc.
71+
72+
Consider updating the package-level doc (in the package object), if appropriate.
73+
74+
### Coding standards
75+
76+
Please follow these standard code standards, though in moderation (scouts quickly learn to let sleeping dogs lie):
77+
78+
* Don't violate [DRY](http://programmer.97things.oreilly.com/wiki/index.php/Don%27t_Repeat_Yourself).
79+
* Follow the [Boy Scout Rule](http://programmer.97things.oreilly.com/wiki/index.php/The_Boy_Scout_Rule).
80+
81+
Please also have a look at the [Scala Hacker Guide](http://www.scala-lang.org/contribute/hacker-guide.html) by @xeno-by.
82+
83+
### Clean commits, clean history
84+
85+
A pull request should consist of commits with messages that clearly state what problem the commit resolves and how.
86+
87+
Commit logs should be stated in the active, present tense.
88+
89+
A commit's subject should be 60 characters or less. Overall, think of
90+
the first line of the commit as a description of the action performed
91+
by the commit on the code base, so use the active voice and the
92+
present tense. That also makes the commit subjects easy to reuse in
93+
release notes.
94+
95+
For a bugfix, the title must look like "SI-NNNN - don't crash when
96+
moon is in wrong phase".
97+
98+
If a commit purely refactors and is not intended to change behaviour,
99+
say so.
100+
101+
Backports should be tagged as "[backport]".
102+
103+
When working on maintenance branches (e.g., 2.11.x), include "[nomerge]"
104+
if this commit should not be merged forward into the next release
105+
branch.
106+
107+
Here is standard advice on good commit messages:
108+
http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
109+
110+
### Pass Scabot
111+
112+
Our pull request bot, Scabot, automatically builds all the commits in a PR individually. (All, so we can `git bisect` later.)
113+
114+
Click on the little x next to a commit sha to go to the overview of the PR validation job. To diagnose a failure, consult the console output of the job that failed.
115+
116+
See the [scala-jenkins-infra repo](https://github.com/scala/scala-jenkins-infra) and [Scabot repo](https://github.com/) for full details on PR validation. One tip you should know is that commenting `/rebuild` on a PR asks validation to be run again on the same commits. This is only necessary when a spurious failure occurred.
117+
118+
### Pass code review
119+
120+
Your PR will need to be assigned to one or more reviewers. You can suggest reviewers yourself; if you're not sure, see the list in [README.md](README.md) or ask on scala-internals.
121+
122+
To assign a reviewer, add a "review by @reviewer" to your PR description.
123+
124+
NOTE: it's best not to @mention in commit messages, as github pings you every time a commit with your @name on it shuffles through the system (even in other repos, on merges,...).
125+
126+
A reviewer gives the green light by commenting "LGTM" (looks good to me).
127+
128+
A review feedback may be addressed by pushing new commits to the request, if these commits stand on their own.
129+
130+
Once all these conditions are met, and we agree with the change (we are available on scala-internals to discuss this beforehand, before you put in the coding work!), we will merge your changes.

README.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,20 @@ If you need some help with your PR at any time, please feel free to @-mention an
1313

1414
| username | talk to me about... |
1515
--------------------------------------------------------------------------------------------------|----------------------------------------------------------------|---------------------------------------------------|
16-
<img src="https://avatars.githubusercontent.com/adriaanm" height="50px" title="Adriaan Moors"/> | [`@adriaanm`](https://github.com/adriaanm) | how we can help // type checker, pattern matcher, infrastructure |
17-
<img src="https://avatars.githubusercontent.com/SethTisue" height="50px" title="Seth Tisue"/> | [`@SethTisue`](https://github.com/SethTisue) | back-end, library, improving the *welcome to Scala* experience |
18-
<img src="https://avatars.githubusercontent.com/retronym" height="50px" title="Jason Zaugg"/> | [`@retronym`](https://github.com/retronym) | Java 8 lambdas, tricky bug detective work |
19-
<img src="https://avatars.githubusercontent.com/Ichoran" height="50px" title="Rex Kerr"/> | [`@Ichoran`](https://github.com/Ichoran) | the collections library, performance |
16+
<img src="https://avatars.githubusercontent.com/adriaanm" height="50px" title="Adriaan Moors"/> | [`@adriaanm`](https://github.com/adriaanm) | type checker, pattern matcher, infrastructure, language spec |
17+
<img src="https://avatars.githubusercontent.com/SethTisue" height="50px" title="Seth Tisue"/> | [`@SethTisue`](https://github.com/SethTisue) | back-end, library, the welcome-to-Scala experience, build |
18+
<img src="https://avatars.githubusercontent.com/retronym" height="50px" title="Jason Zaugg"/> | [`@retronym`](https://github.com/retronym) | compiler performance, weird compiler bugs, Java 8 lambdas, REPL |
19+
<img src="https://avatars.githubusercontent.com/Ichoran" height="50px" title="Rex Kerr"/> | [`@Ichoran`](https://github.com/Ichoran) | collections library, performance |
2020
<img src="https://avatars.githubusercontent.com/lrytz" height="50px" title="Lukas Rytz"/> | [`@lrytz`](https://github.com/lrytz) | optimizer, named & default arguments |
21-
<img src="https://avatars.githubusercontent.com/VladUreche" height="50px" title="Vlad Ureche"/> | [`@VladUreche`](https://github.com/VladUreche) | specialization & the scaladoc tool |
21+
<img src="https://avatars.githubusercontent.com/VladUreche" height="50px" title="Vlad Ureche"/> | [`@VladUreche`](https://github.com/VladUreche) | specialization, Scaladoc tool |
2222
<img src="https://avatars.githubusercontent.com/densh" height="50px" title="Denys Shabalin"/> | [`@densh`](https://github.com/densh) | quasiquotes, parser, string interpolators, macros in standard library |
2323
<img src="https://avatars.githubusercontent.com/xeno-by" height="50px" title="Eugene Burmako"/> | [`@xeno-by`](https://github.com/xeno-by) | macros and reflection |
24-
<img src="https://avatars.githubusercontent.com/dickwall" height="50px" title="Dick Wall"/> | [`@dickwall`](https://github.com/dickwall) | process & community |
24+
<img src="https://avatars.githubusercontent.com/heathermiller" height="50px" title="Heather Miller"/> | [`@heathermiller`](https://github.com/heathermiller) | documentation |
25+
<img src="https://avatars.githubusercontent.com/dickwall" height="50px" title="Dick Wall"/> | [`@dickwall`](https://github.com/dickwall) | process & community, documentation |
26+
<img src="https://avatars.githubusercontent.com/dragos" height="50px" title="Iulian Dragos"/> | [`@dragos`](https://github.com/dragos) | specialization, back end |
27+
<img src="https://avatars.githubusercontent.com/axel22" height="50px" title="Aleksandr Prokopec"/> | [`@axel22`](https://github.com/axel22) | collections, concurrency, specialization |
2528

26-
27-
PS: If you have some spare time to help out around here, we would be delighted to add your name to this list!
29+
P.S.: If you have some spare time to help out around here, we would be delighted to add your name to this list!
2830

2931
# Handy Links
3032
- [A wealth of documentation](http://docs.scala-lang.org)
@@ -151,14 +153,14 @@ to build the compiler. You can run `sbt test` to run unit (JUnit) tests.
151153
Use `sbt test/it:test` to run integration (partest) tests.
152154

153155
We would like to migrate to sbt build as quickly as possible. If you would
154-
like to help please contact scala-internals@ mailing list to discuss your
156+
like to help please use the scala-internals mailing list to discuss your
155157
ideas and coordinate your effort with others.
156158

157159
### Tips and tricks
158160

159161
Here are some common commands. Most ant targets offer a `-opt` variant that runs under `-optimise` (CI runs the -optimize variant).
160162

161-
- `./pull-binary-libs.sh` [downloads](http://typesafe.artifactoryonline.com/typesafe) all binary artifacts associated with this commit.
163+
- `./pull-binary-libs.sh` downloads all binary artifacts associated with this commit.
162164
- `ant -p` prints out information about the commonly used ant targets.
163165
- `ant` or `ant build`: A quick compilation (to build/quick) of your changes using the locker compiler.
164166

build.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ TODO:
763763
</path>
764764

765765
<path id="quick.bin.tool.path">
766-
<path refid="quick.repl.build.path"/>
766+
<path refid="quick.repl-jline.build.path"/>
767767
<pathelement location="${build-quick.dir}/classes/scalap"/>
768768
<pathelement location="${build-quick.dir}/classes/scaladoc"/>
769769
<path refid="external-modules-nocore"/>

src/compiler/scala/tools/nsc/backend/opt/ConstantOptimization.scala

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,11 @@ abstract class ConstantOptimization extends SubComponent {
170170
// out all the possibilities
171171
case Impossible(possible2) => (possible -- possible2).nonEmpty
172172
})
173-
def mightNotEqual(other: Contents): Boolean = (this ne other) && (other match {
174-
// two Possibles might not be equal if either has possible members that the other doesn't
175-
case Possible(possible2) => (possible -- possible2).nonEmpty || (possible2 -- possible).nonEmpty
173+
def mightNotEqual(other: Contents): Boolean = (other match {
174+
case Possible(possible2) =>
175+
// two Possibles must equal if each is known to be of the same, single value
176+
val mustEqual = possible.size == 1 && possible == possible2
177+
!mustEqual
176178
case Impossible(_) => true
177179
})
178180
}

src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ abstract class ClassfileParser {
8484
protected final def u2(): Int = in.nextChar.toInt
8585
protected final def u4(): Int = in.nextInt
8686

87+
protected final def s1(): Int = in.nextByte.toInt // sign-extend the byte to int
88+
protected final def s2(): Int = (in.nextByte.toInt << 8) | u1 // sign-extend and shift the first byte, or with the unsigned second byte
89+
8790
private def readInnerClassFlags() = readClassFlags()
8891
private def readClassFlags() = JavaAccFlags classFlags u2
8992
private def readMethodFlags() = JavaAccFlags methodFlags u2

src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,8 @@ abstract class ICodeReader extends ClassfileParser {
326326
case JVM.dconst_0 => code emit CONSTANT(Constant(0.0))
327327
case JVM.dconst_1 => code emit CONSTANT(Constant(1.0))
328328

329-
case JVM.bipush => code.emit(CONSTANT(Constant(u1))); size += 1
330-
case JVM.sipush => code.emit(CONSTANT(Constant(u2))); size += 2
329+
case JVM.bipush => code.emit(CONSTANT(Constant(s1))); size += 1
330+
case JVM.sipush => code.emit(CONSTANT(Constant(s2))); size += 2
331331
case JVM.ldc => code.emit(CONSTANT(pool.getConstant(u1))); size += 1
332332
case JVM.ldc_w => code.emit(CONSTANT(pool.getConstant(u2))); size += 2
333333
case JVM.ldc2_w => code.emit(CONSTANT(pool.getConstant(u2))); size += 2
@@ -466,7 +466,7 @@ abstract class ICodeReader extends ClassfileParser {
466466
size += 2
467467
val local = code.getLocal(u1, INT)
468468
code.emit(LOAD_LOCAL(local))
469-
code.emit(CONSTANT(Constant(u1)))
469+
code.emit(CONSTANT(Constant(s1)))
470470
code.emit(CALL_PRIMITIVE(Arithmetic(ADD, INT)))
471471
code.emit(STORE_LOCAL(local))
472472

src/compiler/scala/tools/nsc/transform/Mixin.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1122,7 +1122,7 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL {
11221122
if (scope exists (_.isLazy)) {
11231123
val map = mutable.Map[Symbol, Set[Symbol]]() withDefaultValue Set()
11241124
// check what fields can be nulled for
1125-
for ((field, users) <- singleUseFields(templ); lazyFld <- users)
1125+
for ((field, users) <- singleUseFields(templ); lazyFld <- users if !lazyFld.accessed.hasAnnotation(TransientAttr))
11261126
map(lazyFld) += field
11271127

11281128
map.toMap

src/compiler/scala/tools/nsc/typechecker/Macros.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ trait Macros extends MacroRuntimes with Traces with Helpers {
8585
*/
8686
case class MacroImplBinding(
8787
// Is this macro impl a bundle (a trait extending *box.Macro) or a vanilla def?
88-
val isBundle: Boolean,
88+
isBundle: Boolean,
8989
// Is this macro impl blackbox (i.e. having blackbox.Context in its signature)?
90-
val isBlackbox: Boolean,
90+
isBlackbox: Boolean,
9191
// Java class name of the class that contains the macro implementation
9292
// is used to load the corresponding object with Java reflection
9393
className: String,

src/library-aux/scala/AnyRef.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ trait AnyRef extends Any {
4545
*/
4646
def synchronized[T](body: => T): T
4747

48-
/** Tests whether the argument (`arg0`) is a reference to the receiver object (`this`).
48+
/** Tests whether the argument (`that`) is a reference to the receiver object (`this`).
4949
*
5050
* The `eq` method implements an [[http://en.wikipedia.org/wiki/Equivalence_relation equivalence relation]] on
5151
* non-null instances of `AnyRef`, and has three additional properties:
@@ -73,7 +73,7 @@ trait AnyRef extends Any {
7373

7474
/** The expression `x == that` is equivalent to `if (x eq null) that eq null else x.equals(that)`.
7575
*
76-
* @param arg0 the object to compare against this object for equality.
76+
* @param that the object to compare against this object for equality.
7777
* @return `true` if the receiver object is equivalent to the argument; `false` otherwise.
7878
*/
7979
final def ==(that: Any): Boolean =

src/library/scala/StringContext.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ object StringContext {
173173
/** An exception that is thrown if a string contains a backslash (`\`) character
174174
* that does not start a valid escape sequence.
175175
* @param str The offending string
176-
* @param idx The index of the offending backslash character in `str`.
176+
* @param index The index of the offending backslash character in `str`.
177177
*/
178178
class InvalidEscapeException(str: String, @deprecatedName('idx) val index: Int) extends IllegalArgumentException(
179179
s"""invalid escape ${

src/library/scala/collection/GenSeqLike.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ trait GenSeqLike[+A, +Repr] extends Any with GenIterableLike[A, Repr] with Equal
274274
* @tparam B the element type of the returned $coll.
275275
* @tparam That $thatinfo
276276
* @param bf $bfinfo
277-
* @return a new $coll` which is a copy of this $coll with the element at position `index` replaced by `elem`.
277+
* @return a new $coll which is a copy of this $coll with the element at position `index` replaced by `elem`.
278278
* @throws IndexOutOfBoundsException if `index` does not satisfy `0 <= index < length`.
279279
*
280280
* @usecase def updated(index: Int, elem: A): $Coll[A]

src/library/scala/collection/convert/Wrappers.scala

Lines changed: 8 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -266,17 +266,11 @@ private[collection] trait Wrappers {
266266
def +=(kv: (A, B)): this.type = { underlying.put(kv._1, kv._2); this }
267267
def -=(key: A): this.type = { underlying remove key; this }
268268

269-
override def put(k: A, v: B): Option[B] = {
270-
val r = underlying.put(k, v)
271-
if (r != null) Some(r) else None
272-
}
269+
override def put(k: A, v: B): Option[B] = Option(underlying.put(k, v))
273270

274271
override def update(k: A, v: B) { underlying.put(k, v) }
275272

276-
override def remove(k: A): Option[B] = {
277-
val r = underlying remove k
278-
if (r != null) Some(r) else None
279-
}
273+
override def remove(k: A): Option[B] = Option(underlying remove k)
280274

281275
def iterator: Iterator[(A, B)] = new AbstractIterator[(A, B)] {
282276
val ui = underlying.entrySet.iterator
@@ -327,25 +321,15 @@ private[collection] trait Wrappers {
327321
* are not guaranteed to be atomic.
328322
*/
329323
case class JConcurrentMapWrapper[A, B](underlying: juc.ConcurrentMap[A, B]) extends mutable.AbstractMap[A, B] with JMapWrapperLike[A, B, JConcurrentMapWrapper[A, B]] with concurrent.Map[A, B] {
330-
override def get(k: A) = {
331-
val v = underlying get k
332-
if (v != null) Some(v)
333-
else None
334-
}
324+
override def get(k: A) = Option(underlying get k)
335325

336326
override def empty = new JConcurrentMapWrapper(new juc.ConcurrentHashMap[A, B])
337327

338-
def putIfAbsent(k: A, v: B): Option[B] = {
339-
val r = underlying.putIfAbsent(k, v)
340-
if (r != null) Some(r) else None
341-
}
328+
def putIfAbsent(k: A, v: B): Option[B] = Option(underlying.putIfAbsent(k, v))
342329

343330
def remove(k: A, v: B): Boolean = underlying.remove(k, v)
344331

345-
def replace(k: A, v: B): Option[B] = {
346-
val prev = underlying.replace(k, v)
347-
if (prev != null) Some(prev) else None
348-
}
332+
def replace(k: A, v: B): Option[B] = Option(underlying.replace(k, v))
349333

350334
def replace(k: A, oldvalue: B, newvalue: B): Boolean =
351335
underlying.replace(k, oldvalue, newvalue)
@@ -381,25 +365,16 @@ private[collection] trait Wrappers {
381365
case class JDictionaryWrapper[A, B](underlying: ju.Dictionary[A, B]) extends mutable.AbstractMap[A, B] with mutable.Map[A, B] {
382366
override def size: Int = underlying.size
383367

384-
def get(k: A) = {
385-
val v = underlying get k
386-
if (v != null) Some(v) else None
387-
}
368+
def get(k: A) = Option(underlying get k)
388369

389370
def +=(kv: (A, B)): this.type = { underlying.put(kv._1, kv._2); this }
390371
def -=(key: A): this.type = { underlying remove key; this }
391372

392-
override def put(k: A, v: B): Option[B] = {
393-
val r = underlying.put(k, v)
394-
if (r != null) Some(r) else None
395-
}
373+
override def put(k: A, v: B): Option[B] = Option(underlying.put(k, v))
396374

397375
override def update(k: A, v: B) { underlying.put(k, v) }
398376

399-
override def remove(k: A): Option[B] = {
400-
val r = underlying remove k
401-
if (r != null) Some(r) else None
402-
}
377+
override def remove(k: A): Option[B] = Option(underlying remove k)
403378

404379
def iterator = enumerationAsScalaIterator(underlying.keys) map (k => (k, underlying get k))
405380

0 commit comments

Comments
 (0)