funkwerk/accessors

Using alias-imported types for fields might cause naming collisions

Opened this issue · 2 comments

When using two different types with the same name (one of them imported as an alias) inside a class breaks compilation:

import accessors;
import person : PersonId;
import another : AnotherPersonId = PersonId;

class Foo
{
    @ConstRead
    private PersonId personId_;

    @ConstRead
    private AnotherPersonId anotherPersonId_;

    mixin(GenerateFieldAccessors);
}

Error: cannot implicitly convert expression (this.anotherPersonId_) of type const(PersonId) to const(PersonId)

Still doesn't work for @Write.

Test case:

import accessors;
import person : PersonId;
import another : AnotherPersonId = PersonId;

class PersonId
{
}

class WriteAttrTest
{
    @Write
    private PersonId personId_;

    @Write
    private AnotherPersonId anotherPersonId_;

    mixin(GenerateFieldAccessors);
}
Error: cannot implicitly convert expression anotherPersonId of type main.PersonId to PersonId.PersonId