{"record":{"id":"0b1acf986152d5f5","repo":"apple/pkl","slug":"noimplementationforabstractmethod","errorCode":"noImplementationForAbstractMethod","errorMessage":"noImplementationForAbstractMethod","messagePattern":"noImplementationForAbstractMethod","errorType":"error_code","errorClass":"VmException","httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/runtime/VmClass.java","lineNumber":161,"sourceCode":"  }\n\n  public void initSupertype(TypeNode supertypeNode, VmClass superclass) {\n    assert this.supertypeNode == null;\n    assert this.superclass == null;\n\n    this.supertypeNode = supertypeNode;\n    this.superclass = superclass;\n    prototype.lateInitParent(superclass.getPrototype());\n  }\n\n  @TruffleBoundary\n  private void checkAbstractMethods() {\n    if (isAbstract()) return;\n    // minimize allocations in the non-error case\n    var abstractMethods = getAbstractMethods();\n    if (abstractMethods.isEmpty()) return;\n    if (abstractMethods.size() == 1) {\n      throw new VmExceptionBuilder()\n          .evalError(\n              \"noImplementationForAbstractMethod\",\n              getDisplayName(),\n              abstractMethods.get(0).getCallSignature())\n          .withSourceSection(getHeaderSection())\n          .build();\n    }\n    var methodList = new ArrayList<String>(abstractMethods.size());\n    for (var method : abstractMethods) {\n      methodList.add(method.getCallSignature());\n    }\n    throw new VmExceptionBuilder()\n        .evalError(\n            \"noImplementationForAbstractMethods\", getDisplayName(), MultilineValue.of(methodList))\n        .withSourceSection(getHeaderSection())\n        .build();\n  }\n","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/runtime/VmClass.java#L143-L179","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Implement the missing method listed in the error's call signature in the concrete class.","If the subclass should also be abstract, mark the subclass `abstract`.","Check for typos: the overriding method's name and parameter list must exactly match the abstract declaration.","Update against the base class definition to see which abstract members exist and which ones are still missing."],"exampleFix":"// before\nabstract class Base {\n  abstract function describe(): String\n}\nclass Impl extends Base {} // error\n// after\nclass Impl extends Base {\n  function describe(): String = \"impl\"\n}","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"// Pkl-side check: a concrete class is valid only if it overrides all inherited abstract members\n// at authoring time, compare against the abstract base's declarations:\n// abstract class Base { abstract function describe(): String }\n// class Impl extends Base { function describe(): String = ... } // must exist","tryCatchPattern":"catch (EvalError e) {\n  if (e.getMessage().contains(\"noImplementationForAbstractMethod\")) {\n    // implement the signature named in the message or mark the class abstract\n  }\n}","preventionTips":["When adding an abstract method to a base class, update all known subclasses in the same change.","Use an IDE with Pkl support to surface unimplemented overrides while editing.","Grep for `extends <Base>` when changing a base class's abstract surface."],"tags":["pkl","classes","abstract-method","inheritance"],"backgroundTag":"abstract-method-not-implemented","analyzedSha":"f3efcbfc9b60d30053b0536d664948d7aa1b8673","analyzedAt":"2026-09-08T13:10:45.570Z","contentChangedAt":"2026-09-08T13:10:45.570Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}