Skip to content

Commit

Permalink
Fix possible ClassCastException trying to complete typeparam
Browse files Browse the repository at this point in the history
  • Loading branch information
mickaelistria committed Jan 29, 2025
1 parent c52dfb2 commit 9e93a86
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,9 @@ public char[][] getExpectedTypesSignatures() {
return null;
}
var res = this.expectedTypes.getExpectedTypes().stream() //
.map(ITypeBinding::getQualifiedName) //
.map(name -> Signature.createTypeSignature(name, true))
.map(binding -> binding.isTypeVariable() ?
'T' + binding.getQualifiedName() + ';' :
Signature.createTypeSignature(binding.getQualifiedName(), true))
.map(String::toCharArray) //
.toArray(char[][]::new);
return res.length == 0 ? null : res;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1968,11 +1968,10 @@ private void publishFromScope(Bindings scope) {
private void completeConstructor(ITypeBinding typeBinding, ASTNode referencedFrom, IJavaProject javaProject) {
// compute type hierarchy
boolean isArray = typeBinding.isArray();
IType typeHandle = ((IType)typeBinding.getJavaElement());
AbstractTypeDeclaration enclosingType = (AbstractTypeDeclaration) DOMCompletionUtil.findParent(referencedFrom, new int[] { ASTNode.TYPE_DECLARATION, ASTNode.ENUM_DECLARATION, ASTNode.RECORD_DECLARATION, ASTNode.ANNOTATION_TYPE_DECLARATION });
ITypeBinding enclosingTypeBinding = enclosingType.resolveBinding();
IType enclosingTypeElement = (IType) enclosingTypeBinding.getJavaElement();
if (typeHandle != null) {
if (typeBinding.getJavaElement() instanceof IType typeHandle) {
try {
ITypeHierarchy newTypeHierarchy = typeHandle.newTypeHierarchy(javaProject, null);
ASTParser parser = ASTParser.newParser(AST.getJLSLatest());
Expand Down

0 comments on commit 9e93a86

Please sign in to comment.