apple/pkl · error · VmException

noImplementationForAbstractMethod

noImplementationForAbstractMethod

Error message

noImplementationForAbstractMethod

What it means

Instantiating a concrete Pkl class whose supertype declares an abstract method leaves the class incomplete, so `VmClass.checkAbstractMethods` (run when the class is fully initialized) throws `noImplementationForAbstractMethod` naming the class display name and the missing method's call signature. Pkl, like Java, refuses to treat a class as instantiable if it does not implement all inherited abstract members.

Source

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

  }

  public void initSupertype(TypeNode supertypeNode, VmClass superclass) {
    assert this.supertypeNode == null;
    assert this.superclass == null;

    this.supertypeNode = supertypeNode;
    this.superclass = superclass;
    prototype.lateInitParent(superclass.getPrototype());
  }

  @TruffleBoundary
  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();
  }

View on GitHub (pinned to f3efcbfc9b)

Solutions

  1. Implement the missing method listed in the error's call signature in the concrete class.
  2. If the subclass should also be abstract, mark the subclass `abstract`.
  3. Check for typos: the overriding method's name and parameter list must exactly match the abstract declaration.
  4. Update against the base class definition to see which abstract members exist and which ones are still missing.

Example fix

// before
abstract class Base {
  abstract function describe(): String
}
class Impl extends Base {} // error
// after
class Impl extends Base {
  function describe(): String = "impl"
}
Defensive patterns

Strategy: type-guard

Type guard

// Pkl-side check: a concrete class is valid only if it overrides all inherited abstract members
// at authoring time, compare against the abstract base's declarations:
// abstract class Base { abstract function describe(): String }
// class Impl extends Base { function describe(): String = ... } // must exist

Try / catch

catch (EvalError e) {
  if (e.getMessage().contains("noImplementationForAbstractMethod")) {
    // implement the signature named in the message or mark the class abstract
  }
}

Prevention

When it happens

Trigger: A class extends an abstract class (or implements an abstract type) and overrides all but one abstract method — detected when exactly one abstract method remains unimplemented.

Common situations: Partial migration after an abstract method is added to a shared base class; renaming an override so it no longer matches the abstract declaration; forgetting an override in a new subclass of a library base type.

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/0b1acf986152d5f5. Report an issue: GitHub.