diff options
author | Paul Phillips <paulp@improving.org> | 2012-09-26 11:44:54 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-09-26 11:44:54 -0700 |
commit | 874b3724775b2ad06976ffe58865ece5dc3393b5 (patch) | |
tree | cd350badb747ef6c46ae1c537510d2dd82f245a4 /src/compiler | |
parent | 53cb251ae24d06ed9e1e98b39d9be4c5baaf3525 (diff) | |
download | scala-874b3724775b2ad06976ffe58865ece5dc3393b5.tar.gz scala-874b3724775b2ad06976ffe58865ece5dc3393b5.tar.bz2 scala-874b3724775b2ad06976ffe58865ece5dc3393b5.zip |
Refine an -Xlint warning.
It should not warn about default getters.
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/RefChecks.scala | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala index 84ec86b194..e3f5214581 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -1631,12 +1631,14 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans case NullaryMethodType(restpe) if restpe.typeSymbol == UnitClass => // this may be the implementation of e.g. a generic method being parameterized // on Unit, in which case we had better let it slide. - if (sym.isGetter || sym.allOverriddenSymbols.exists(over => !(over.tpe.resultType =:= sym.tpe.resultType))) () - else unit.warning(sym.pos, - "side-effecting nullary methods are discouraged: suggest defining as `def %s()` instead".format( - sym.name.decode) + val isOk = ( + sym.isGetter + || sym.allOverriddenSymbols.exists(over => !(over.tpe.resultType =:= sym.tpe.resultType)) + || (sym.name containsName nme.DEFAULT_GETTER_STRING) ) - case _ => () + if (!isOk) + unit.warning(sym.pos, s"side-effecting nullary methods are discouraged: suggest defining as `def ${sym.name.decode}()` instead") + case _ => () } // Verify classes extending AnyVal meet the requirements |