call to super method causes precondition violation
Reported by me (at andresteingress) | April 11th, 2011 @ 09:14 PM | in 1.2.6
let's consider this valid piece of precondition overriding:
class Account
{
protected BigDecimal balance
def Account( BigDecimal amount = 0.0 )
{
balance = amount
}
void deposit( BigDecimal amount )
{
balance += amount
}
@Requires({ amount >= 0.0 })
@Ensures({ balance == old.balance - amount })
BigDecimal withdraw( BigDecimal amount )
{
if (balance < amount) return 0.0
balance -= amount
return amount
}
BigDecimal getBalance()
{
return balance
}
}
class BetterAccount extends Account {
@Requires({ true })
BigDecimal withdraw( BigDecimal amount )
{
return super.withdraw (amount)
}
}
in the case above, betterAccount.withdraw (null) fails (it shouldn't) because a call to super causes a fresh revalidation
Comments and changes to this ticket
-
me (at andresteingress) May 12th, 2011 @ 08:08 PM
- Milestone changed from 1.2.2 to 1.2.3
- Milestone order changed from 11 to 0
-
me (at andresteingress) May 18th, 2011 @ 11:17 AM
- Milestone changed from 1.2.3 to 1.2.4
- Milestone order changed from 3 to 0
-
me (at andresteingress) June 12th, 2011 @ 10:05 PM
- Milestone changed from 1.2.4 to 1.2.5
- Milestone order changed from 1 to 0
-
me (at andresteingress) January 15th, 2012 @ 09:24 PM
- Milestone changed from 1.2.5 to 1.2.6
maybe this issue can be solved by creating an execution tracker instance around the complete method block
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป
core module