Support annotations on class type parameters
#KT-43714
This commit is contained in:
@@ -518,9 +518,10 @@ class DeclarationsChecker(
|
||||
}
|
||||
|
||||
private fun checkTypeParameters(typeParameterListOwner: KtTypeParameterListOwner) {
|
||||
// TODO: Support annotation for type parameters
|
||||
for (jetTypeParameter in typeParameterListOwner.typeParameters) {
|
||||
AnnotationResolverImpl.reportUnsupportedAnnotationForTypeParameter(jetTypeParameter, trace)
|
||||
if (!languageVersionSettings.supportsFeature(LanguageFeature.ClassTypeParameterAnnotations)) {
|
||||
AnnotationResolverImpl.reportUnsupportedAnnotationForTypeParameter(jetTypeParameter, trace)
|
||||
}
|
||||
|
||||
trace.get(TYPE_PARAMETER, jetTypeParameter)?.let { DescriptorResolver.checkConflictingUpperBounds(trace, it, jetTypeParameter) }
|
||||
}
|
||||
|
||||
+24
-2
@@ -252,10 +252,32 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
||||
List<KtTypeParameter> typeParameters = typeParameterList.getParameters();
|
||||
if (typeParameters.isEmpty()) return Collections.emptyList();
|
||||
|
||||
boolean supportClassTypeParameterAnnotations = c.getLanguageVersionSettings().supportsFeature(LanguageFeature.ClassTypeParameterAnnotations);
|
||||
List<TypeParameterDescriptor> parameters = new ArrayList<>(typeParameters.size());
|
||||
|
||||
|
||||
for (int i = 0; i < typeParameters.size(); i++) {
|
||||
parameters.add(new LazyTypeParameterDescriptor(c, this, typeParameters.get(i), i));
|
||||
KtTypeParameter parameter = typeParameters.get(i);
|
||||
Annotations lazyAnnotations;
|
||||
if (supportClassTypeParameterAnnotations) {
|
||||
lazyAnnotations = new LazyAnnotations(
|
||||
new LazyAnnotationsContext(
|
||||
c.getAnnotationResolver(),
|
||||
storageManager,
|
||||
c.getTrace()
|
||||
) {
|
||||
@NotNull
|
||||
@Override
|
||||
public LexicalScope getScope() {
|
||||
return getOuterScope();
|
||||
}
|
||||
},
|
||||
parameter.getAnnotationEntries()
|
||||
);
|
||||
} else {
|
||||
lazyAnnotations = Annotations.Companion.getEMPTY();
|
||||
}
|
||||
|
||||
parameters.add(new LazyTypeParameterDescriptor(c, this, parameter, lazyAnnotations, i));
|
||||
}
|
||||
|
||||
return parameters;
|
||||
|
||||
+3
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.resolve.lazy.descriptors;
|
||||
|
||||
import kotlin.collections.CollectionsKt;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.kotlin.descriptors.impl.AbstractLazyTypeParameterDescriptor;
|
||||
import org.jetbrains.kotlin.diagnostics.Errors;
|
||||
import org.jetbrains.kotlin.lexer.KtTokens;
|
||||
@@ -43,11 +44,13 @@ public class LazyTypeParameterDescriptor extends AbstractLazyTypeParameterDescri
|
||||
@NotNull LazyClassContext c,
|
||||
@NotNull LazyClassDescriptor containingDeclaration,
|
||||
@NotNull KtTypeParameter typeParameter,
|
||||
@NotNull Annotations annotations,
|
||||
int index
|
||||
) {
|
||||
super(
|
||||
c.getStorageManager(),
|
||||
containingDeclaration,
|
||||
annotations,
|
||||
typeParameter.getNameAsSafeName(),
|
||||
typeParameter.getVariance(),
|
||||
typeParameter.hasModifier(KtTokens.REIFIED_KEYWORD),
|
||||
|
||||
Reference in New Issue
Block a user