File tree Expand file tree Collapse file tree 2 files changed +8
-0
lines changed
compiler/src/dotty/tools/dotc/transform Expand file tree Collapse file tree 2 files changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ class CheckStatic extends MiniPhase {
3636 if (defn.symbol.isScalaStatic) {
3737 if (! ctx.owner.is(Module ))
3838 report.error(StaticFieldsOnlyAllowedInObjects (defn.symbol), defn.srcPos)
39+ defn.symbol.resetFlag(JavaStatic )
3940
4041 if (defn.isInstanceOf [ValDef ] && hadNonStaticField)
4142 report.error(StaticFieldsShouldPrecedeNonStatic (defn.symbol, defns), defn.srcPos)
@@ -68,6 +69,7 @@ class CheckStatic extends MiniPhase {
6869 case t : Select => isSafeQual(t.qualifier) && symbolWhitelist.contains(t.symbol)
6970 case t : Ident => symbolWhitelist.contains(t.symbol)
7071 case t : Block => t.stats.forall(tpd.isPureExpr) && isSafeQual(t.expr)
72+ case _ => false
7173 }
7274 if (isSafeQual(tree.qualifier))
7375 ref(tree.symbol)
Original file line number Diff line number Diff line change 1+ import annotation .static
2+
3+ class T :
4+ @ static val foo = 10 // error
5+
6+ val x = (new T ).foo
You can’t perform that action at this time.
0 commit comments