Skip to content

Methods called from toString need a readonly receiver type #59

@Shreyas-BS

Description

@Shreyas-BS

Issue Description

Primitive int Readonly constant numbers when passed to the toString method as radix parameter creates this error. It is expecting the object to be also Readonly Type.

How to reproduce

Create an object of type Immutable or Mutable and add 2 toString functions (function overloading) differentiated by an int radix parameter. Call the toString with a constant number as a radix parameter inside the other toString function without.

Screen Shot / Recording

Screenshot 2024-06-30 at 3 43 11 PM Screenshot 2024-06-30 at 4 22 41 PM

Sample Minimum test case code

import qual.Immutable;

@Immutable
public final class Demo {

    // private final @Immutable int value = 123;

    public @Immutable String toString() {
        return toString(10);
    }

    public @Immutable String toString(int radix) {
        return "Hello";
        // Usually it would be calling a function like this
        // return Integer.toString(this.value, radix);
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions