{"record":{"id":"fffcf10467d37390","repo":"apple/pkl","slug":"invalidthistypeintypealias","errorCode":"invalidThisTypeInTypeAlias","errorMessage":"invalidThisTypeInTypeAlias","messagePattern":"invalidThisTypeInTypeAlias","errorType":"error_code","errorClass":"VmException","httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/ast/builder/AstBuilder.java","lineNumber":453,"sourceCode":"    var sourceSection = createSourceSection(type);\n    // need to pass explicit class name for property and method arg/return type annotations.\n    // this is because type annotations on class properties/methods are initialized when the\n    // ClassNode\n    // is executed, and the frame's receiver is the enclosing module rather than the class.\n    // do not need: when in any object or at the module level (where `this` is the receiver's class)\n    org.pkl.core.runtime.Identifier className = null;\n    for (var scope = symbolTable.getCurrentScope(); scope != null; scope = scope.getParent()) {\n      if (scope.isObjectScope() || scope.isCustomThisScope()) {\n        break;\n      }\n      if (scope instanceof ClassScope foundClassScope) {\n        className = foundClassScope.getName();\n        break;\n      }\n      // it's still safe to break on ObjectScope because this is valid:\n      // typealias Foo = List(any((it) -> it == new Dynamic { it is this })) // this == Dynamic\n      if (scope.isTypeAliasScope()) {\n        throw exceptionBuilder()\n            .withSourceSection(sourceSection)\n            .evalError(\"invalidThisTypeInTypeAlias\")\n            .build();\n      }\n    }\n\n    ExpressionNode getClassNode;\n    if (isBaseModule && className != null) {\n      getClassNode = new GetBaseModuleClassNode(className);\n    } else if (className == null) {\n      getClassNode = new GetReceiverClassNode(sourceSection);\n    } else if (className.isLocalProp()) {\n      getClassNode =\n          new ReadQualifiedLocalPropertyNode(\n              sourceSection, className, false, new GetModuleNode(sourceSection));\n    } else {\n      getClassNode =\n          ReadPropertyNodeGen.create(","sourceCodeStart":435,"sourceCodeEnd":471,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/ast/builder/AstBuilder.java#L435-L471","documentation":"AstBuilder.visitThisType throws 'invalidThisTypeInTypeAlias': `this` types (e.g. in type annotations) are not permitted inside a type alias, since a typealias has no receiver. The input at fault is a `this` type reference appearing in a typealias declaration.","triggerScenarios":"Thrown at pkl-core/src/main/java/org/pkl/core/ast/builder/AstBuilder.java:453 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Replace the `this` type in the typealias with a concrete class type.","Move the type annotation into a class or module where a receiver exists."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f3efcbfc9b60d30053b0536d664948d7aa1b8673","analyzedAt":"2026-09-08T13:10:45.570Z","contentChangedAt":"2026-09-08T13:10:45.570Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}