{"record":{"id":"69cb1c7fae37b1e5","repo":"apple/pkl","slug":"expectedannotationclass","errorCode":"expectedAnnotationClass","errorMessage":"Expected an annotation class.","messagePattern":"Expected an annotation class\\.","errorType":"exception","errorClass":"VmException","httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/ast/expression/literal/CheckIsAnnotationClassNode.java","lineNumber":50,"sourceCode":"    this.unresolvedTypeNode = unresolvedTypeNode;\n  }\n\n  @Override\n  public Object executeGeneric(VirtualFrame frame) {\n    if (typeNode == null) {\n      // invalidation is done by insert()\n      CompilerDirectives.transferToInterpreter();\n      assert unresolvedTypeNode != null;\n      typeNode = insert(unresolvedTypeNode.execute(frame));\n      unresolvedTypeNode = null;\n    }\n    var clazz = typeNode.getVmClass();\n    if (clazz != null && clazz.isSubclassOf(BaseModule.getAnnotationClass())) {\n      return typeNode.getVmClass();\n    }\n\n    CompilerDirectives.transferToInterpreter();\n    throw exceptionBuilder().evalError(\"expectedAnnotationClass\").build();\n  }\n}\n","sourceCodeStart":32,"sourceCodeEnd":53,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/ast/expression/literal/CheckIsAnnotationClassNode.java#L32-L53","documentation":"An annotation position (e.g. `@Type` style usage via this node) expected a class that is a subclass of `Annotation`, but the given type resolved to a non-annotation class. Pkl only permits `@AnnotationClass` in annotation positions.","triggerScenarios":"Writing `@SomeClass` where `SomeClass` is a regular class, module import, or type alias that is not declared as `annotation class SomeClass`.","commonSituations":"Typo in annotation name, annotating with a plain `class` instead of an `annotation class`, or importing the wrong symbol with the same name.","solutions":["Declare the class as an annotation class: `annotation class Foo`.","Use a built-in annotation like `@Deprecated` or a project-defined annotation class.","Check imports — the name may resolve to a non-annotation class in another module."],"exampleFix":"// before\nclass MyAnno\n@MyAnno property x: Int\n// after\nannotation class MyAnno\n@MyAnno property x: Int","handlingStrategy":"validation","validationCode":"// verify the symbol is an annotation class before use\n// annotation class MyAnno","typeGuard":"function isAnnotationClass(c) { return c != null && c is Class && c.isSubclassOf(Annotation); }","tryCatchPattern":null,"preventionTips":["Declare annotators with the `annotation class` keyword.","Verify imports resolve to the intended annotation class.","Prefer built-in annotations (@Deprecated, @DocComment) when possible."],"tags":["pkl","annotation","class"],"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"}