Merge: Contract refactoring
authorJean Privat <jean@pryen.org>
Mon, 8 Jun 2020 19:58:00 +0000 (15:58 -0400)
committerJean Privat <jean@pryen.org>
Mon, 8 Jun 2020 19:58:00 +0000 (15:58 -0400)
This pr do the following changes:

* Authorize the declaration of identical contracts on the same method in order to facilitate the reading of contracts. Example
```nit
fun foo(x, y: Int)
is
expect(x > 0)
expect(y > 0)
do end
```

* Modification of the generation of contracts. In the default mode, the contracts are now generated even if they are not used, only the public facet is generated only if it is necessary. The objective is to provide the contracts verification when you are in a redefinition in a module where contracts must be applied. This solution is a compromise to try to keep acceptable performance in the default mode. Example

```nit
module one
import two
[...]

module two
import three

redef class C
# Now all calls to foo of c (only in module one or two) check the `expect` property defined in module three (as defined by the default contract rule).
redef foo ...
end

module three

class C
fun foo is expect(true), ensure(true)
end
```

* When a contract is not fulfilled the messages displayed to the user are now more explicit. Example:

```nit\
class A
fun foo(i: Int) is expect(i > 0) do end
end

var a = new A
a.foo(0)
```
This is the output of the program
```
Runtime error: Assert 'expect(i > 0)' failed
```

* Cosmetic modifications have been made to remove useless methods, modify the names and comments of certain methods to be more explicit.

Pull-Request: #2827


Trivial merge