Skip to content

Validation error: Can only refer to own type parameters in nested class/enum #748

@lars-reimann

Description

@lars-reimann

Is your feature request related to a problem?

This code is currently legal:

class MyClass<T> {
    class Inner(p: T) {
        attr a: T

        fun f<S>(p: T, q: S)
    }

    enum InnerEnum {
        Variant(p: T)
    }
}

Desired solution

However, a class/enum variant should only be able to refer to its own type parameters. A function should be able to refer to its own type parameters and the type parameters of the containing class. Add validation for this.

Possible alternatives (optional)

No response

Screenshots (optional)

No response

Additional Context (optional)

No response

Metadata

Metadata

Assignees

Labels

releasedIncluded in a releasevalidation ✔️Improved or new static checks

Type

No type

Projects

Status

✔️ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions