@@ -119,7 +119,7 @@ class CheckErrors : CompilerStep
119119
120120 // these modifiers are never allowed on a type
121121 if (flags.and(FConst.Ctor) != 0 ) err("Cannot use 'new' modifier on type" , loc)
122- if (flags.and(Parser .Once) != 0 ) err("Cannot use 'once' modifier on type" , loc)
122+ if (flags.and(FConst .Once) != 0 ) err("Cannot use 'once' modifier on type" , loc)
123123 if (flags.and(FConst.Override) != 0 ) err("Cannot use 'override' modifier on type" , loc)
124124 if (flags.and(FConst.Private) != 0 ) err("Cannot use 'private' modifier on type" , loc)
125125 if (flags.and(FConst.Protected) != 0 ) err("Cannot use 'protected' modifier on type" , loc)
@@ -177,16 +177,9 @@ class CheckErrors : CompilerStep
177177 // in another check
178178 t.fieldDefs.each |FieldDef f|
179179 {
180- if (! f.isConst && ! f.isStatic && f.isStorage && ! isSys)
180+ if (! f.isConst && ! f.isStatic && f.isStorage && ! isSys && ! f.isOnce )
181181 err("Const type '$t.name ' cannot contain non-const field '$f.name '" , f.loc)
182182 }
183-
184- // check that no once methods
185- t.methodDefs.each |MethodDef m|
186- {
187- if (m.isOnce)
188- err("Const type '$t.name ' cannot contain once method '$m.name '" , m.loc)
189- }
190183 }
191184
192185 private Void checkBase(TypeDef t, CType base)
@@ -256,7 +249,7 @@ class CheckErrors : CompilerStep
256249 // these modifiers are never allowed on a field
257250 if (flags.and(FConst.Ctor) != 0 ) err("Cannot use 'new' modifier on field" , loc)
258251 if (flags.and(FConst.Final) != 0 ) err("Cannot use 'final' modifier on field" , loc)
259- if (flags.and(Parser .Once) != 0 ) err("Cannot use 'once' modifier on field" , loc)
252+ if (flags.and(FConst .Once) != 0 && flags.and(FConst.Synthetic) == 0 ) err("Cannot use 'once' modifier on field" , loc)
260253
261254 // check invalid protection combinations
262255 checkProtectionFlags(flags, loc)
@@ -380,7 +373,7 @@ class CheckErrors : CompilerStep
380373 if (flags.and(FConst.Abstract) != 0 ) err("Invalid combination of 'new' and 'abstract' modifiers" , loc)
381374 else if (flags.and(FConst.Override) != 0 ) err("Invalid combination of 'new' and 'override' modifiers" , loc)
382375 else if (flags.and(FConst.Virtual) != 0 ) err("Invalid combination of 'new' and 'virtual' modifiers" , loc)
383- if (flags.and(Parser .Once) != 0 ) err("Invalid combination of 'new' and 'once' modifiers" , loc)
376+ if (flags.and(FConst .Once) != 0 ) err("Invalid combination of 'new' and 'once' modifiers" , loc)
384377 if (flags.and(FConst.Native) != 0 ) err("Invalid combination of 'new' and 'native' modifiers" , loc)
385378 }
386379
@@ -390,18 +383,18 @@ class CheckErrors : CompilerStep
390383 if (flags.and(FConst.Abstract) != 0 ) err("Invalid combination of 'static' and 'abstract' modifiers" , loc)
391384 else if (flags.and(FConst.Override) != 0 ) err("Invalid combination of 'static' and 'override' modifiers" , loc)
392385 else if (flags.and(FConst.Virtual) != 0 ) err("Invalid combination of 'static' and 'virtual' modifiers" , loc)
393- if (flags.and(Parser .Once) != 0 ) err("Invalid combination of 'static' and 'once' modifiers" , loc)
386+ if (flags.and(FConst .Once) != 0 ) err("Invalid combination of 'static' and 'once' modifiers" , loc)
394387 }
395388
396389 // check invalid abstract flags
397390 if (flags.and(FConst.Abstract) != 0 )
398391 {
399392 if (flags.and(FConst.Native) != 0 ) err("Invalid combination of 'abstract' and 'native' modifiers" , loc)
400- if (flags.and(Parser .Once) != 0 ) err("Invalid combination of 'abstract' and 'once' modifiers" , loc)
393+ if (flags.and(FConst .Once) != 0 ) err("Invalid combination of 'abstract' and 'once' modifiers" , loc)
401394 }
402395
403396 // mixins cannot have once methods
404- if (flags.and(Parser .Once) != 0 )
397+ if (flags.and(FConst .Once) != 0 )
405398 {
406399 if (curType.isMixin)
407400 err("Mixins cannot have once methods" , m.loc)
0 commit comments