diff options
author | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2016-04-18 17:32:49 +0200 |
---|---|---|
committer | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2016-06-07 14:18:27 +0200 |
commit | 2e5ab542921bd5cf16cda398dc9e40e6af14dd72 (patch) | |
tree | bd67c7de3b42c4749be7b1d2aa37ecd9eae0d783 /src | |
parent | 7c90f48f4fe844b5c94f7f19993834c754b0ac7e (diff) | |
download | dotty-2e5ab542921bd5cf16cda398dc9e40e6af14dd72.tar.gz dotty-2e5ab542921bd5cf16cda398dc9e40e6af14dd72.tar.bz2 dotty-2e5ab542921bd5cf16cda398dc9e40e6af14dd72.zip |
Fix #1220. Dont die when having incorect static methods
Diffstat (limited to 'src')
-rw-r--r-- | src/dotty/tools/dotc/transform/CheckStatic.scala | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/dotty/tools/dotc/transform/CheckStatic.scala b/src/dotty/tools/dotc/transform/CheckStatic.scala index 77c6dfc51..2275331a5 100644 --- a/src/dotty/tools/dotc/transform/CheckStatic.scala +++ b/src/dotty/tools/dotc/transform/CheckStatic.scala @@ -57,16 +57,13 @@ class CheckStatic extends MiniPhaseTransform { thisTransformer => } val companion = ctx.owner.companionClass + def clashes = companion.asClass.membersNamed(defn.name) + if (!companion.exists) { ctx.error("object that conatin @static members should have companion class", defn.pos) - } - - val clashes = companion.asClass.membersNamed(defn.name) - if (clashes.exists) { + } else if (clashes.exists) { ctx.error("companion classes cannot define members with same name as @static member", defn.pos) - } - - if (defn.symbol.is(Flags.Mutable) && companion.is(Flags.Trait)) { + } else if (defn.symbol.is(Flags.Mutable) && companion.is(Flags.Trait)) { ctx.error("Companions of traits cannot define mutable @static fields") } } else hadNonStaticField = hadNonStaticField || defn.isInstanceOf[ValDef] |