Create <out Any?> projections for raw Java types, not <*>
KT-3760 Internal compiler error with Java interoperability and ElasticSearch 0.90.2 (IllegalStateException, Type parameter descriptor in not initialized: T declared in ...) #KT-3760 Fixed EA-44150 Type parameter descriptor in not initialized. Fixed
This commit is contained in:
+12
-8
@@ -166,14 +166,18 @@ public class JavaTypeTransformer {
|
||||
List<TypeParameterDescriptor> parameters = classData.getTypeConstructor().getParameters();
|
||||
if (isRaw(classType, !parameters.isEmpty())) {
|
||||
for (TypeParameterDescriptor parameter : parameters) {
|
||||
TypeProjection starProjection = SubstitutionUtils.makeStarProjection(parameter);
|
||||
if (howThisTypeIsUsed == SUPERTYPE) {
|
||||
// projections are not allowed in immediate arguments of supertypes
|
||||
arguments.add(new TypeProjection(starProjection.getType()));
|
||||
}
|
||||
else {
|
||||
arguments.add(starProjection);
|
||||
}
|
||||
// not making a star projection because of this case:
|
||||
// Java:
|
||||
// class C<T extends C> {}
|
||||
// The upper bound is raw here, and we can't compute the projection: it would be infinite:
|
||||
// C<*> = C<out C<out C<...>>>
|
||||
// this way we loose some type information, even when the case is not so bad, but it doesn't seem to matter
|
||||
|
||||
// projections are not allowed in immediate arguments of supertypes
|
||||
Variance projectionKind = parameter.getVariance() == OUT_VARIANCE || howThisTypeIsUsed == SUPERTYPE
|
||||
? INVARIANT
|
||||
: OUT_VARIANCE;
|
||||
arguments.add(new TypeProjection(projectionKind, KotlinBuiltIns.getInstance().getNullableAnyType()));
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user