Ticket #302: mixin-collision.patch
File mixin-collision.patch, 2.6 KB (added by hopscc, 12 years ago) |
---|
-
Source/Boxes.cobra
1592 1592 # TODO: contracts? tests? 1593 1593 for stmt in member.statements 1594 1594 method.addStmt(stmt.clone) 1595 if box.declForName(method.name) 1596 box.throwError('mixin added method "[method.name]" is already in [box.englishName] "[box.name]"') 1595 1597 box.addDecl(method) 1596 1598 else if member inherits Property 1597 1599 prop = Property(member.token, member.idToken, box, member.name, member.returnType, member.isNames, member.attributes, member.docString) … … 1603 1605 setPart = prop.makeSetPart(member.setPart.token) 1604 1606 for stmt in member.setPart.statements 1605 1607 setPart.addStmt(stmt.clone) 1608 if box.declForName(prop.name) 1609 box.throwError('mixin added property "[prop.name]" is already in [box.englishName] "[box.name]"') 1606 1610 box.addDecl(prop) 1607 1611 else if member inherits BoxField 1612 if box.declForName(member.name) 1613 box.throwError('mixin added member "[member.name]" is already in [box.englishName] "[box.name]"') 1608 1614 box.addDecl(member) 1609 1615 else 1610 1616 # TODO: warning? -
Tests/150-mixins/140-mixin-collision-method.cobra
1 mixin MixA 2 def sayhello 3 pass 4 5 mixin MixB 6 def sayhello 7 pass 8 9 class Hello #.error. "sayhello" is already in class 10 adds MixA, MixB 11 12 def main 13 pass -
Tests/150-mixins/142-mixin-collision-prop.cobra
1 mixin MixA 2 def sayhello 3 pass 4 5 mixin MixB 6 pro foo from var as int 7 8 9 class Hello #.error. property "foo" is already in class 10 adds MixA, MixB 11 12 var _fooA as int 13 14 pro foo from _fooA 15 16 def main 17 pass -
Tests/150-mixins/144-mixin-collision-field.cobra
1 mixin MixA 2 var memA as int 3 4 mixin MixB 5 pro foo from var as int 6 7 8 class Hello #.error. member "memA" is already in 9 adds MixA, MixB 10 11 var memA as int 12 13 def main 14 pass