summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2016-03-02 22:02:15 +1000
committerJason Zaugg <jzaugg@gmail.com>2016-03-02 22:11:55 +1000
commitfe5bd09861994734bc394813d069ea40c89d39de (patch)
tree97465b7fe4f0b89c48fb5bfbb2b5baeaaa70ac7f /src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
parent1a59c55ed5c6a0d53acd0259090cf57328748451 (diff)
downloadscala-fe5bd09861994734bc394813d069ea40c89d39de.tar.gz
scala-fe5bd09861994734bc394813d069ea40c89d39de.tar.bz2
scala-fe5bd09861994734bc394813d069ea40c89d39de.zip
SI-9546 Fix regression in rewrite of case apply to constructor call
In SI-9425, I disabled the rewrite of `CaseClass.apply(x)` to `new CaseClass(x)` if the constructor was was less accessible than the apply method. This solved a problem with spurious "constructor cannot be accessed" errors during refchecks for case classes with non-public constructors. However, for polymorphic case classes, refchecks was persistent, and even after refusing to transform the `TypeApply` within: CaseClass.apply[String]("") It *would* try again to transform the enclosing `Select`, a code path only intended for monomorphic case classes. The tree has a `PolyType`, which foiled the newly added accessibility check. I've modified the call to `isSimpleCaseApply` from the transform of `Select` nodes to exclude polymorphic apply's from being considered twice.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/RefChecks.scala')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/RefChecks.scala7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
index f2607b6bde..517271e5eb 100644
--- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
@@ -1571,7 +1571,9 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans
// term should have been eliminated by super accessors
assert(!(qual.symbol.isTrait && sym.isTerm && mix == tpnme.EMPTY), (qual.symbol, sym, mix))
- if (isSimpleCaseApply(tree)) {
+ // SI-9546 isHigherKinded excludes generic case classes which are instead considered when transforming
+ // the enclosing `TypeApply`.
+ if (!tree.tpe.isHigherKinded && isSimpleCaseApply(tree)) {
transformCaseApply(tree)
} else {
qual match {
@@ -1725,9 +1727,6 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans
case Ident(name) =>
checkUndesiredProperties(sym, tree.pos)
- if (isSimpleCaseApply(tree)) {
- abort("case factory methods are now always selected from prefix (since https://github.com/scala/scala/commit/76c06b4)")
- }
if (name != nme.WILDCARD && name != tpnme.WILDCARD_STAR) {
assert(sym != NoSymbol, "transformCaseApply: name = " + name.debugString + " tree = " + tree + " / " + tree.getClass) //debug
enterReference(tree.pos, sym)