Exact equality operator (===) is not treated commutative

Issue #979 resolved
Alexander Johannes created an issue

The following code shows a problem where IC is treating the exact equality operator as if it is not commutative:

@IsTest
private class TestTest {

    virtual class Foo {}
    class Bar extends Foo {}

    @IsTest
    static void test() {
        Foo f = new Foo();
        Bar b = new Bar();

        System.assertEquals(true, b === f);
        System.assertEquals(true, f === b);
    }
}

Line 12 is marked with the following error: Comparison Arguments must be compatible types: TestTest.Foo, TestTest.Bar

The code itself compiles without issues.

Use case: we are creating mocks/stubs for our classes. In many cases we are comparing for exact equality between a variable of the mock type and another with the base type. This works as expected, but is always marked as error in IC 2.

Comments (2)

  1. Scott Wells repo owner

    This should be resolved now. Please let me know if you're still seeing it after updating to a recent build.

  2. Log in to comment