Ticket #169: static-ctor.patch
File static-ctor.patch, 2.9 KB (added by hopscc, 15 years ago) |
---|
-
Source/Members.cobra
1003 1003 else if stmt.left inherits ThisLit and ((stmt.right inherits MemberExpr and (stmt.right to MemberExpr).name == 'init') or (stmt.right inherits CallExpr and (stmt.right to CallExpr).name == 'init')) # CC: axe casts 1004 1004 isThisInit = true 1005 1005 if first 1006 if .isClassMember and not isBase and not isThisInit 1006 if .isClassMember and not isBase and not isThisInit and not stmt inherits PassStmt 1007 1007 # structs cannot call base constructors 1008 1008 .compiler.warning(stmt, 'The first statement of an "init" cue should be a call to another "init" in this class or the base class.') 1009 1009 else -
Source/BackEndClr/SharpGenerator.cobra
1697 1697 class Initializer 1698 1698 is partial 1699 1699 1700 def _fixupIsNames 1701 # suppress adding default access modifiers on static initializer 1702 # any access modifier in static ctor is error but that should have been caught in bind* methods 1703 # we'll just cater to the default 'public' 1704 if 'shared' in _isNames and _isNames.count > 1 1705 _isNames.remove('public') 1706 1700 1707 def innerWriteSharpDef(sw as CurlyWriter) 1701 1708 base.innerWriteSharpDef(sw) 1702 1709 .writeSharpAttribs(sw) … … 1710 1717 args = firstRight.args 1711 1718 Stmt.inInitCall = true 1712 1719 didSetInInitCall = true 1720 _fixupIsNames 1713 1721 .writeSharpIsNames(sw) 1714 1722 sw.write(' [.parentBox.rootName]') 1715 1723 .writeSharpParams(sw) -
Tests/120-classes/325-static-ctor.cobra
1 # This gave erroneous codegen on cue init line (ticket:169) 2 # generating 3 # public static Foo {} <-- 'access modifiers are not allowed on static constructors (C#)' 4 class Foo 5 shared 6 cue init 7 pass 8 9 def x is private 10 pass 11 12 def main 13 pass 14 15 16 class Foo1 17 cue init is shared 18 pass 19 20 def x is shared, private 21 pass 22 23 def main1 is shared 24 pass 25 -
Developer/IntermediateReleaseNotes.text
381 381 * Fixed: Cannot pass dynamic values to initializers. ticket:74 382 382 383 383 * Fixed: Cobra gives an inscrutable error message for numeric for-loops that have incompatible numeric types. ticket:165 384 385 * Fixed: Improper codegen for static constructors. ticket:169