summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@typesafe.com>2015-08-24 18:47:31 -0700
committerAdriaan Moors <adriaan.moors@typesafe.com>2015-09-02 12:04:07 -0700
commitcc70cfb5024729935b5dd9be385847bd43c90b04 (patch)
tree28e860755f2a6c90a9641a5f70b125f5392848f1 /src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala
parent66a316a4acdb2584ef9d85f15b950f12c94d909c (diff)
downloadscala-cc70cfb5024729935b5dd9be385847bd43c90b04.tar.gz
scala-cc70cfb5024729935b5dd9be385847bd43c90b04.tar.bz2
scala-cc70cfb5024729935b5dd9be385847bd43c90b04.zip
Simplify decision whether to derive accessors
Originally (modulo renaming & reduction of double negation in previous commit): ``` def deriveAccessors(vd: ValDef) = vd.mods.isLazy || !( !owner.isClass || (vd.mods.isPrivateLocal && !vd.mods.isCaseAccessor) // this is an error -- now checking first || (vd.name startsWith nme.OUTER) || (context.unit.isJava) // pulled out to caller || isEnumConstant(vd) ) def deriveAccessorTrees(vd: ValDef) = !( (vd.mods.isPrivateLocal && !vd.mods.isLazy) // lazy was pulled out to outer disjunction || vd.symbol.isModuleVar // pulled out to caller || isEnumConstant(vd)) ``` With changes in comments above, these conditions are now captured by one method.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala13
1 files changed, 3 insertions, 10 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala b/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala
index 5f5e13951d..5fdddf0641 100644
--- a/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala
@@ -135,18 +135,12 @@ trait MethodSynthesis {
}
// TODO: see if we can link symbol creation & tree derivation by sharing the Field/Getter/Setter factories
- def enterGetterSetter(tree: ValDef) {
- val ValDef(mods, name, _, _) = tree
- if (nme.isSetterName(name))
- ValOrValWithSetterSuffixError(tree)
-
+ def enterGetterSetter(tree: ValDef): Unit = {
tree.symbol =
- if (mods.isLazy) {
+ if (tree.mods.isLazy) {
val lazyValGetter = LazyValGetter(tree).createAndEnterSymbol()
enterLazyVal(tree, lazyValGetter)
} else {
- if (mods.isPrivateLocal)
- PrivateThisCaseClassParameterError(tree)
val getter = Getter(tree)
val getterSym = getter.createAndEnterSymbol()
@@ -163,7 +157,6 @@ trait MethodSynthesis {
else enterStrictVal(tree)
}
-
enterBeans(tree)
}
@@ -184,7 +177,7 @@ trait MethodSynthesis {
}
def addDerivedTrees(typer: Typer, stat: Tree): List[Tree] = stat match {
- case vd @ ValDef(mods, name, tpt, rhs) if deriveAccessorTrees(vd) =>
+ case vd @ ValDef(mods, name, tpt, rhs) if deriveAccessors(vd) && !vd.symbol.isModuleVar =>
// If we don't save the annotations, they seem to wander off.
val annotations = stat.symbol.initialize.annotations
val trees = (