[FIR] Expand type of const val in FirConstPropertyChecker
This commit is contained in:
committed by
TeamCityServer
parent
669985f853
commit
478a512b24
+5
@@ -975,6 +975,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract
|
||||
public void testConstValWithGetterOrDelegate() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/constVal/constValWithGetterOrDelegate.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("constValWithTypealiasType.kt")
|
||||
public void testConstValWithTypealiasType() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/constVal/constValWithTypealiasType.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/constructors")
|
||||
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
FILE: constValWithTypealiasType.kt
|
||||
public final typealias Foo = R|kotlin/Int|
|
||||
public final const val x: R|Foo| = Int(10)
|
||||
public get(): R|Foo|
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
typealias Foo = Int
|
||||
|
||||
const val x: Foo = 10
|
||||
+6
@@ -1128,6 +1128,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest {
|
||||
public void testConstValWithGetterOrDelegate() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/constVal/constValWithGetterOrDelegate.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("constValWithTypealiasType.kt")
|
||||
public void testConstValWithTypealiasType() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/constVal/constValWithTypealiasType.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
+6
@@ -1128,6 +1128,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
|
||||
public void testConstValWithGetterOrDelegate() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/constVal/constValWithGetterOrDelegate.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("constValWithTypealiasType.kt")
|
||||
public void testConstValWithTypealiasType() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/constVal/constValWithTypealiasType.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
+3
-2
@@ -17,6 +17,7 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.reportOn
|
||||
import org.jetbrains.kotlin.fir.declarations.FirProperty
|
||||
import org.jetbrains.kotlin.fir.declarations.FirRegularClass
|
||||
import org.jetbrains.kotlin.fir.declarations.isConst
|
||||
import org.jetbrains.kotlin.fir.resolve.fullyExpandedType
|
||||
import org.jetbrains.kotlin.fir.types.ConeClassErrorType
|
||||
import org.jetbrains.kotlin.fir.types.coneType
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
@@ -55,7 +56,7 @@ object FirConstPropertyChecker : FirPropertyChecker() {
|
||||
return
|
||||
}
|
||||
|
||||
val type = declaration.returnTypeRef.coneType
|
||||
val type = declaration.returnTypeRef.coneType.fullyExpandedType(context.session)
|
||||
if ((type !is ConeClassErrorType) && !type.canBeUsedForConstVal()) {
|
||||
reporter.reportOn(declaration.source, FirErrors.TYPE_CANT_BE_USED_FOR_CONST_VAL, declaration.returnTypeRef.coneType, context)
|
||||
return
|
||||
@@ -65,4 +66,4 @@ object FirConstPropertyChecker : FirPropertyChecker() {
|
||||
reporter.reportOn(initializer.source, FirErrors.CONST_VAL_WITH_NON_CONST_INITIALIZER, context)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5
@@ -977,6 +977,11 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis
|
||||
public void testConstValWithGetterOrDelegate() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/constVal/constValWithGetterOrDelegate.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("constValWithTypealiasType.kt")
|
||||
public void testConstValWithTypealiasType() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/constVal/constValWithTypealiasType.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/constructors")
|
||||
|
||||
Reference in New Issue
Block a user