summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
diff options
context:
space:
mode:
authorSom Snytt <som.snytt@gmail.com>2016-02-09 12:50:10 -0800
committerSom Snytt <som.snytt@gmail.com>2016-02-10 01:56:31 -0800
commit4abf00c4f01c0047f42b0aa2e945ba57108593de (patch)
tree5cc739d43b63d8eebb6a853aa52e9492d683a576 /src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
parent78c378c97c51600cac1cf42edd050aceb2366026 (diff)
downloadscala-4abf00c4f01c0047f42b0aa2e945ba57108593de.tar.gz
scala-4abf00c4f01c0047f42b0aa2e945ba57108593de.tar.bz2
scala-4abf00c4f01c0047f42b0aa2e945ba57108593de.zip
SI-9650 Refchecks on case apply transform
Apply checks for unsavoriness when transforming a case apply.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/RefChecks.scala')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/RefChecks.scala13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
index cafea55b4d..9261d6b851 100644
--- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
@@ -1154,11 +1154,13 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans
def toConstructor(pos: Position, tpe: Type): Tree = {
val rtpe = tpe.finalResultType
assert(rtpe.typeSymbol hasFlag CASE, tpe)
- localTyper.typedOperator {
+ val tree = localTyper.typedOperator {
atPos(pos) {
Select(New(TypeTree(rtpe)), rtpe.typeSymbol.primaryConstructor)
}
}
+ checkUndesiredProperties(rtpe.typeSymbol, tree.pos)
+ tree
}
override def transformStats(stats: List[Tree], exprOwner: Symbol): List[Tree] = {
@@ -1529,11 +1531,20 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans
!tree.tpe.resultType.typeSymbol.primaryConstructor.isLessAccessibleThan(tree.symbol)
if (doTransform) {
+ def loop(t: Tree): Unit = t match {
+ case Ident(_) =>
+ checkUndesiredProperties(t.symbol, t.pos)
+ case Select(qual, _) =>
+ checkUndesiredProperties(t.symbol, t.pos)
+ loop(qual)
+ case _ =>
+ }
tree foreach {
case i@Ident(_) =>
enterReference(i.pos, i.symbol) // SI-5390 need to `enterReference` for `a` in `a.B()`
case _ =>
}
+ loop(tree)
toConstructor(tree.pos, tree.tpe)
}
else {