accessors icon indicating copy to clipboard operation
accessors copied to clipboard

Using alias-imported types for fields might cause naming collisions

Open duselbaer opened this issue 7 years ago • 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)

duselbaer avatar May 09 '17 08:05 duselbaer

Still doesn't work for @Write.

belka-ew avatar Oct 20 '17 08:10 belka-ew

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

belka-ew avatar Oct 23 '17 14:10 belka-ew