ClassDescriptor is now a super-interface for ClassConstructorDescriptor and TypeAliasConstructorDescriptor.
This commit is contained in:
committed by
Dmitry Petrov
parent
7d214c6e58
commit
796d11c860
+12
-12
@@ -21,14 +21,14 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.SourceElement;
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.kotlin.load.java.descriptors.JavaConstructorDescriptor;
|
||||
import org.jetbrains.kotlin.load.java.descriptors.JavaClassConstructorDescriptor;
|
||||
import org.jetbrains.kotlin.load.java.descriptors.SamAdapterDescriptor;
|
||||
|
||||
/* package */ class SamAdapterConstructorDescriptor extends JavaConstructorDescriptor
|
||||
implements SamAdapterDescriptor<JavaConstructorDescriptor> {
|
||||
private final JavaConstructorDescriptor declaration;
|
||||
/* package */ class SamAdapterClassConstructorDescriptor extends JavaClassConstructorDescriptor
|
||||
implements SamAdapterDescriptor<JavaClassConstructorDescriptor> {
|
||||
private final JavaClassConstructorDescriptor declaration;
|
||||
|
||||
public SamAdapterConstructorDescriptor(@NotNull JavaConstructorDescriptor declaration) {
|
||||
public SamAdapterClassConstructorDescriptor(@NotNull JavaClassConstructorDescriptor declaration) {
|
||||
super(declaration.getContainingDeclaration(), null, declaration.getAnnotations(),
|
||||
declaration.isPrimary(), Kind.SYNTHESIZED, declaration.getSource());
|
||||
this.declaration = declaration;
|
||||
@@ -36,14 +36,14 @@ import org.jetbrains.kotlin.load.java.descriptors.SamAdapterDescriptor;
|
||||
setHasSynthesizedParameterNames(declaration.hasSynthesizedParameterNames());
|
||||
}
|
||||
|
||||
private SamAdapterConstructorDescriptor(
|
||||
private SamAdapterClassConstructorDescriptor(
|
||||
@NotNull ClassDescriptor containingDeclaration,
|
||||
@Nullable JavaConstructorDescriptor original,
|
||||
@Nullable JavaClassConstructorDescriptor original,
|
||||
@NotNull Annotations annotations,
|
||||
boolean isPrimary,
|
||||
@NotNull Kind kind,
|
||||
@NotNull SourceElement source,
|
||||
@NotNull JavaConstructorDescriptor declaration
|
||||
@NotNull JavaClassConstructorDescriptor declaration
|
||||
) {
|
||||
super(containingDeclaration, original, annotations, isPrimary, kind, source);
|
||||
this.declaration = declaration;
|
||||
@@ -51,19 +51,19 @@ import org.jetbrains.kotlin.load.java.descriptors.SamAdapterDescriptor;
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected JavaConstructorDescriptor createDescriptor(
|
||||
protected JavaClassConstructorDescriptor createDescriptor(
|
||||
@NotNull ClassDescriptor newOwner,
|
||||
@Nullable JavaConstructorDescriptor original,
|
||||
@Nullable JavaClassConstructorDescriptor original,
|
||||
@NotNull Kind kind,
|
||||
@NotNull SourceElement sourceElement,
|
||||
@NotNull Annotations annotations
|
||||
) {
|
||||
return new SamAdapterConstructorDescriptor(newOwner, original, annotations, isPrimary, kind, sourceElement, declaration);
|
||||
return new SamAdapterClassConstructorDescriptor(newOwner, original, annotations, isPrimary, kind, sourceElement, declaration);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JavaConstructorDescriptor getBaseDescriptorForSynthetic() {
|
||||
public JavaClassConstructorDescriptor getBaseDescriptorForSynthetic() {
|
||||
return declaration;
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -21,7 +21,7 @@ import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.load.java.components.SamConversionResolver
|
||||
import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor
|
||||
import org.jetbrains.kotlin.load.java.descriptors.JavaConstructorDescriptor
|
||||
import org.jetbrains.kotlin.load.java.descriptors.JavaClassConstructorDescriptor
|
||||
import org.jetbrains.kotlin.load.java.descriptors.JavaMethodDescriptor
|
||||
import org.jetbrains.kotlin.load.java.descriptors.SamConstructorDescriptor
|
||||
import org.jetbrains.kotlin.load.java.lazy.descriptors.LazyJavaClassDescriptor
|
||||
@@ -38,7 +38,7 @@ object SamConversionResolverImpl : SamConversionResolver {
|
||||
override fun <D : FunctionDescriptor> resolveSamAdapter(original: D): D? {
|
||||
return when {
|
||||
!SingleAbstractMethodUtils.isSamAdapterNecessary(original) -> null
|
||||
original is JavaConstructorDescriptor -> SingleAbstractMethodUtils.createSamAdapterConstructor(original) as D
|
||||
original is JavaClassConstructorDescriptor -> SingleAbstractMethodUtils.createSamAdapterConstructor(original) as D
|
||||
original is JavaMethodDescriptor -> SingleAbstractMethodUtils.createSamAdapterFunction(original) as D
|
||||
else -> null
|
||||
}
|
||||
|
||||
+3
-3
@@ -205,8 +205,8 @@ public class SingleAbstractMethodUtils {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static SamAdapterDescriptor<JavaConstructorDescriptor> createSamAdapterConstructor(@NotNull final JavaConstructorDescriptor original) {
|
||||
final SamAdapterConstructorDescriptor result = new SamAdapterConstructorDescriptor(original);
|
||||
public static SamAdapterDescriptor<JavaClassConstructorDescriptor> createSamAdapterConstructor(@NotNull final JavaClassConstructorDescriptor original) {
|
||||
final SamAdapterClassConstructorDescriptor result = new SamAdapterClassConstructorDescriptor(original);
|
||||
return initSamAdapter(original, result, new FunctionInitializer() {
|
||||
@Override
|
||||
public void initialize(
|
||||
@@ -277,7 +277,7 @@ public class SingleAbstractMethodUtils {
|
||||
@NotNull List<TypeParameterDescriptor> originalParameters,
|
||||
@Nullable DeclarationDescriptor newOwner
|
||||
) {
|
||||
if (newOwner instanceof SamAdapterConstructorDescriptor) {
|
||||
if (newOwner instanceof SamAdapterClassConstructorDescriptor) {
|
||||
return new TypeParameters(originalParameters, TypeSubstitutor.EMPTY);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticFactory0
|
||||
import org.jetbrains.kotlin.load.java.JvmAnnotationNames
|
||||
import org.jetbrains.kotlin.load.java.components.JavaAnnotationMapper
|
||||
import org.jetbrains.kotlin.load.java.descriptors.JavaConstructorDescriptor
|
||||
import org.jetbrains.kotlin.load.java.descriptors.JavaClassConstructorDescriptor
|
||||
import org.jetbrains.kotlin.psi.KtAnnotationEntry
|
||||
import org.jetbrains.kotlin.psi.KtExpression
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
@@ -37,7 +37,7 @@ import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm
|
||||
class JavaAnnotationCallChecker : CallChecker {
|
||||
override fun check(resolvedCall: ResolvedCall<*>, reportOn: PsiElement, context: CallCheckerContext) {
|
||||
val resultingDescriptor = resolvedCall.resultingDescriptor.original
|
||||
if (resultingDescriptor !is JavaConstructorDescriptor ||
|
||||
if (resultingDescriptor !is JavaClassConstructorDescriptor ||
|
||||
resultingDescriptor.containingDeclaration.kind != ClassKind.ANNOTATION_CLASS) return
|
||||
|
||||
reportErrorsOnPositionedArguments(resolvedCall, context)
|
||||
|
||||
Reference in New Issue
Block a user