Salesforce Dictionary - Free Salesforce GlossarySalesforce Dictionary
All errors
Apex

Method does not exist or incorrect signature

The Apex compiler can't find a method matching the call you wrote — wrong name, wrong argument types, or wrong number of arguments. The compiler points at the line; the fix is usually a typo or a stale signature.

Also seen asMethod does not exist or incorrect signature·Method does not exist·incorrect signature apex

Apex method dispatch is statically typed. The compiler resolves every method call at compile time. If your call doesn't match an existing method, you get this error before the code ever runs.

The four shapes

1. Wrong name (typo)

String s = 'hello';
s.toUppercase();   // ❌ method is toUpperCase, not toUppercase

The compiler reports the line. Fix the typo.

2. Wrong argument types

Integer a = 1;
String b = '2';
Math.max(a, b);   // ❌ Math.max takes two Integers (or two Decimals)

Apex doesn't auto-coerce types. Convert explicitly:

Math.max(a, Integer.valueOf(b));

3. Wrong number of arguments

String.format('Hello {0}');   // ❌ String.format requires (template, args)
String.format('Hello {0}', new List<Object>{ 'world' });   // ✅

4. Method exists in a different scope

public class Outer {
    private class Inner {
        public void doSomething() { ... }
    }
}

Outer o = new Outer();
o.doSomething();   // ❌ doSomething is on Inner, not Outer

Reference the right type.

A common cause: stale references to renamed Apex

If you renamed a method and missed a caller, the deploy fails with this error pointing at the caller. Use VS Code's "Find All References" before renaming, not after.

When the method DOES exist

Three subtle cases where the compiler claims the method doesn't exist but it does:

  1. The method is declared protected and you're calling from outside the class hierarchy. The compiler treats it as not-existing for visibility.
  2. The class is in a managed package namespace and you forgot the namespace prefix. MyPackage.MyClass.doSomething() not MyClass.doSomething().
  3. The method has a Comparable / Iterator parameter and your argument doesn't implement the interface. The compiler matches by exact interface, not by structural duck-typing.

In test classes

Test classes can call private methods only if they're inside the same outer class or marked @TestVisible. If you're seeing this error on a private method from a test class:

public class MyClass {
    @TestVisible private void helper() { ... }
}

@TestVisible makes the method accessible from test classes anywhere in the org without changing its production-code visibility.

Related dictionary terms