{"record":{"id":"b48c179d03b98b05","repo":"apple/pkl","slug":"invalidsupertype-b48c17","errorCode":"invalidSupertype","errorMessage":"invalidSupertype","messagePattern":"invalidSupertype","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/ast/member/ClassNode.java","lineNumber":169,"sourceCode":"        cachedClass.addProperty(node.execute(frame, cachedClass));\n      }\n\n      for (var node : unresolvedMethodNodes) {\n        cachedClass.addMethod(node.execute(frame, cachedClass));\n      }\n\n      cachedClass.onOwnClassInitialized();\n      localContext.endClassInit();\n      return cachedClass;\n    } catch (Throwable e) {\n      localContext.clearClassInitState();\n      throw e;\n    }\n  }\n\n  private void checkSupertype(TypeNode supertypeNode, @Nullable VmClass superclass) {\n    if (superclass == null) {\n      throw exceptionBuilder()\n          .evalError(\"invalidSupertype\", supertypeNode.getSourceSection().getCharacters())\n          .withSourceSection(supertypeNode.getSourceSection())\n          .build();\n    }\n    if (moduleInfo != null) {\n      if (cachedClass == superclass) {\n        throw exceptionBuilder()\n            .evalError(\"moduleCannotExtendSelf\", moduleInfo.getModuleName())\n            .withSourceSection(supertypeNode.getSourceSection())\n            .build();\n      }\n      if (superclass.isClosed()) {\n        throw exceptionBuilder()\n            .evalError(\"cannotExtendFinalModule\", superclass.getModuleName())\n            .withSourceSection(supertypeNode.getSourceSection())\n            .build();\n      }\n    } else {","sourceCodeStart":151,"sourceCodeEnd":187,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/ast/member/ClassNode.java#L151-L187","documentation":"Pkl throws invalidSupertype when a class (or module) declares a supertype that resolves to something that is not an actual class. During class initialization, ClassNode.checkSupertype validates the resolved superclass; if the superclass is null — meaning the type reference did not resolve to a VmClass — the declaration is rejected. This keeps the inheritance graph well-formed before any evaluation of the class body.","triggerScenarios":"Declaring `extends X` where X resolves to a non-class value (object, property, function, type alias to a non-class); misspelling a class name so the identifier resolves to nothing usable; extending a module-level property instead of a class.","commonSituations":"Typo in a class name in an `extends` clause; refactoring renames a class leaving a stale supertype reference; accidentally extending an object or a type alias rather than a class; importing the wrong module and inheriting from a similarly named non-class member.","solutions":["Check the identifier after `extends` in the error's highlighted source section and confirm it names a class.","Fix the spelling or import path so it points at the intended class.","If you meant to inherit type constraints only, use `typechecked` or a type annotation instead of `extends`.","Ensure the imported module actually exports the class you are extending."],"exampleFix":"// before\nmodule my_config\n\nextends baseConfg  // typo, resolves to nothing\n\n// after\nextends BaseConfig","handlingStrategy":"validation","validationCode":"// Verify the extends target is a real class before relying on it:\nimport \"mylib.pkl\"\n// mylib.pkl must contain: class BaseConfig { ... }\n// In tooling/tests, render the module to fail fast:\n// pkl eval my_config.pkl  -> invalidSupertype surfaces at definition time","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always extend classes that are visibly declared as `class` in the imported module.","Use IDE navigation (pkl-lsp) to jump to the extends target and confirm it is a class.","Run `pkl eval` in CI so bad supertypes fail before deployment.","Avoid extending type aliases or object-valued properties."],"tags":["pkl","inheritance","type-resolution","compile-time"],"backgroundTag":"invalid-argument-value","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"}