SLC: drop the assertion that class context shouldn't be null
...because it can be null if an anonymous object is returned as a value of reified inline function, which isn't materialized as LC element. ^KT-59537 Fixed
This commit is contained in:
+1
-3
@@ -125,9 +125,7 @@ abstract class SymbolLightClassBase protected constructor(val ktModule: KtModule
|
||||
|
||||
abstract override fun hashCode(): Int
|
||||
|
||||
override fun getContext(): PsiElement = parent ?: buildErrorWithAttachment("parent must not be null") {
|
||||
withClassEntry("class", this@SymbolLightClassBase)
|
||||
}
|
||||
override fun getContext(): PsiElement? = parent
|
||||
|
||||
override fun isEquivalentTo(another: PsiElement?): Boolean = PsiClassImplUtil.isClassEquivalentTo(this, another)
|
||||
|
||||
|
||||
+12
-3
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.light.classes.symbol.base
|
||||
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.*
|
||||
import java.nio.file.Path
|
||||
import org.jetbrains.kotlin.analysis.test.framework.test.configurators.AnalysisApiTestConfigurator
|
||||
import org.jetbrains.kotlin.light.classes.symbol.modifierLists.SymbolLightClassModifierList
|
||||
import org.jetbrains.kotlin.light.classes.symbol.modifierLists.SymbolLightMemberModifierList
|
||||
@@ -17,7 +18,6 @@ import org.jetbrains.kotlin.test.directives.model.SimpleDirectivesContainer
|
||||
import org.jetbrains.kotlin.test.model.TestModule
|
||||
import org.jetbrains.kotlin.test.services.AssertionsService
|
||||
import org.junit.Assume
|
||||
import java.nio.file.Path
|
||||
|
||||
open class AbstractSymbolLightClassesParentingTestBase(
|
||||
configurator: AnalysisApiTestConfigurator,
|
||||
@@ -190,9 +190,18 @@ open class AbstractSymbolLightClassesParentingTestBase(
|
||||
}
|
||||
|
||||
private fun checkDeclarationParent(declaration: PsiElement) {
|
||||
val expectedParent = declarationStack.lastOrNull() ?: return
|
||||
// NB: we deliberately put these retrievals before the bail-out below so that we can catch any potential exceptions.
|
||||
val context = declaration.context
|
||||
val parent = declaration.parent
|
||||
assertions.assertNotNull(parent) { "Parent should not be null for ${declaration::class} with text ${declaration.text}" }
|
||||
// NB: for a legitimate `null` parent case, e.g., an anonymous object as a return value of reified inline function,
|
||||
// it will not have an expected parent from the stack, and we can bail out early here.
|
||||
val expectedParent = declarationStack.lastOrNull() ?: return
|
||||
assertions.assertNotNull(context) {
|
||||
"context should not be null for ${declaration::class} with text ${declaration.text}"
|
||||
}
|
||||
assertions.assertNotNull(parent) {
|
||||
"Parent should not be null for ${declaration::class} with text ${declaration.text}"
|
||||
}
|
||||
assertions.assertEquals(expectedParent, parent) {
|
||||
"Unexpected parent for ${declaration::class} with text ${declaration.text}"
|
||||
}
|
||||
|
||||
+6
@@ -429,6 +429,12 @@ public class SymbolLightClassesByPsiForLibraryTestGenerated extends AbstractSymb
|
||||
runTest("compiler/testData/asJava/lightClasses/lightClassByPsi/facades/properties.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("reifiedInlineReturnsObject.kt")
|
||||
public void testReifiedInlineReturnsObject() throws Exception {
|
||||
runTest("compiler/testData/asJava/lightClasses/lightClassByPsi/facades/reifiedInlineReturnsObject.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("simpleFunctions.kt")
|
||||
public void testSimpleFunctions() throws Exception {
|
||||
|
||||
+6
@@ -429,6 +429,12 @@ public class SymbolLightClassesEqualityByPsiForLibraryTestGenerated extends Abst
|
||||
runTest("compiler/testData/asJava/lightClasses/lightClassByPsi/facades/properties.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("reifiedInlineReturnsObject.kt")
|
||||
public void testReifiedInlineReturnsObject() throws Exception {
|
||||
runTest("compiler/testData/asJava/lightClasses/lightClassByPsi/facades/reifiedInlineReturnsObject.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("simpleFunctions.kt")
|
||||
public void testSimpleFunctions() throws Exception {
|
||||
|
||||
+6
@@ -429,6 +429,12 @@ public class SymbolLightClassesParentingByPsiForLibraryTestGenerated extends Abs
|
||||
runTest("compiler/testData/asJava/lightClasses/lightClassByPsi/facades/properties.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("reifiedInlineReturnsObject.kt")
|
||||
public void testReifiedInlineReturnsObject() throws Exception {
|
||||
runTest("compiler/testData/asJava/lightClasses/lightClassByPsi/facades/reifiedInlineReturnsObject.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("simpleFunctions.kt")
|
||||
public void testSimpleFunctions() throws Exception {
|
||||
|
||||
+6
@@ -429,6 +429,12 @@ public class SymbolLightClassesByPsiForSourceTestGenerated extends AbstractSymbo
|
||||
runTest("compiler/testData/asJava/lightClasses/lightClassByPsi/facades/properties.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("reifiedInlineReturnsObject.kt")
|
||||
public void testReifiedInlineReturnsObject() throws Exception {
|
||||
runTest("compiler/testData/asJava/lightClasses/lightClassByPsi/facades/reifiedInlineReturnsObject.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("simpleFunctions.kt")
|
||||
public void testSimpleFunctions() throws Exception {
|
||||
|
||||
+6
@@ -429,6 +429,12 @@ public class SymbolLightClassesEqualityByPsiForSourceTestGenerated extends Abstr
|
||||
runTest("compiler/testData/asJava/lightClasses/lightClassByPsi/facades/properties.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("reifiedInlineReturnsObject.kt")
|
||||
public void testReifiedInlineReturnsObject() throws Exception {
|
||||
runTest("compiler/testData/asJava/lightClasses/lightClassByPsi/facades/reifiedInlineReturnsObject.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("simpleFunctions.kt")
|
||||
public void testSimpleFunctions() throws Exception {
|
||||
|
||||
+6
@@ -429,6 +429,12 @@ public class SymbolLightClassesParentingByPsiForSourceTestGenerated extends Abst
|
||||
runTest("compiler/testData/asJava/lightClasses/lightClassByPsi/facades/properties.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("reifiedInlineReturnsObject.kt")
|
||||
public void testReifiedInlineReturnsObject() throws Exception {
|
||||
runTest("compiler/testData/asJava/lightClasses/lightClassByPsi/facades/reifiedInlineReturnsObject.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("simpleFunctions.kt")
|
||||
public void testSimpleFunctions() throws Exception {
|
||||
|
||||
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
final class null /* null*/ extends PaginatedTableModel<R> {
|
||||
@java.lang.Override()
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public java.util.List<R> getRows();// getRows()
|
||||
|
||||
private ();// .ctor()
|
||||
}
|
||||
|
||||
public abstract class PaginatedTableModel /* PaginatedTableModel*/<R> {
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public abstract java.util.List<R> getRows();// getRows()
|
||||
|
||||
public PaginatedTableModel(int);// .ctor(int)
|
||||
}
|
||||
|
||||
public final class ReifiedInlineReturnsObjectKt /* ReifiedInlineReturnsObjectKt*/ {
|
||||
}
|
||||
Vendored
+16
@@ -0,0 +1,16 @@
|
||||
final class null /* null*/ extends PaginatedTableModel<R> {
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public java.util.List<R> getRows();// getRows()
|
||||
|
||||
private ();// .ctor()
|
||||
}
|
||||
|
||||
public abstract class PaginatedTableModel /* PaginatedTableModel*/<R> {
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public abstract java.util.List<R> getRows();// getRows()
|
||||
|
||||
public PaginatedTableModel(int);// .ctor(int)
|
||||
}
|
||||
|
||||
public final class ReifiedInlineReturnsObjectKt /* ReifiedInlineReturnsObjectKt*/ {
|
||||
}
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
abstract class PaginatedTableModel<R>(initialPageSize: Int) {
|
||||
abstract val rows: List<R>
|
||||
}
|
||||
|
||||
inline fun <reified R> MutableList<R>.asTableModel(pageSize : Int = 42) =
|
||||
object : PaginatedTableModel<R>(pageSize) {
|
||||
override val rows
|
||||
get() = this@asTableModel
|
||||
}
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
public abstract class PaginatedTableModel /* PaginatedTableModel*/<R> {
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public abstract java.util.List<R> getRows();// getRows()
|
||||
|
||||
public PaginatedTableModel(int);// .ctor(int)
|
||||
}
|
||||
|
||||
public final class ReifiedInlineReturnsObjectKt /* ReifiedInlineReturnsObjectKt*/ {
|
||||
}
|
||||
Reference in New Issue
Block a user