{"record":{"id":"4a6ada63ba06b07c","repo":"JetBrains/intellij-community","slug":"cannot-substitute-0-into-1-as-this","errorCode":null,"errorMessage":"Cannot substitute ''{0}'' into ''{1}'' as ''this''","messagePattern":"Cannot substitute ''(.+?)'' into ''(.+?)'' as ''this''","errorType":"exception","errorClass":"EvaluateException","httpStatus":null,"severity":"error","filePath":"java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/DebuggerTreeNodeExpression.java","lineNumber":93,"sourceCode":"          }\n        }\n        else if (type instanceof PsiArrayType && PsiUtil.isArrayClass(thisClass)) {\n          castNeeded = false;\n        }\n      }\n    }\n\n    if (castNeeded) {\n      howToEvaluateThis = castToRuntimeType(howToEvaluateThis, howToEvaluateThisValue);\n    }\n\n    ChangeContextUtil.encodeContextInfo(result, false);\n    PsiExpression psiExpression;\n    try {\n      psiExpression = (PsiExpression)ChangeContextUtil.decodeContextInfo(result, thisClass, howToEvaluateThis);\n    }\n    catch (IncorrectOperationException e) {\n      throw new EvaluateException(\n        JavaDebuggerBundle.message(\"evaluation.error.invalid.this.expression\", result.getText(), howToEvaluateThis.getText()), null);\n    }\n\n    try {\n      PsiExpression res = JavaPsiFacade.getElementFactory(howToEvaluateThis.getProject())\n        .createExpressionFromText(psiExpression.getText(), howToEvaluateThis.getContext());\n      res.putUserData(ADDITIONAL_IMPORTS_KEY, howToEvaluateThis.getUserData(ADDITIONAL_IMPORTS_KEY));\n      return res;\n    }\n    catch (IncorrectOperationException e) {\n      throw new EvaluateException(e.getMessage(), e);\n    }\n  }\n\n  public static final Key<Set<String>> ADDITIONAL_IMPORTS_KEY = Key.create(\"ADDITIONAL_IMPORTS\");\n\n  public static PsiExpression castToRuntimeType(PsiExpression expression, Value value) throws EvaluateException {\n    if (!(value instanceof ObjectReference)) {","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/JetBrains/intellij-community/blob/be881553f2a76ac8b4ea53950d93f0de78295c19/java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/DebuggerTreeNodeExpression.java#L75-L111","documentation":"Error \"Cannot substitute ''{0}'' into ''{1}'' as ''this''\" thrown in JetBrains/intellij-community.","triggerScenarios":"A debugger tree expression tries to substitute a value of an incompatible type as 'this'.","commonSituations":"Custom renderers or expression nodes built for one type being applied to an object of another type.","solutions":["Use an expression whose type is assignment-compatible with the required 'this' type in that context.","Qualify the reference explicitly instead of relying on 'this' substitution."],"exampleFix":"Write 'otherObject.field' instead of relying on substituting 'this' for an unrelated type.","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"be881553f2a76ac8b4ea53950d93f0de78295c19","analyzedAt":"2026-08-14T14:13:06.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}