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();
|
List<TypeParameterDescriptor> parameters = classData.getTypeConstructor().getParameters();
|
||||||
if (isRaw(classType, !parameters.isEmpty())) {
|
if (isRaw(classType, !parameters.isEmpty())) {
|
||||||
for (TypeParameterDescriptor parameter : parameters) {
|
for (TypeParameterDescriptor parameter : parameters) {
|
||||||
TypeProjection starProjection = SubstitutionUtils.makeStarProjection(parameter);
|
// not making a star projection because of this case:
|
||||||
if (howThisTypeIsUsed == SUPERTYPE) {
|
// Java:
|
||||||
// projections are not allowed in immediate arguments of supertypes
|
// class C<T extends C> {}
|
||||||
arguments.add(new TypeProjection(starProjection.getType()));
|
// The upper bound is raw here, and we can't compute the projection: it would be infinite:
|
||||||
}
|
// C<*> = C<out C<out C<...>>>
|
||||||
else {
|
// this way we loose some type information, even when the case is not so bad, but it doesn't seem to matter
|
||||||
arguments.add(starProjection);
|
|
||||||
}
|
// 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 {
|
else {
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
// FILE: Bad.java
|
||||||
|
|
||||||
|
class Bad<T extends Bad> {}
|
||||||
|
|
||||||
|
// FILE: X.java
|
||||||
|
|
||||||
|
class X {
|
||||||
|
Bad foo() {return null;}
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: Usage.kt
|
||||||
|
|
||||||
|
fun foo(p: X) = p.foo()
|
||||||
@@ -3314,6 +3314,11 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage
|
|||||||
doTest("compiler/testData/diagnostics/tests/j+k/packageVisibility.kt");
|
doTest("compiler/testData/diagnostics/tests/j+k/packageVisibility.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("recursiveRawUpperBound.kt")
|
||||||
|
public void testRecursiveRawUpperBound() throws Exception {
|
||||||
|
doTest("compiler/testData/diagnostics/tests/j+k/recursiveRawUpperBound.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("Simple.kt")
|
@TestMetadata("Simple.kt")
|
||||||
public void testSimple() throws Exception {
|
public void testSimple() throws Exception {
|
||||||
doTest("compiler/testData/diagnostics/tests/j+k/Simple.kt");
|
doTest("compiler/testData/diagnostics/tests/j+k/Simple.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user