Menu

TypeArgumentDeclaration and TypeReference

Developers
2011-06-24
2012-10-08
  • Andrea Poli

    Andrea Poli - 2011-06-24

    Hi, while I was creating a type reference, using
    recoder.kit.TypeKit.createTypeReference, of this type:

    Map.Entry<String, String>
    

    I received a NullPointerException.
    Both parameters of type Map.Entry where represented as TypeArgumentDeclaration
    which contains a TypeReference.
    It seems that the TypeReference inside TypeArgumentDeclaration has no parent.

    I patched this problem changing the methods:

    recoder.java.reference.TypeReference

        public void makeParentRoleValid() {
            super.makeParentRoleValid();
            if (prefix != null) {
                prefix.setReferenceSuffix(this);
            }
            if (name != null) {
                name.setParent(this);
            }
            if (typeArguments != null) {
                for(TypeArgumentDeclaration ta : typeArguments) {
                    ta.setParent(this);
                    //AP 22/06/2011 - 16.27
                    ta.makeParentRoleValid();
                }
            }
        }
    

    recoder.java.declaration.TypeArgumentDeclaration

        public void makeParentRoleValid() {
            super.makeParentRoleValid();
            if (typeReference != null){
                typeReference.setParent(this);
                //AP 22/06/2011 - 16.27
                typeReference.makeParentRoleValid();
            }
        }
    

    I'd like to know if there is a better solution in order to solve this problem.

    Thanks a lot :-)

     
  • Tobias Gutzmann

    Tobias Gutzmann - 2011-06-26

    Hej,

    this looks like bugs to me in TypeKit. It should be fixed there instead.
    I will investigate it further after July 10, but "unfortunately", I am going
    onto vacation for now ;)

    Regards,
    Tobias

     
  • Tobias Gutzmann

    Tobias Gutzmann - 2011-07-10

    Hi,

    I cannot reproduce this. Which of the overloaded methods are you using? Can
    you provide a minimal example that triggers the bug?

    /Tobias

     

Log in to post a comment.