Support annotations on class type parameters
#KT-43714
This commit is contained in:
+9
-3
@@ -990,9 +990,15 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("AnnotationForClassTypeParameter.kt")
|
@TestMetadata("AnnotationForClassTypeParameter_15.kt")
|
||||||
public void testAnnotationForClassTypeParameter() throws Exception {
|
public void testAnnotationForClassTypeParameter_15() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/annotations/AnnotationForClassTypeParameter.kt");
|
runTest("compiler/testData/diagnostics/tests/annotations/AnnotationForClassTypeParameter_15.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("AnnotationForClassTypeParameter_16.kt")
|
||||||
|
public void testAnnotationForClassTypeParameter_16() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/annotations/AnnotationForClassTypeParameter_16.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
+9
-3
@@ -990,9 +990,15 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("AnnotationForClassTypeParameter.kt")
|
@TestMetadata("AnnotationForClassTypeParameter_15.kt")
|
||||||
public void testAnnotationForClassTypeParameter() throws Exception {
|
public void testAnnotationForClassTypeParameter_15() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/annotations/AnnotationForClassTypeParameter.kt");
|
runTest("compiler/testData/diagnostics/tests/annotations/AnnotationForClassTypeParameter_15.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("AnnotationForClassTypeParameter_16.kt")
|
||||||
|
public void testAnnotationForClassTypeParameter_16() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/annotations/AnnotationForClassTypeParameter_16.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -518,9 +518,10 @@ class DeclarationsChecker(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun checkTypeParameters(typeParameterListOwner: KtTypeParameterListOwner) {
|
private fun checkTypeParameters(typeParameterListOwner: KtTypeParameterListOwner) {
|
||||||
// TODO: Support annotation for type parameters
|
|
||||||
for (jetTypeParameter in typeParameterListOwner.typeParameters) {
|
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) }
|
trace.get(TYPE_PARAMETER, jetTypeParameter)?.let { DescriptorResolver.checkConflictingUpperBounds(trace, it, jetTypeParameter) }
|
||||||
}
|
}
|
||||||
|
|||||||
+23
-1
@@ -252,10 +252,32 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
|||||||
List<KtTypeParameter> typeParameters = typeParameterList.getParameters();
|
List<KtTypeParameter> typeParameters = typeParameterList.getParameters();
|
||||||
if (typeParameters.isEmpty()) return Collections.emptyList();
|
if (typeParameters.isEmpty()) return Collections.emptyList();
|
||||||
|
|
||||||
|
boolean supportClassTypeParameterAnnotations = c.getLanguageVersionSettings().supportsFeature(LanguageFeature.ClassTypeParameterAnnotations);
|
||||||
List<TypeParameterDescriptor> parameters = new ArrayList<>(typeParameters.size());
|
List<TypeParameterDescriptor> parameters = new ArrayList<>(typeParameters.size());
|
||||||
|
|
||||||
for (int i = 0; i < typeParameters.size(); i++) {
|
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;
|
return parameters;
|
||||||
|
|||||||
+3
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.resolve.lazy.descriptors;
|
|||||||
|
|
||||||
import kotlin.collections.CollectionsKt;
|
import kotlin.collections.CollectionsKt;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
||||||
import org.jetbrains.kotlin.descriptors.impl.AbstractLazyTypeParameterDescriptor;
|
import org.jetbrains.kotlin.descriptors.impl.AbstractLazyTypeParameterDescriptor;
|
||||||
import org.jetbrains.kotlin.diagnostics.Errors;
|
import org.jetbrains.kotlin.diagnostics.Errors;
|
||||||
import org.jetbrains.kotlin.lexer.KtTokens;
|
import org.jetbrains.kotlin.lexer.KtTokens;
|
||||||
@@ -43,11 +44,13 @@ public class LazyTypeParameterDescriptor extends AbstractLazyTypeParameterDescri
|
|||||||
@NotNull LazyClassContext c,
|
@NotNull LazyClassContext c,
|
||||||
@NotNull LazyClassDescriptor containingDeclaration,
|
@NotNull LazyClassDescriptor containingDeclaration,
|
||||||
@NotNull KtTypeParameter typeParameter,
|
@NotNull KtTypeParameter typeParameter,
|
||||||
|
@NotNull Annotations annotations,
|
||||||
int index
|
int index
|
||||||
) {
|
) {
|
||||||
super(
|
super(
|
||||||
c.getStorageManager(),
|
c.getStorageManager(),
|
||||||
containingDeclaration,
|
containingDeclaration,
|
||||||
|
annotations,
|
||||||
typeParameter.getNameAsSafeName(),
|
typeParameter.getNameAsSafeName(),
|
||||||
typeParameter.getVariance(),
|
typeParameter.getVariance(),
|
||||||
typeParameter.hasModifier(KtTokens.REIFIED_KEYWORD),
|
typeParameter.hasModifier(KtTokens.REIFIED_KEYWORD),
|
||||||
|
|||||||
+31
-35
@@ -3,6 +3,7 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
// TARGET_BACKEND: JVM
|
// TARGET_BACKEND: JVM
|
||||||
// EMIT_JVM_TYPE_ANNOTATIONS
|
// EMIT_JVM_TYPE_ANNOTATIONS
|
||||||
|
// !LANGUAGE: +ClassTypeParameterAnnotations
|
||||||
// JVM_TARGET: 1.8
|
// JVM_TARGET: 1.8
|
||||||
// WITH_REFLECT
|
// WITH_REFLECT
|
||||||
// FULL_JDK
|
// FULL_JDK
|
||||||
@@ -29,41 +30,36 @@ class SimpleClass
|
|||||||
interface Generic<G>
|
interface Generic<G>
|
||||||
class GenericClass<G>
|
class GenericClass<G>
|
||||||
|
|
||||||
@Suppress("UNSUPPORTED")
|
|
||||||
class SimpleParameter<@TypeParameterAnn @TypeParameterAnnBinary T> {}
|
class SimpleParameter<@TypeParameterAnn @TypeParameterAnnBinary T> {}
|
||||||
|
|
||||||
@Suppress("UNSUPPORTED")
|
|
||||||
class InterfaceBound<@TypeParameterAnn T : @TypeAnn("Simple") Simple> {}
|
class InterfaceBound<@TypeParameterAnn T : @TypeAnn("Simple") Simple> {}
|
||||||
|
|
||||||
@Suppress("UNSUPPORTED")
|
|
||||||
class ClassBound<@TypeParameterAnn T : @TypeAnn("Simple") SimpleClass>
|
class ClassBound<@TypeParameterAnn T : @TypeAnn("Simple") SimpleClass>
|
||||||
|
|
||||||
class InterfaceBoundGeneric<T : @TypeAnn("Generic") Generic<@TypeAnn("Simple") Simple>> {}
|
class InterfaceBoundGeneric<T : @TypeAnn("Generic") Generic<@TypeAnn("Simple") Simple>> {}
|
||||||
|
|
||||||
class ClassBoundGeneric<T : @TypeAnn("GenericClass") GenericClass<@TypeAnn("SimpleClass") SimpleClass>>
|
class ClassBoundGeneric<T : @TypeAnn("GenericClass") GenericClass<@TypeAnn("SimpleClass") SimpleClass>>
|
||||||
|
|
||||||
@Suppress("UNSUPPORTED")
|
|
||||||
class TypeParameterAsBound<Y, @TypeParameterAnn T : @TypeAnn("Y as Bound") Y>
|
class TypeParameterAsBound<Y, @TypeParameterAnn T : @TypeAnn("Y as Bound") Y>
|
||||||
|
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
|
|
||||||
//foo
|
//foo
|
||||||
// checkTypeParameterAnnotation(
|
checkTypeParameterAnnotation(
|
||||||
// SimpleParameter::class.java.typeParameters.single(),
|
SimpleParameter::class.java.typeParameters.single(),
|
||||||
// "T",
|
"T",
|
||||||
// "@foo.TypeParameterAnn()",
|
"@foo.TypeParameterAnn()",
|
||||||
// "foo"
|
"foo"
|
||||||
// )
|
)
|
||||||
|
|
||||||
//interfaceBound
|
//interfaceBound
|
||||||
val interfaceBound = InterfaceBound::class.java
|
val interfaceBound = InterfaceBound::class.java
|
||||||
// checkTypeParameterAnnotation(
|
checkTypeParameterAnnotation(
|
||||||
// InterfaceBound.typeParameters.single(),
|
interfaceBound.typeParameters.single(),
|
||||||
// "T",
|
"T",
|
||||||
// "@foo.TypeParameterAnn()",
|
"@foo.TypeParameterAnn()",
|
||||||
// "interfaceBound type parameter"
|
"interfaceBound type parameter"
|
||||||
// )
|
)
|
||||||
|
|
||||||
checkTypeAnnotation(
|
checkTypeAnnotation(
|
||||||
interfaceBound.typeParameters.single().annotatedBounds.single(),
|
interfaceBound.typeParameters.single().annotatedBounds.single(),
|
||||||
@@ -74,12 +70,12 @@ fun box(): String {
|
|||||||
|
|
||||||
//classBound
|
//classBound
|
||||||
val classBound = ClassBound::class.java
|
val classBound = ClassBound::class.java
|
||||||
// checkTypeParameterAnnotation(
|
checkTypeParameterAnnotation(
|
||||||
// classBound.typeParameters.single(),
|
classBound.typeParameters.single(),
|
||||||
// "T",
|
"T",
|
||||||
// "@foo.TypeParameterAnn()",
|
"@foo.TypeParameterAnn()",
|
||||||
// "classBound type parameter"
|
"classBound type parameter"
|
||||||
// )
|
)
|
||||||
|
|
||||||
checkTypeAnnotation(
|
checkTypeAnnotation(
|
||||||
classBound.typeParameters.single().annotatedBounds.single(),
|
classBound.typeParameters.single().annotatedBounds.single(),
|
||||||
@@ -91,12 +87,12 @@ fun box(): String {
|
|||||||
|
|
||||||
//interfaceBoundGeneric
|
//interfaceBoundGeneric
|
||||||
val interfaceBoundGeneric = InterfaceBoundGeneric::class.java
|
val interfaceBoundGeneric = InterfaceBoundGeneric::class.java
|
||||||
// checkTypeAnnotation(
|
checkTypeAnnotation(
|
||||||
// interfaceBoundGeneric.typeParameters.single().annotatedBounds.single(),
|
interfaceBoundGeneric.typeParameters.single().annotatedBounds.single(),
|
||||||
// "foo.Generic<foo.Simple>",
|
"foo.Generic<foo.Simple>",
|
||||||
// "@foo.TypeAnn(name=Generic)",
|
"@foo.TypeAnn(name=Generic)",
|
||||||
// "interfaceBoundGeneric bound"
|
"interfaceBoundGeneric bound"
|
||||||
// )
|
)
|
||||||
|
|
||||||
checkTypeAnnotation(
|
checkTypeAnnotation(
|
||||||
(interfaceBoundGeneric.typeParameters.single().annotatedBounds.single() as AnnotatedParameterizedType).getAnnotatedActualTypeArguments().single(),
|
(interfaceBoundGeneric.typeParameters.single().annotatedBounds.single() as AnnotatedParameterizedType).getAnnotatedActualTypeArguments().single(),
|
||||||
@@ -124,12 +120,12 @@ fun box(): String {
|
|||||||
|
|
||||||
//typeParameterTypeParameterBound
|
//typeParameterTypeParameterBound
|
||||||
val typeParameterTypeParameterBound = TypeParameterAsBound::class.java
|
val typeParameterTypeParameterBound = TypeParameterAsBound::class.java
|
||||||
// checkTypeParameterAnnotation(
|
checkTypeParameterAnnotation(
|
||||||
// typeParameterTypeParameterBound.typeParameters[1]!!,
|
typeParameterTypeParameterBound.typeParameters[1]!!,
|
||||||
// "T",
|
"T",
|
||||||
// "@foo.TypeParameterAnn()",
|
"@foo.TypeParameterAnn()",
|
||||||
// "typeParameterTypeParameterBound type parameter"
|
"typeParameterTypeParameterBound type parameter"
|
||||||
// )
|
)
|
||||||
// Works on JDK 15
|
// Works on JDK 15
|
||||||
// checkTypeAnnotation(
|
// checkTypeAnnotation(
|
||||||
// typeParameterTypeParameterBound.typeParameters[1]!!.annotatedBounds.single(),
|
// typeParameterTypeParameterBound.typeParameters[1]!!.annotatedBounds.single(),
|
||||||
|
|||||||
+1
@@ -1,3 +1,4 @@
|
|||||||
|
// !LANGUAGE: -ClassTypeParameterAnnotations
|
||||||
annotation class A1
|
annotation class A1
|
||||||
annotation class A2(val some: Int = 12)
|
annotation class A2(val some: Int = 12)
|
||||||
|
|
||||||
+1
@@ -1,3 +1,4 @@
|
|||||||
|
// !LANGUAGE: -ClassTypeParameterAnnotations
|
||||||
annotation class A1
|
annotation class A1
|
||||||
annotation class A2(val some: Int = 12)
|
annotation class A2(val some: Int = 12)
|
||||||
|
|
||||||
+24
@@ -0,0 +1,24 @@
|
|||||||
|
// !LANGUAGE: +ClassTypeParameterAnnotations
|
||||||
|
annotation class A1
|
||||||
|
annotation class A2(val some: Int = 12)
|
||||||
|
|
||||||
|
@Target(AnnotationTarget.TYPE)
|
||||||
|
annotation class TA1
|
||||||
|
@Target(AnnotationTarget.TYPE_PARAMETER)
|
||||||
|
annotation class TA2(val some: Int = 12)
|
||||||
|
|
||||||
|
class TopLevelClass<@A1 @A2(3) @A2 @A1(12) @A2("Test") T> {
|
||||||
|
class InnerClass<@A1 @A2(3) @A2 @A1(12) @A2("Test") T> {
|
||||||
|
fun test() {
|
||||||
|
class InFun<@A1 @A2(3) @A2 @A1(12) @A2("Test") T>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class TTopLevelClass<@TA1 @TA2(3) @TA2 @TA1(12) @TA2("Test") T> {
|
||||||
|
class TInnerClass<@TA1 @TA2(3) @TA2 @TA1(12) @TA2("Test") T> {
|
||||||
|
fun test() {
|
||||||
|
class TInFun<@TA1 @TA2(3) @TA2 @TA1(12) @TA2("Test") T>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+25
@@ -0,0 +1,25 @@
|
|||||||
|
// !LANGUAGE: +ClassTypeParameterAnnotations
|
||||||
|
annotation class A1
|
||||||
|
annotation class A2(val some: Int = 12)
|
||||||
|
|
||||||
|
@Target(AnnotationTarget.TYPE)
|
||||||
|
annotation class TA1
|
||||||
|
|
||||||
|
@Target(AnnotationTarget.TYPE_PARAMETER)
|
||||||
|
annotation class TA2(val some: Int = 12)
|
||||||
|
|
||||||
|
class TopLevelClass<<!WRONG_ANNOTATION_TARGET!>@A1<!> <!WRONG_ANNOTATION_TARGET!>@A2(3)<!> <!REPEATED_ANNOTATION, WRONG_ANNOTATION_TARGET!>@A2<!> <!REPEATED_ANNOTATION, WRONG_ANNOTATION_TARGET!>@A1(<!TOO_MANY_ARGUMENTS!>12<!>)<!> <!REPEATED_ANNOTATION, WRONG_ANNOTATION_TARGET!>@A2(<!TYPE_MISMATCH!>"Test"<!>)<!> T> {
|
||||||
|
class InnerClass<<!WRONG_ANNOTATION_TARGET!>@A1<!> <!WRONG_ANNOTATION_TARGET!>@A2(3)<!> <!REPEATED_ANNOTATION, WRONG_ANNOTATION_TARGET!>@A2<!> <!REPEATED_ANNOTATION, WRONG_ANNOTATION_TARGET!>@A1(<!TOO_MANY_ARGUMENTS!>12<!>)<!> <!REPEATED_ANNOTATION, WRONG_ANNOTATION_TARGET!>@A2(<!TYPE_MISMATCH!>"Test"<!>)<!> T> {
|
||||||
|
fun test() {
|
||||||
|
class InFun<<!WRONG_ANNOTATION_TARGET!>@A1<!> <!WRONG_ANNOTATION_TARGET!>@A2(3)<!> <!REPEATED_ANNOTATION, WRONG_ANNOTATION_TARGET!>@A2<!> <!REPEATED_ANNOTATION, WRONG_ANNOTATION_TARGET!>@A1(<!TOO_MANY_ARGUMENTS!>12<!>)<!> <!REPEATED_ANNOTATION, WRONG_ANNOTATION_TARGET!>@A2(<!TYPE_MISMATCH!>"Test"<!>)<!> T>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class TTopLevelClass<<!WRONG_ANNOTATION_TARGET!>@TA1<!> @TA2(3) <!REPEATED_ANNOTATION!>@TA2<!> <!REPEATED_ANNOTATION, WRONG_ANNOTATION_TARGET!>@TA1(<!TOO_MANY_ARGUMENTS!>12<!>)<!> <!REPEATED_ANNOTATION!>@TA2(<!TYPE_MISMATCH!>"Test"<!>)<!> T> {
|
||||||
|
class TInnerClass<<!WRONG_ANNOTATION_TARGET!>@TA1<!> @TA2(3) <!REPEATED_ANNOTATION!>@TA2<!> <!REPEATED_ANNOTATION, WRONG_ANNOTATION_TARGET!>@TA1(<!TOO_MANY_ARGUMENTS!>12<!>)<!> <!REPEATED_ANNOTATION!>@TA2(<!TYPE_MISMATCH!>"Test"<!>)<!> T> {
|
||||||
|
fun test() {
|
||||||
|
class TInFun<<!WRONG_ANNOTATION_TARGET!>@TA1<!> @TA2(3) <!REPEATED_ANNOTATION!>@TA2<!> <!REPEATED_ANNOTATION, WRONG_ANNOTATION_TARGET!>@TA1(<!TOO_MANY_ARGUMENTS!>12<!>)<!> <!REPEATED_ANNOTATION!>@TA2(<!TYPE_MISMATCH!>"Test"<!>)<!> T>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+62
@@ -0,0 +1,62 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public final annotation class A1 : kotlin.Annotation {
|
||||||
|
public constructor A1()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
public final annotation class A2 : kotlin.Annotation {
|
||||||
|
public constructor A2(/*0*/ some: kotlin.Int = ...)
|
||||||
|
public final val some: kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE}) public final annotation class TA1 : kotlin.Annotation {
|
||||||
|
public constructor TA1()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE_PARAMETER}) public final annotation class TA2 : kotlin.Annotation {
|
||||||
|
public constructor TA2(/*0*/ some: kotlin.Int = ...)
|
||||||
|
public final val some: kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class TTopLevelClass</*0*/ @TA1 @TA2(some = 3) @TA2 @TA1 @TA2(some = "Test") T> {
|
||||||
|
public constructor TTopLevelClass</*0*/ @TA1 @TA2(some = 3) @TA2 @TA1 @TA2(some = "Test") T>()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|
||||||
|
public final class TInnerClass</*0*/ @TA1 @TA2(some = 3) @TA2 @TA1 @TA2(some = "Test") T> {
|
||||||
|
public constructor TInnerClass</*0*/ @TA1 @TA2(some = 3) @TA2 @TA1 @TA2(some = "Test") T>()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public final fun test(): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class TopLevelClass</*0*/ @A1 @A2(some = 3) @A2 @A1 @A2(some = "Test") T> {
|
||||||
|
public constructor TopLevelClass</*0*/ @A1 @A2(some = 3) @A2 @A1 @A2(some = "Test") T>()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|
||||||
|
public final class InnerClass</*0*/ @A1 @A2(some = 3) @A2 @A1 @A2(some = "Test") T> {
|
||||||
|
public constructor InnerClass</*0*/ @A1 @A2(some = 3) @A2 @A1 @A2(some = "Test") T>()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public final fun test(): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Generated
+9
-3
@@ -990,9 +990,15 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("AnnotationForClassTypeParameter.kt")
|
@TestMetadata("AnnotationForClassTypeParameter_15.kt")
|
||||||
public void testAnnotationForClassTypeParameter() throws Exception {
|
public void testAnnotationForClassTypeParameter_15() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/annotations/AnnotationForClassTypeParameter.kt");
|
runTest("compiler/testData/diagnostics/tests/annotations/AnnotationForClassTypeParameter_15.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("AnnotationForClassTypeParameter_16.kt")
|
||||||
|
public void testAnnotationForClassTypeParameter_16() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/annotations/AnnotationForClassTypeParameter_16.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -208,6 +208,7 @@ enum class LanguageFeature(
|
|||||||
SuspendFunctionAsSupertype(KOTLIN_1_6),
|
SuspendFunctionAsSupertype(KOTLIN_1_6),
|
||||||
UnrestrictedBuilderInference(KOTLIN_1_6),
|
UnrestrictedBuilderInference(KOTLIN_1_6),
|
||||||
ProperTypeInferenceConstraintsProcessing(KOTLIN_1_6, kind = BUG_FIX),
|
ProperTypeInferenceConstraintsProcessing(KOTLIN_1_6, kind = BUG_FIX),
|
||||||
|
ClassTypeParameterAnnotations(KOTLIN_1_6),
|
||||||
|
|
||||||
// Temporarily disabled, see KT-27084/KT-22379
|
// Temporarily disabled, see KT-27084/KT-22379
|
||||||
SoundSmartcastFromLoopConditionForLoopAssignedVariables(sinceVersion = null, kind = BUG_FIX),
|
SoundSmartcastFromLoopConditionForLoopAssignedVariables(sinceVersion = null, kind = BUG_FIX),
|
||||||
|
|||||||
+4
-3
@@ -36,13 +36,14 @@ class LazyJavaTypeParameterDescriptor(
|
|||||||
) : AbstractLazyTypeParameterDescriptor(
|
) : AbstractLazyTypeParameterDescriptor(
|
||||||
c.storageManager,
|
c.storageManager,
|
||||||
containingDeclaration,
|
containingDeclaration,
|
||||||
|
LazyJavaAnnotations(c, javaTypeParameter),
|
||||||
javaTypeParameter.name,
|
javaTypeParameter.name,
|
||||||
Variance.INVARIANT,
|
Variance.INVARIANT,
|
||||||
/* isReified = */ false,
|
/* isReified = */
|
||||||
|
false,
|
||||||
index,
|
index,
|
||||||
SourceElement.NO_SOURCE, c.components.supertypeLoopChecker
|
SourceElement.NO_SOURCE, c.components.supertypeLoopChecker,
|
||||||
) {
|
) {
|
||||||
override val annotations = LazyJavaAnnotations(c, javaTypeParameter)
|
|
||||||
|
|
||||||
override fun resolveUpperBounds(): List<KotlinType> {
|
override fun resolveUpperBounds(): List<KotlinType> {
|
||||||
return computeNotEnhancedBounds()
|
return computeNotEnhancedBounds()
|
||||||
|
|||||||
+2
-1
@@ -29,6 +29,7 @@ public abstract class AbstractLazyTypeParameterDescriptor extends AbstractTypePa
|
|||||||
public AbstractLazyTypeParameterDescriptor(
|
public AbstractLazyTypeParameterDescriptor(
|
||||||
@NotNull StorageManager storageManager,
|
@NotNull StorageManager storageManager,
|
||||||
@NotNull DeclarationDescriptor containingDeclaration,
|
@NotNull DeclarationDescriptor containingDeclaration,
|
||||||
|
@NotNull Annotations annotations,
|
||||||
@NotNull Name name,
|
@NotNull Name name,
|
||||||
@NotNull Variance variance,
|
@NotNull Variance variance,
|
||||||
boolean isReified,
|
boolean isReified,
|
||||||
@@ -36,7 +37,7 @@ public abstract class AbstractLazyTypeParameterDescriptor extends AbstractTypePa
|
|||||||
@NotNull SourceElement source,
|
@NotNull SourceElement source,
|
||||||
@NotNull SupertypeLoopChecker supertypeLoopChecker
|
@NotNull SupertypeLoopChecker supertypeLoopChecker
|
||||||
) {
|
) {
|
||||||
super(storageManager, containingDeclaration, Annotations.Companion.getEMPTY() /* TODO */, name, variance, isReified, index, source,
|
super(storageManager, containingDeclaration, annotations, name, variance, isReified, index, source,
|
||||||
supertypeLoopChecker);
|
supertypeLoopChecker);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+6
-2
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.serialization.deserialization.descriptors
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.SourceElement
|
import org.jetbrains.kotlin.descriptors.SourceElement
|
||||||
import org.jetbrains.kotlin.descriptors.SupertypeLoopChecker
|
import org.jetbrains.kotlin.descriptors.SupertypeLoopChecker
|
||||||
|
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||||
import org.jetbrains.kotlin.descriptors.impl.AbstractLazyTypeParameterDescriptor
|
import org.jetbrains.kotlin.descriptors.impl.AbstractLazyTypeParameterDescriptor
|
||||||
import org.jetbrains.kotlin.metadata.ProtoBuf
|
import org.jetbrains.kotlin.metadata.ProtoBuf
|
||||||
import org.jetbrains.kotlin.metadata.deserialization.upperBounds
|
import org.jetbrains.kotlin.metadata.deserialization.upperBounds
|
||||||
@@ -32,8 +33,11 @@ class DeserializedTypeParameterDescriptor(
|
|||||||
val proto: ProtoBuf.TypeParameter,
|
val proto: ProtoBuf.TypeParameter,
|
||||||
index: Int
|
index: Int
|
||||||
) : AbstractLazyTypeParameterDescriptor(
|
) : AbstractLazyTypeParameterDescriptor(
|
||||||
c.storageManager, c.containingDeclaration, c.nameResolver.getName(proto.name),
|
c.storageManager, c.containingDeclaration,
|
||||||
ProtoEnumFlags.variance(proto.variance), proto.reified, index, SourceElement.NO_SOURCE, SupertypeLoopChecker.EMPTY
|
/*TODO: support deserialized type annotations: now they are unused, even not accessible via reflection (KT-46932)*/
|
||||||
|
Annotations.EMPTY,
|
||||||
|
c.nameResolver.getName(proto.name),
|
||||||
|
ProtoEnumFlags.variance(proto.variance), proto.reified, index, SourceElement.NO_SOURCE, SupertypeLoopChecker.EMPTY,
|
||||||
) {
|
) {
|
||||||
override val annotations = DeserializedAnnotations(c.storageManager) {
|
override val annotations = DeserializedAnnotations(c.storageManager) {
|
||||||
c.components.annotationAndConstantLoader.loadTypeParameterAnnotations(proto, c.nameResolver).toList()
|
c.components.annotationAndConstantLoader.loadTypeParameterAnnotations(proto, c.nameResolver).toList()
|
||||||
|
|||||||
+8
-3
@@ -838,9 +838,14 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
|
|||||||
runTest("compiler/testData/diagnostics/tests/annotations/AnnotationAsDefaultParameter.kt");
|
runTest("compiler/testData/diagnostics/tests/annotations/AnnotationAsDefaultParameter.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("AnnotationForClassTypeParameter.kt")
|
@TestMetadata("AnnotationForClassTypeParameter_15.kt")
|
||||||
public void testAnnotationForClassTypeParameter() throws Exception {
|
public void testAnnotationForClassTypeParameter_15() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/annotations/AnnotationForClassTypeParameter.kt");
|
runTest("compiler/testData/diagnostics/tests/annotations/AnnotationForClassTypeParameter_15.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("AnnotationForClassTypeParameter_16.kt")
|
||||||
|
public void testAnnotationForClassTypeParameter_16() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/annotations/AnnotationForClassTypeParameter_16.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("AnnotationForFunctionTypeParameter.kt")
|
@TestMetadata("AnnotationForFunctionTypeParameter.kt")
|
||||||
|
|||||||
Reference in New Issue
Block a user