Ticket #67: ticket67.patch
File ticket67.patch, 3.0 KB (added by eric.sellon, 15 years ago) |
---|
-
Source/Boxes.cobra
1166 1166 return true 1167 1167 1168 1168 get subclasses from var 1169 1170 pro baseNode from var 1169 1171 1170 1172 def declForName(name as String) as IBoxMember? is override 1171 1173 """ -
Source/CobraParser.cobra
1160 1160 .throwError(decl.token, 'The other partial declaration is a "[otherDecl.englishName]", not a "[decl.englishName]".') 1161 1161 if 'partial' not in otherDecl.isNames 1162 1162 .throwError(decl.token, 'The other declaration is not marked "partial".') 1163 otherBox = otherDecl to Box # will always work because of above checks 1163 otherBox = otherDecl to Box # will always work because of above check 1164 1165 # deal with partial classes and inheritance 1166 if otherBox inherits Class 1167 myDecl = decl to Class # safe because already checked that it was the same type as otherBox 1168 if otherBox.baseNode is nil 1169 if myDecl.baseNode is not nil 1170 otherBox.baseNode = myDecl.baseNode 1171 else 1172 myOtherType = otherBox.baseNode to AbstractTypeIdentifier 1173 if otherBox.baseNode == myDecl.baseNode 1174 _warning(myDecl.token, 'The class "[otherBox.name]" already inherits from "[myOtherType.name]".') 1175 else if myDecl.baseNode is not nil 1176 thisType = myDecl.baseNode to AbstractTypeIdentifier 1177 .throwError(myDecl.token, 'The class "[otherBox.name]" already inherits from "[myOtherType.name]" and cannot inherit from "[thisType.name]" too.') 1178 1164 1179 for memberDecl in decl.declsInOrder 1165 1180 overload = _overloadIfNeeded(memberDecl.idToken, otherBox, memberDecl.name) 1166 1181 if overload -
Tests/120-classes/990-errors/104-inherit-partial-different.cobra
1 class A 2 pass 3 4 class X 5 is partial 6 inherits A 7 pass 8 9 class B 10 pass 11 12 class X # .error. already 13 is partial 14 inherits B 15 16 class Test 17 18 def main 19 myThing = X() -
Tests/120-classes/604-inherits-partial.cobra
1 class Z is partial 2 pass 3 4 class A 5 pass 6 7 class X 8 is partial 9 inherits A 10 pass 11 12 class B 13 pass 14 15 class X # .warning. already 16 is partial 17 inherits A 18 19 class Z 20 is partial 21 inherits B 22 23 def hi 24 print 'hi' 25 26 class Test 27 28 def main 29 myThing = X() 30 assert myThing inherits A # .warning. always 31 bThing = Z() 32 assert bThing inherits B # .warning. always