Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

call to super method causes precondition violation

#18

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

Reported by me (at andresteingress) · April 11th, 2011 @ 09:14 PM

State: new
Milestone: 1.2.6

Activity

  1. me (at andresteingress)
    me (at andresteingress)
    • Milestone changed from 1.2.2 to 1.2.3
    • Milestone order changed from 11 to 0

    May 12th, 2011 @ 08:08 PM

  2. me (at andresteingress)
    me (at andresteingress)
    • Milestone changed from 1.2.3 to 1.2.4
    • Milestone order changed from 3 to 0

    May 18th, 2011 @ 11:17 AM

  3. me (at andresteingress)
    me (at andresteingress)
    • Milestone changed from 1.2.4 to 1.2.5
    • Milestone order changed from 1 to 0

    June 12th, 2011 @ 10:05 PM

  4. me (at andresteingress)
    me (at andresteingress)
    • 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

    January 15th, 2012 @ 09:24 PM

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.