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:
Andrey Breslav
2013-07-09 21:04:46 +04:00
parent e566c3a738
commit 8d65613eed
3 changed files with 30 additions and 8 deletions
@@ -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 {