Skip to content

Primary constructor type parameter syntax #3172

Closed
@munificent

Description

@munificent

The proposed syntax for a generic class with a named primary constructor (#3023) is:

class D.named<T>(int x);

It feels to me like it should be:

class D<T>.named(int x);

The type parameters are a property of the class itself, not the constructor. The syntax for invoking a named constructor on a generic class is:

D<String>.named(123)

Also, if we ever want to support generic constructors, we may find ourselves wanting to allow:

class D<ClassTypeParam>.named<CtorTypeParam>(int x);

Metadata

Metadata

Assignees

No one assigned

    Labels

    brevityA feature whose purpose is to enable concise syntax, typically expressible already in a longer formprimary-constructors

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions