opprop / immutability

The Practical Immutability for Classes and Objects (PICO) type system enforces transitive class and object immutability
Other
3 stars 5 forks source link

Update JavaExamples.java #45

Closed Ao-senXiong closed 2 months ago

Ao-senXiong commented 2 months ago

I tried with old PICO checker. Here is the following errors reported by PICO.

JavaExamples.java:10: error: [assignment.type.incompatible] incompatible types in assignment.
        @Mutable Set<String> new_s1 = s; // ERROR, type incompatible
                                      ^
  found   : @Initialized @Immutable Set<@Initialized @Immutable String>
  required: @UnknownInitialization @Mutable Set<@Initialized @Immutable String>
JavaExamples.java:11: error: [method.invocation.invalid] call to add(E) not allowed on the given receiver.
        new_s.add("x"); // ERROR
                 ^
  found   : @Initialized @Immutable Set</*INFERENCE FAILED for:*/ ? extends Object>
  required: @Initialized @Mutable Set</*INFERENCE FAILED for:*/ ? extends Object>
JavaExamples.java:18: error: [method.invocation.invalid] call to add(E) not allowed on the given receiver.
        new_s.add("x"); // ERROR
                 ^
  found   : @Initialized @Immutable Set</*INFERENCE FAILED for:*/ ? extends Object>
  required: @Initialized @Mutable Set</*INFERENCE FAILED for:*/ ? extends Object>
JavaExamples.java:38: error: [method.invocation.invalid] call to add(E) not allowed on the given receiver.
        p.family.add("Jenny"); // ERROR, can not mutate immut list
                    ^
  found   : @Initialized @Immutable List</*INFERENCE FAILED for:*/ ? extends Object>
  required: @Initialized @Mutable List</*INFERENCE FAILED for:*/ ? extends Object>
JavaExamples.java:56: error: [method.invocation.invalid] call to add(E) not allowed on the given receiver.
        this.family.add("Mom"); // ERROR
                       ^
  found   : @Initialized @Immutable List</*INFERENCE FAILED for:*/ ? extends Object>
  required: @Initialized @Mutable List</*INFERENCE FAILED for:*/ ? extends Object>
JavaExamples.java:64: error: [return.type.incompatible] incompatible types in return.
        return family; // ERROR, type incompatible
               ^
  type of expression: @Initialized @Immutable List<@Initialized @Immutable String>
  method return type: @Initialized @Mutable List<@Initialized @Immutable String>
6 errors
Ao-senXiong commented 2 months ago

Closed and use #48.