apple/pkl · error · VmException

noImplementationForAbstractMethods

noImplementationForAbstractMethods

Error message

noImplementationForAbstractMethods

What it means

Same check as `noImplementationForAbstractMethod`, but when two or more abstract methods remain unimplemented, `VmClass.checkAbstractMethods` throws `noImplementationForAbstractMethods` with the class name and a multiline list of all missing method signatures.

Source

Thrown at pkl-core/src/main/java/org/pkl/core/runtime/VmClass.java:173

  private void checkAbstractMethods() {
    if (isAbstract()) return;
    // minimize allocations in the non-error case
    var abstractMethods = getAbstractMethods();
    if (abstractMethods.isEmpty()) return;
    if (abstractMethods.size() == 1) {
      throw new VmExceptionBuilder()
          .evalError(
              "noImplementationForAbstractMethod",
              getDisplayName(),
              abstractMethods.get(0).getCallSignature())
          .withSourceSection(getHeaderSection())
          .build();
    }
    var methodList = new ArrayList<String>(abstractMethods.size());
    for (var method : abstractMethods) {
      methodList.add(method.getCallSignature());
    }
    throw new VmExceptionBuilder()
        .evalError(
            "noImplementationForAbstractMethods", getDisplayName(), MultilineValue.of(methodList))
        .withSourceSection(getHeaderSection())
        .build();
  }

  private List<ClassMethod> getAbstractMethods() {
    assert this.superclass != null;
    var result = new ArrayList<ClassMethod>();
    var methodCursor = getAllMethods().getEntries();
    while (methodCursor.advance()) {
      var method = methodCursor.getValue();
      if (method.isAbstract()) {
        result.add(method);
      }
    }
    return result;
  }

View on GitHub (pinned to f3efcbfc9b)

Solutions

  1. Implement every method listed in the error's multiline signature list in the concrete class.
  2. Mark the class `abstract` if it is not meant to be instantiated directly.
  3. Fix method name/parameter-list mismatches so existing overrides actually satisfy the abstract declarations.
  4. Use the IDE's quick-fix/generate-override support to implement all inherited abstract members at once.

Example fix

// before
abstract class Base {
  abstract function a(): String
  abstract function b(): Int
}
class Impl extends Base {}
// after
class Impl extends Base {
  function a(): String = "a"
  function b(): Int = 1
}
Defensive patterns

Strategy: type-guard

Type guard

// require subclasses to implement every listed abstract signature before use;
// validate in CI by evaluating (not just compiling) every concrete module:
// pkl eval **/*.pkl --no-cache // forces class initialization, surfacing missing overrides

Try / catch

catch (EvalError e) {
  if (e.getMessage().contains("noImplementationForAbstractMethods")) {
    // implement each signature in the multiline list, or mark the class abstract
  }
}

Prevention

When it happens

Trigger: A concrete class extends an abstract class (or implements an interface) and leaves two or more abstract methods unimplemented, detected at class fully-initialization time.

Common situations: Creating a minimal stub subclass of a rich abstract base type and forgetting several overrides; interface churn in a shared library adding multiple abstract members; copy-pasting a partial skeleton class.

Understand the failure class

Background: "NotImplementedError: Subclasses should override this method" / "must be implemented" — abstract method errors explained — this error's family across 40 libraries.

Related errors


AI-assisted analysis of apple/pkl@f3efcbfc9b (2026-09-08). Data as JSON: /api/errors/ce620cdaf4f20c45. Report an issue: GitHub.