File tree 2 files changed +8
-0
lines changed
compiler/src/dotty/tools/dotc/transform
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 {
36
36
if (defn.symbol.isScalaStatic) {
37
37
if (! ctx.owner.is(Module ))
38
38
report.error(StaticFieldsOnlyAllowedInObjects (defn.symbol), defn.srcPos)
39
+ defn.symbol.resetFlag(JavaStatic )
39
40
40
41
if (defn.isInstanceOf [ValDef ] && hadNonStaticField)
41
42
report.error(StaticFieldsShouldPrecedeNonStatic (defn.symbol, defns), defn.srcPos)
@@ -68,6 +69,7 @@ class CheckStatic extends MiniPhase {
68
69
case t : Select => isSafeQual(t.qualifier) && symbolWhitelist.contains(t.symbol)
69
70
case t : Ident => symbolWhitelist.contains(t.symbol)
70
71
case t : Block => t.stats.forall(tpd.isPureExpr) && isSafeQual(t.expr)
72
+ case _ => false
71
73
}
72
74
if (isSafeQual(tree.qualifier))
73
75
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