FIR: Fix exception caused by empty supertypes of java.lang.Object
This commit is contained in:
committed by
TeamCityServer
parent
7eb0fd4762
commit
9d9f191f51
+6
@@ -5396,6 +5396,12 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis
|
||||
public void testTypeParameterUse() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/j+k/typeParameterUse.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("UsingObject.kt")
|
||||
public void testUsingObject() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/j+k/UsingObject.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
FILE: UsingObject.kt
|
||||
public final class A : R|kotlin/Any| {
|
||||
public constructor(): R|A| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
}
|
||||
public final fun foo(): R|A?| {
|
||||
^foo Null(null)
|
||||
}
|
||||
public final fun main(): R|kotlin/Unit| {
|
||||
lval w: R|kotlin/Any| = R|/foo|() ?: Q|java/lang|.R|java/lang/Object.Object|()
|
||||
R|<local>/w|.R|kotlin/Any.hashCode|()
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
class A
|
||||
|
||||
fun foo(): A? = null
|
||||
|
||||
fun main() {
|
||||
val w = foo() ?: java.lang.Object()
|
||||
w.hashCode()
|
||||
}
|
||||
+6
@@ -5396,6 +5396,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest {
|
||||
public void testTypeParameterUse() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/j+k/typeParameterUse.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("UsingObject.kt")
|
||||
public void testUsingObject() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/j+k/UsingObject.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
+6
@@ -5396,6 +5396,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
|
||||
public void testTypeParameterUse() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/j+k/typeParameterUse.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("UsingObject.kt")
|
||||
public void testUsingObject() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/j+k/UsingObject.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
@@ -33,15 +33,13 @@ import org.jetbrains.kotlin.fir.types.ConeClassLikeType
|
||||
import org.jetbrains.kotlin.fir.types.ConeFlexibleType
|
||||
import org.jetbrains.kotlin.fir.types.ConeKotlinType
|
||||
import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef
|
||||
import org.jetbrains.kotlin.fir.types.constructClassLikeType
|
||||
import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl
|
||||
import org.jetbrains.kotlin.load.java.JavaClassFinder
|
||||
import org.jetbrains.kotlin.load.java.JvmAnnotationNames
|
||||
import org.jetbrains.kotlin.load.java.structure.*
|
||||
import org.jetbrains.kotlin.load.java.structure.impl.JavaElementImpl
|
||||
import org.jetbrains.kotlin.name.CallableId
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.name.*
|
||||
import org.jetbrains.kotlin.types.Variance.INVARIANT
|
||||
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||
|
||||
@@ -195,6 +193,13 @@ class FirJavaFacade(
|
||||
}
|
||||
}
|
||||
javaClass.supertypes.mapTo(superTypeRefs) { it.toFirJavaTypeRef(session, javaTypeParameterStack) }
|
||||
if (superTypeRefs.isEmpty()) {
|
||||
superTypeRefs.add(
|
||||
buildResolvedTypeRef {
|
||||
type = StandardClassIds.Any.constructClassLikeType(emptyArray(), isNullable = false)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
val dispatchReceiver = classId.defaultType(typeParameters.map { it.symbol })
|
||||
|
||||
|
||||
Reference in New Issue
Block a user