Skip to content

Commit 798462e

Browse files
committed
Merge pull request #5040 from adriaanm/rebase-5031
Merge 2.11.x into 2.12.x [ci: last-only]
2 parents 5ebae12 + 827b6f3 commit 798462e

File tree

16 files changed

+198
-118
lines changed

16 files changed

+198
-118
lines changed

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ We follow the standard GitHub [fork & pull](https://help.github.com/articles/usi
44
You're always welcome to submit your PR straight away and start the discussion (without reading the rest of this wonderful doc, or the `READMEnot^H^H^H.md`). The goal of these notes is to make your experience contributing to Scala as smooth and pleasant as possible. We're happy to guide you through the process once you've submitted your PR.
55

66
## The Scala Community
7-
In 2014, you -- the Scala community -- matched the core team at EPFL in number of commits contributed to Scala 2.11, doubling the percentage of commits from outside EPFL/Typesafe since 2.10. Excellent work! (The split was roughly 25/25/50 for you/EPFL/Typesafe.)
7+
In 2014, you -- the Scala community -- matched the core team at EPFL in number of commits contributed to Scala 2.11, doubling the percentage of commits from outside EPFL/Lightbend since 2.10. Excellent work! (The split was roughly 25/25/50 for you/EPFL/Lightbend.)
88

99
We are super happy about this, and are eager to make your experience contributing to Scala productive and satisfying, so that we can keep up this growth. We can't do this alone (nor do we want to)!
1010

1111
This is why we're collecting these notes on how to contribute, and we hope you'll share your experience to improve the process for the next contributor! (Feel free to send a PR for this note, send your thoughts to scala-internals, or tweet about it to @adriaanm.)
1212

13-
By the way, the team at Lightbend (formerly Typesafe) is: @adriaanm, @lrytz, @retronym, @SethTisue, and @szeiger.
13+
By the way, the team at Lightbend is: @adriaanm, @lrytz, @retronym, @SethTisue, and @szeiger.
1414

1515
## What kind of PR are you submitting?
1616

doc/LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Scala is licensed under the [BSD 3-Clause License](http://opensource.org/license
44

55
Copyright (c) 2002-2016 EPFL
66

7-
Copyright (c) 2011-2016 Lightbend, Inc. (formerly Typesafe, Inc.)
7+
Copyright (c) 2011-2016 Lightbend, Inc.
88

99
All rights reserved.
1010

doc/License.rtf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
\fs40 \
1212

1313
\fs26 Copyright (c) 2002-2016 EPFL\
14-
Copyright (c) 2011-2016 Lightbend, Inc. (formerly Typesafe, Inc.)\
14+
Copyright (c) 2011-2016 Lightbend, Inc.\
1515
All rights reserved.\
1616
\
1717
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\

project/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=0.13.9
1+
sbt.version=0.13.11

scripts/common

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ mkdir -p $IVY_CACHE
1919
rm -rf $IVY_CACHE/cache/org.scala-lang
2020

2121
SBT_CMD=${sbtCmd-sbt}
22-
SBT_CMD="$SBT_CMD -sbt-version 0.13.9"
22+
SBT_CMD="$SBT_CMD -sbt-version 0.13.11"
2323

2424
# temp dir where all 'non-build' operation are performed
2525
TMP_ROOT_DIR=$(mktemp -d -t pr-scala.XXXX)

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

Lines changed: 47 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1507,50 +1507,45 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans
15071507
}
15081508
}
15091509

