False positive inspector error Batchable start method return type: List<CustomType>

Issue #2071 resolved
Eric Kintzer created an issue

Sort of an edge case but I know you like to hear about these things. Observe line 5

public inherited sharing class Ic2Batchable implements Database.Batchable<MyInnerClass> {

    private class MyInnerClass{}

    public MyInnerClass[] start(Database.BatchableContext param1) {
        return null;
    }
    public void execute(Database.BatchableContext param1, List<MyInnerClass> param2) {
    }
    public void finish(Database.BatchableContext param1) {
    }
}

Line 5 has an inspection error but compiles fine because lists implicitly implement Iterable:

Overridden/implemented method return types clash: expected type Iterable; 
found Ic2Batchable.MyInnerClass[] 

Replacing line 5 with below resolves the inspection error

public Iterable<MyInnerClass> start(Database.BatchableContext param1) {

Comments (3)

  1. Scott Wells repo owner

    Thanks for filing, Eric. You're correct that I prefer to take care of these types of things even if they seem to be edge cases. I probably won't get to this in the next week as I'm updating for the Salesforce CLI changes that will be (re)released on Thursday, but I'll take a look for a near-term release.

  2. Log in to comment