[java-inspections] IDEA-357275 "Convert class to record" quickfix throws IOE when inherit compiled class

GitOrigin-RevId: 3fef0a37b006d12b2728b98454071d0fd7d3b24f
This commit is contained in:
Mikhail Pyltsin
2024-10-07 18:58:01 +00:00
committed by intellij-monorepo-bot
parent 18cdebfb9e
commit a9a1a18b94
3 changed files with 58 additions and 2 deletions
@@ -1,4 +1,4 @@
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.codeInspection.classCanBeRecord;
import com.intellij.codeInsight.AnnotationTargetUtil;
@@ -294,7 +294,9 @@ public class ConvertToRecordFix extends InspectionGadgetsFix {
recordStyleNaming = true;
break;
}
if (mySuggestAccessorsRenaming && fieldName.equals(PropertyUtilBase.getPropertyNameByGetter(psiMethod))) {
if (mySuggestAccessorsRenaming && fieldName.equals(PropertyUtilBase.getPropertyNameByGetter(psiMethod)) &&
!ContainerUtil.exists(psiMethod.findDeepestSuperMethods(),
superMethod -> superMethod instanceof PsiCompiledElement || superMethod instanceof SyntheticElement)) {
backingField = field;
break;
}
@@ -0,0 +1,23 @@
// "Convert to record class" "true-preview"
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
class Outer {
private record ParameterizedTypeImpl(Type rawType, Type... typeArguments) implements ParameterizedType {
@Override
public Type[] getActualTypeArguments() {
return typeArguments;
}
@Override
public Type getRawType() {
return rawType;
}
@Override
public Type getOwnerType() {
return null;
}
}
}
@@ -0,0 +1,31 @@
// "Convert to record class" "true-preview"
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
class Outer {
private static class Parameterized<caret>TypeImpl implements ParameterizedType {
private final Type rawType;
private final Type[] typeArguments;
public ParameterizedTypeImpl(Type rawType, Type... typeArguments) {
this.rawType = rawType;
this.typeArguments = typeArguments;
}
@Override
public Type[] getActualTypeArguments() {
return typeArguments;
}
@Override
public Type getRawType() {
return rawType;
}
@Override
public Type getOwnerType() {
return null;
}
}
}