JetBrains/intellij-community · error · EvaluateException
Cannot substitute ''{0}'' into ''{1}'' as ''this''
Error message
Cannot substitute ''{0}'' into ''{1}'' as ''this'' What it means
Error "Cannot substitute ''{0}'' into ''{1}'' as ''this''" thrown in JetBrains/intellij-community.
Source
Thrown at java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/DebuggerTreeNodeExpression.java:93
}
}
else if (type instanceof PsiArrayType && PsiUtil.isArrayClass(thisClass)) {
castNeeded = false;
}
}
}
if (castNeeded) {
howToEvaluateThis = castToRuntimeType(howToEvaluateThis, howToEvaluateThisValue);
}
ChangeContextUtil.encodeContextInfo(result, false);
PsiExpression psiExpression;
try {
psiExpression = (PsiExpression)ChangeContextUtil.decodeContextInfo(result, thisClass, howToEvaluateThis);
}
catch (IncorrectOperationException e) {
throw new EvaluateException(
JavaDebuggerBundle.message("evaluation.error.invalid.this.expression", result.getText(), howToEvaluateThis.getText()), null);
}
try {
PsiExpression res = JavaPsiFacade.getElementFactory(howToEvaluateThis.getProject())
.createExpressionFromText(psiExpression.getText(), howToEvaluateThis.getContext());
res.putUserData(ADDITIONAL_IMPORTS_KEY, howToEvaluateThis.getUserData(ADDITIONAL_IMPORTS_KEY));
return res;
}
catch (IncorrectOperationException e) {
throw new EvaluateException(e.getMessage(), e);
}
}
public static final Key<Set<String>> ADDITIONAL_IMPORTS_KEY = Key.create("ADDITIONAL_IMPORTS");
public static PsiExpression castToRuntimeType(PsiExpression expression, Value value) throws EvaluateException {
if (!(value instanceof ObjectReference)) {View on GitHub (pinned to be881553f2)
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.
Example fix
Write 'otherObject.field' instead of relying on substituting 'this' for an unrelated type.
When it happens
Trigger: A debugger tree expression tries to substitute a value of an incompatible type as 'this'.
Common situations: Custom renderers or expression nodes built for one type being applied to an object of another type.
AI-assisted analysis of JetBrains/intellij-community@be881553f2 (2026-08-14).
Data as JSON: /api/errors/4a6ada63ba06b07c.
Report an issue: GitHub.