Skip to content

Validation error: Impurity reasons of overriding methods must be subset of impurity reasons of overridden methods #665

@lars-reimann

Description

@lars-reimann

Basic example: If the overridden method is pure, the overriding method must be pure as well:

package tests.validation.other.declarations.functions.purePropagates

class MyOpenClass {
    @Pure fun pureFunction1()
    @Pure fun pureFunction2()
    fun impureFunction1()
}

class MyClass sub MyOpenClass {
    // $TEST$ no error "One of the supertypes of this class declares a pure function with this name, so this must be pure as well."
    @Pure fun »ownPureFunction«()
    // $TEST$ no error "One of the supertypes of this class declares a pure function with this name, so this must be pure as well."
    fun »ownImpureFunction«()

    // $TEST$ error "One of the supertypes of this class declares a pure function with this name, so this must be pure as well."
    fun »pureFunction1«()
    // $TEST$ no error "One of the supertypes of this class declares a pure function with this name, so this must be pure as well."
    @Pure fun »pureFunction2«()
    // $TEST$ no error "One of the supertypes of this class declares a pure function with this name, so this must be pure as well."
    @Pure fun »impureFunction1«()
}

Metadata

Metadata

Assignees

Labels

releasedIncluded in a releasevalidation ✔️Improved or new static checks

Type

No type

Projects

Status

✔️ Done

Relationships

None yet

Development

No branches or pull requests

Issue actions