1510-
private def transformCaseApply(tree: Tree, ifNot: => Unit) = {
1510+
private def isSimpleCaseApply(tree: Tree): Boolean = {
15111511
val sym = tree.symbol
1512-
15131512
def isClassTypeAccessible(tree: Tree): Boolean = tree match {
15141513
case TypeApply(fun, targs) =>
15151514
isClassTypeAccessible(fun)
15161515
case Select(module, apply) =>
15171516
( // SI-4859 `CaseClass1().InnerCaseClass2()` must not be rewritten to `new InnerCaseClass2()`;
15181517
// {expr; Outer}.Inner() must not be rewritten to `new Outer.Inner()`.
15191518
treeInfo.isQualifierSafeToElide(module) &&
1520-
// SI-5626 Classes in refinement types cannot be constructed with `new`. In this case,
1521-
// the companion class is actually not a ClassSymbol, but a reference to an abstract type.
1522-
module.symbol.companionClass.isClass
1523-
)
1519+
// SI-5626 Classes in refinement types cannot be constructed with `new`. In this case,
1520+
// the companion class is actually not a ClassSymbol, but a reference to an abstract type.
1521+
module.symbol.companionClass.isClass
1522+
)
15241523
}
15251524

1526-
val doTransform =
1527-
sym.isSourceMethod &&
1525+
sym.isSourceMethod &&
15281526
sym.isCase &&
15291527
sym.name == nme.apply &&
15301528
isClassTypeAccessible(tree) &&
1531-
!tree.tpe.resultType.typeSymbol.primaryConstructor.isLessAccessibleThan(tree.symbol)
1532-
1533-
if (doTransform) {
1534-
def loop(t: Tree): Unit = t match {
1535-
case Ident(_) =>
1536-
checkUndesiredProperties(t.symbol, t.pos)
1537-
case Select(qual, _) =>
1538-
checkUndesiredProperties(t.symbol, t.pos)
1539-
loop(qual)
1540-
case _ =>
1541-
}
1542-
tree foreach {
1543-
case i@Ident(_) =>
1544-
enterReference(i.pos, i.symbol) // SI-5390 need to `enterReference` for `a` in `a.B()`
1545-
case _ =>
1546-
}
1547-
loop(tree)
1548-
toConstructor(tree.pos, tree.tpe)
1529+
!tree.tpe.finalResultType.typeSymbol.primaryConstructor.isLessAccessibleThan(tree.symbol)
1530+
}
1531+
1532+
private def transformCaseApply(tree: Tree) = {
1533+
def loop(t: Tree): Unit = t match {
1534+
case Ident(_) =>
1535+
checkUndesiredProperties(t.symbol, t.pos)
1536+
case Select(qual, _) =>
1537+
checkUndesiredProperties(t.symbol, t.pos)
1538+
loop(qual)
1539+
case _ =>
15491540
}
1550-
else {
1551-
ifNot
1552-
tree
1541+
1542+
tree foreach {
1543+
case i@Ident(_) =>
1544+
enterReference(i.pos, i.symbol) // SI-5390 need to `enterReference` for `a` in `a.B()`
1545+
case _ =>
15531546
}
1547+
loop(tree)
1548+
toConstructor(tree.pos, tree.tpe)
15541549
}
15551550

15561551
private def transformApply(tree: Apply): Tree = tree match {
@@ -1590,12 +1585,24 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans
15901585
// term should have been eliminated by super accessors
15911586
assert(!(qual.symbol.isTrait && sym.isTerm && mix == tpnme.EMPTY), (qual.symbol, sym, mix))
15921587

1593-
transformCaseApply(tree,
1588+
// Rewrite eligible calls to monomorphic case companion apply methods to the equivalent constructor call.
1589+
//
1590+
// Note: for generic case classes the rewrite needs to be handled at the enclosing `TypeApply` to transform
1591+
// `TypeApply(Select(C, apply), targs)` to `Select(New(C[targs]), <init>)`. In case such a `TypeApply`
1592+
// was deemed ineligible for transformation (e.g. the case constructor was private), the refchecks transform
1593+
// will recurse to this point with `Select(C, apply)`, which will have a type `[T](...)C[T]`.
1594+
//
1595+
// We don't need to perform the check on the Select node, and `!isHigherKinded will guard against this
1596+
// redundant (and previously buggy, SI-9546) consideration.
1597+
if (!tree.tpe.isHigherKinded && isSimpleCaseApply(tree)) {
1598+
transformCaseApply(tree)
1599+
} else {
15941600
qual match {
15951601
case Super(_, mix) => checkSuper(mix)
15961602
case _ =>
15971603
}
1598-
)
1604+
tree
1605+
}
15991606
}
16001607
private def transformIf(tree: If): Tree = {
16011608
val If(cond, thenpart, elsepart) = tree
@@ -1720,7 +1727,10 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans
17201727

17211728
case TypeApply(fn, args) =>
17221729
checkBounds(tree, NoPrefix, NoSymbol, fn.tpe.typeParams, args map (_.tpe))
1723-
transformCaseApply(tree, ())
1730+
if (isSimpleCaseApply(tree))
1731+
transformCaseApply(tree)
1732+
else
1733+
tree
17241734

17251735
case x @ Apply(_, _) =>
17261736
transformApply(x)
@@ -1739,12 +1749,11 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans
17391749

17401750
case Ident(name) =>
17411751
checkUndesiredProperties(sym, tree.pos)
1742-
transformCaseApply(tree,
1743-
if (name != nme.WILDCARD && name != tpnme.WILDCARD_STAR) {
1744-
assert(sym != NoSymbol, "transformCaseApply: name = " + name.debugString + " tree = " + tree + " / " + tree.getClass) //debug
1745-
enterReference(tree.pos, sym)
1746-
}
1747-
)
1752+
if (name != nme.WILDCARD && name != tpnme.WILDCARD_STAR) {
1753+
assert(sym != NoSymbol, "transformCaseApply: name = " + name.debugString + " tree = " + tree + " / " + tree.getClass) //debug
1754+
enterReference(tree.pos, sym)
1755+
}
1756+
tree
17481757

17491758
case x @ Select(_, _) =>
17501759
transformSelect(x)

0 commit comments

Comments
 (0)