From f8220bfdcccfd7caa74728ebbca48ea092bc75ce Mon Sep 17 00:00:00 2001 From: Noopur Gupta Date: Wed, 6 Nov 2024 11:22:54 +0530 Subject: [PATCH] ClassCastException when ctrl+hover over a 'case' literal Fixes https://github.com/eclipse-jdt/eclipse.jdt.ui/issues/1764 --- .../eclipse/jdt/internal/corext/dom/ASTFlattener.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/ASTFlattener.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/ASTFlattener.java index 7edb4f9b722..85e721f113a 100644 --- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/ASTFlattener.java +++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/dom/ASTFlattener.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2023 IBM Corporation and others. + * Copyright (c) 2000, 2024 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -2017,8 +2017,13 @@ public boolean visit(TypeParameter node) { @Override public boolean visit(TypePattern node) { - if (ASTHelper.isPatternSupported(node.getAST())) { - node.getPatternVariable().accept(this); + AST ast= node.getAST(); + if (ASTHelper.isPatternSupported(ast)) { + if (ast.apiLevel() >= ASTHelper.JLS22) { + node.getPatternVariable2().accept(this); + } else { + node.getPatternVariable().accept(this); + } } return false; }