Skip to content

Overloading not accounting for arguments type for state transitions #134

@CatarinaGamboa

Description

@CatarinaGamboa

I think there's a bug in selecting the correct method to check when there are two methods with the same number of arguments but different types.

This was the example where I encountered the issue.

This class has two constructors with only 1 argument, but they go to different states. With the first, it's okay to call initCause, with the second, it is not.

@StateSet({"start", "hasMessage", "hasCause"})
@ExternalRefinementsFor("java.lang.Throwable")
public interface ThrowableRefinements {

    // ##### Constructors #######
    @StateRefinement(to="hasMessage(this)")
    public void Throwable(String message);

    @StateRefinement(to="hasCause(this)")
    public void Throwable(Throwable cause);

    @StateRefinement(from="!hasCause(this)", to="hasCause(this)")
    public Throwable initCause(Throwable cause);
}

Tests where we can see the issue:

public class Test{
    void test3(){
        Throwable t = new Throwable("Example");
        t.initCause(null);
        t.getCause();
    }

    void test4(){
        Throwable originT = new Throwable();
        Throwable t = new Throwable(originT); // should be an error but its not
        t.initCause(null);
        t.getCause();
    }

}

Now, what leads me to think this is an issue in selecting the methods is that we get errors in both test cases if:

  • we remove the constructor with string
  • change the order of the two constructors

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions