diff --git a/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java index 9f9947519fb..28819360c1f 100644 --- a/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java @@ -1041,6 +1041,11 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest { runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/repeatedModifier.kt"); } + @TestMetadata("returnTypeMismatchOnOverride.kt") + public void testReturnTypeMismatchOnOverride() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/returnTypeMismatchOnOverride.kt"); + } + @TestMetadata("sealedClassConstructorCall.kt") public void testSealedClassConstructorCall() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/sealedClassConstructorCall.kt"); @@ -1051,11 +1056,6 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest { runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/sealedSupertype.kt"); } - @TestMetadata("returnTypeMismatchOnOverride.kt") - public void testReturnTypeMismatchOnOverride() throws Exception { - runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/returnTypeMismatchOnOverride.kt"); - } - @TestMetadata("superIsNotAnExpression.kt") public void testSuperIsNotAnExpression() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/superIsNotAnExpression.kt"); diff --git a/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java index 1bd1eb87dd7..5c70f88cf13 100644 --- a/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java +++ b/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java @@ -1041,6 +1041,11 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/repeatedModifier.kt"); } + @TestMetadata("returnTypeMismatchOnOverride.kt") + public void testReturnTypeMismatchOnOverride() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/returnTypeMismatchOnOverride.kt"); + } + @TestMetadata("sealedClassConstructorCall.kt") public void testSealedClassConstructorCall() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/sealedClassConstructorCall.kt"); @@ -1051,11 +1056,6 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/sealedSupertype.kt"); } - @TestMetadata("returnTypeMismatchOnOverride.kt") - public void testReturnTypeMismatchOnOverride() throws Exception { - runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/returnTypeMismatchOnOverride.kt"); - } - @TestMetadata("superIsNotAnExpression.kt") public void testSuperIsNotAnExpression() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/superIsNotAnExpression.kt"); diff --git a/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/fir/ValueParameter.kt b/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/fir/ValueParameter.kt index 58a4c97ff69..7d5964ce434 100644 --- a/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/fir/ValueParameter.kt +++ b/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/fir/ValueParameter.kt @@ -48,7 +48,7 @@ class ValueParameter( source = firValueParameter.source this.session = session origin = FirDeclarationOrigin.Source - returnTypeRef = type.copyWithNewSourceKind(FirFakeSourceElementKind.ImplicitTypeRef) + returnTypeRef = type.copyWithNewSourceKind(FirFakeSourceElementKind.PropertyFromParameter) this.name = name initializer = buildQualifiedAccessExpression { calleeReference = buildPropertyFromParameterResolvedNamedReference { @@ -67,8 +67,20 @@ class ValueParameter( isLateInit = false } annotations += this@ValueParameter.firValueParameter.annotations - getter = FirDefaultPropertyGetter(null, session, FirDeclarationOrigin.Source, type, modifiers.getVisibility()) - setter = if (this.isVar) FirDefaultPropertySetter(null, session, FirDeclarationOrigin.Source, type, modifiers.getVisibility()) else null + getter = FirDefaultPropertyGetter( + null, + session, + FirDeclarationOrigin.Source, + type.copyWithNewSourceKind(FirFakeSourceElementKind.DefaultAccessor), + modifiers.getVisibility() + ) + setter = if (this.isVar) FirDefaultPropertySetter( + null, + session, + FirDeclarationOrigin.Source, + type.copyWithNewSourceKind(FirFakeSourceElementKind.DefaultAccessor), + modifiers.getVisibility() + ) else null }.apply { this.isFromVararg = firValueParameter.isVararg } diff --git a/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt b/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt index 6e7063ba576..1b4c9bf91f1 100644 --- a/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt +++ b/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt @@ -399,12 +399,18 @@ class RawFirBuilder( isLocal = false this.status = status val defaultAccessorSource = propertySource.fakeElement(FirFakeSourceElementKind.DefaultAccessor) - getter = FirDefaultPropertyGetter(defaultAccessorSource, baseSession, FirDeclarationOrigin.Source, type, visibility) + getter = FirDefaultPropertyGetter( + defaultAccessorSource, + baseSession, + FirDeclarationOrigin.Source, + type.copyWithNewSourceKind(FirFakeSourceElementKind.DefaultAccessor), + visibility + ) setter = if (isMutable) FirDefaultPropertySetter( defaultAccessorSource, baseSession, FirDeclarationOrigin.Source, - type, + type.copyWithNewSourceKind(FirFakeSourceElementKind.DefaultAccessor), visibility ) else null extractAnnotationsTo(this) diff --git a/compiler/fir/raw-fir/psi2fir/tests/org/jetbrains/kotlin/fir/builder/AbstractRawFirBuilderTestCase.kt b/compiler/fir/raw-fir/psi2fir/tests/org/jetbrains/kotlin/fir/builder/AbstractRawFirBuilderTestCase.kt index b1fb5a91e15..53bd4107316 100644 --- a/compiler/fir/raw-fir/psi2fir/tests/org/jetbrains/kotlin/fir/builder/AbstractRawFirBuilderTestCase.kt +++ b/compiler/fir/raw-fir/psi2fir/tests/org/jetbrains/kotlin/fir/builder/AbstractRawFirBuilderTestCase.kt @@ -20,12 +20,14 @@ import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.contracts.impl.FirEmptyContractDescription import org.jetbrains.kotlin.fir.declarations.FirFile import org.jetbrains.kotlin.fir.declarations.FirTypeParameter +import org.jetbrains.kotlin.fir.declarations.FirValueParameter import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirEmptyArgumentList import org.jetbrains.kotlin.fir.expressions.impl.FirNoReceiverExpression import org.jetbrains.kotlin.fir.expressions.impl.FirStubStatement import org.jetbrains.kotlin.fir.references.impl.FirStubReference import org.jetbrains.kotlin.fir.render +import org.jetbrains.kotlin.fir.types.FirTypeProjection import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.types.isExtensionFunctionAnnotationCall import org.jetbrains.kotlin.fir.visitors.CompositeTransformResult @@ -164,6 +166,7 @@ abstract class AbstractRawFirBuilderTestCase : KtParsingTestCase( private fun throwTwiceVisitingError(element: FirElement) { if (element is FirTypeRef || element is FirNoReceiverExpression || element is FirTypeParameter || + element is FirTypeProjection || element is FirValueParameter || element is FirAnnotationCall || element is FirEmptyContractDescription || element is FirStubReference || element.isExtensionFunctionAnnotation || element is FirEmptyArgumentList || element is FirStubStatement diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/Utils.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/Utils.kt index ba1504496e1..43704d00e79 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/Utils.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/Utils.kt @@ -52,6 +52,11 @@ fun R.copyWithNewSourceKind(newKind: FirFakeSourceElementKind): is FirFunctionTypeRefImpl -> buildFunctionTypeRefCopy(typeRef) { source = newSource } + is FirDynamicTypeRef -> buildDynamicTypeRef { + source = newSource + isMarkedNullable = typeRef.isMarkedNullable + annotations += typeRef.annotations + } is FirImplicitBuiltinTypeRef -> typeRef.withFakeSource(newKind) else -> TODO("Not implemented for ${typeRef::class}") } as R diff --git a/compiler/testData/cli/jvm/inapplicableLateinitModifier.out b/compiler/testData/cli/jvm/inapplicableLateinitModifier.out index fea5e307797..656662915d1 100644 --- a/compiler/testData/cli/jvm/inapplicableLateinitModifier.out +++ b/compiler/testData/cli/jvm/inapplicableLateinitModifier.out @@ -1,52 +1,22 @@ -compiler/testData/cli/jvm/inapplicableLateinitModifier.kt:6:1: error: 'lateinit' modifier is not allowed on properties of primitive types -lateinit var test: Int -^ -compiler/testData/cli/jvm/inapplicableLateinitModifier.kt:7:1: error: 'lateinit' modifier is not allowed on delegated properties +compiler/testData/cli/jvm/inapplicableLateinitModifier.kt:6:1: error: 'lateinit' modifier is not allowed on delegated properties lateinit var kest by Delegate ^ -compiler/testData/cli/jvm/inapplicableLateinitModifier.kt:12:5: error: 'lateinit' modifier is allowed only on mutable properties +compiler/testData/cli/jvm/inapplicableLateinitModifier.kt:9:5: error: 'lateinit' modifier is allowed only on mutable properties lateinit val fest = "10" ^ -compiler/testData/cli/jvm/inapplicableLateinitModifier.kt:12:5: error: 'lateinit' modifier is not allowed on properties with initializer - lateinit val fest = "10" - ^ -compiler/testData/cli/jvm/inapplicableLateinitModifier.kt:14:5: error: 'lateinit' modifier is not allowed on properties of nullable types +compiler/testData/cli/jvm/inapplicableLateinitModifier.kt:11:5: error: 'lateinit' modifier is not allowed on properties of a type with nullable upper bound lateinit var xest: String? ^ -compiler/testData/cli/jvm/inapplicableLateinitModifier.kt:15:5: error: 'lateinit' modifier is not allowed on properties of primitive types +compiler/testData/cli/jvm/inapplicableLateinitModifier.kt:12:5: error: 'lateinit' modifier is not allowed on properties of primitive types lateinit var nest: Int ^ -compiler/testData/cli/jvm/inapplicableLateinitModifier.kt:16:5: error: 'lateinit' modifier is not allowed on properties of primitive types - lateinit var west: Char - ^ -compiler/testData/cli/jvm/inapplicableLateinitModifier.kt:17:5: error: 'lateinit' modifier is not allowed on properties of primitive types - lateinit var qest: Boolean - ^ -compiler/testData/cli/jvm/inapplicableLateinitModifier.kt:18:5: error: 'lateinit' modifier is not allowed on properties of primitive types - lateinit var aest: Short - ^ -compiler/testData/cli/jvm/inapplicableLateinitModifier.kt:19:5: error: 'lateinit' modifier is not allowed on properties of primitive types - lateinit var hest: Byte - ^ -compiler/testData/cli/jvm/inapplicableLateinitModifier.kt:20:5: error: 'lateinit' modifier is not allowed on properties of primitive types - lateinit var jest: Long - ^ -compiler/testData/cli/jvm/inapplicableLateinitModifier.kt:21:5: error: 'lateinit' modifier is allowed only on mutable properties +compiler/testData/cli/jvm/inapplicableLateinitModifier.kt:13:5: error: 'lateinit' modifier is allowed only on mutable properties lateinit val dest: String ^ -compiler/testData/cli/jvm/inapplicableLateinitModifier.kt:21:5: error: 'lateinit' modifier is not allowed on properties with a custom getter or setter - lateinit val dest: String - ^ -compiler/testData/cli/jvm/inapplicableLateinitModifier.kt:26:5: error: 'lateinit' modifier is not allowed on properties of a type with nullable upper bound +compiler/testData/cli/jvm/inapplicableLateinitModifier.kt:18:5: error: 'lateinit' modifier is not allowed on properties of a type with nullable upper bound lateinit var best: T ^ -compiler/testData/cli/jvm/inapplicableLateinitModifier.kt:31:5: error: 'lateinit' modifier is not allowed on properties of nullable types - lateinit var vest: K? - ^ -compiler/testData/cli/jvm/inapplicableLateinitModifier.kt:35:5: error: 'lateinit' modifier is not allowed on local variables of primitive types - lateinit var i: Int - ^ -compiler/testData/cli/jvm/inapplicableLateinitModifier.kt:37:5: error: 'lateinit' modifier is not allowed on local variables with initializer +compiler/testData/cli/jvm/inapplicableLateinitModifier.kt:23:5: error: 'lateinit' modifier is not allowed on local variables with initializer lateinit var b: B = B() ^ COMPILATION_ERROR diff --git a/compiler/testData/cli/jvm/instanceAccessBeforeSuperCall.out b/compiler/testData/cli/jvm/instanceAccessBeforeSuperCall.out index a6d00540672..e6268d3d157 100644 --- a/compiler/testData/cli/jvm/instanceAccessBeforeSuperCall.out +++ b/compiler/testData/cli/jvm/instanceAccessBeforeSuperCall.out @@ -1,30 +1,18 @@ -warning: ATTENTION! -This build uses unsafe internal compiler arguments: - --XXLanguage:-SoundSmartCastsAfterTry - -This mode is not recommended for production use, -as no stability/compatibility guarantees are given on -compiler or generated code. Use it at your own risk! - -compiler/testData/cli/jvm/instanceAccessBeforeSuperCall.kt:2:26: error: cannot access 'getSomeInt' before superclass constructor has been called +compiler/testData/cli/jvm/instanceAccessBeforeSuperCall.kt:2:26: error: unresolved reference: getSomeInt constructor(x: Int = getSomeInt(), other: A = this, header: String = keker) {} ^ compiler/testData/cli/jvm/instanceAccessBeforeSuperCall.kt:2:51: error: cannot access '' before superclass constructor has been called constructor(x: Int = getSomeInt(), other: A = this, header: String = keker) {} ^ -compiler/testData/cli/jvm/instanceAccessBeforeSuperCall.kt:2:74: error: cannot access 'keker' before superclass constructor has been called - constructor(x: Int = getSomeInt(), other: A = this, header: String = keker) {} - ^ -compiler/testData/cli/jvm/instanceAccessBeforeSuperCall.kt:2:74: error: variable 'keker' must be initialized +compiler/testData/cli/jvm/instanceAccessBeforeSuperCall.kt:2:74: error: unresolved reference: keker constructor(x: Int = getSomeInt(), other: A = this, header: String = keker) {} ^ compiler/testData/cli/jvm/instanceAccessBeforeSuperCall.kt:7:20: error: 'this' is not defined in this context class B(other: B = this) ^ -compiler/testData/cli/jvm/instanceAccessBeforeSuperCall.kt:10:32: error: type mismatch: inferred type is () -> C but Int was expected +compiler/testData/cli/jvm/instanceAccessBeforeSuperCall.kt:10:27: error: inapplicable candidate(s): /C.C constructor(x: Int) : this({ - ^ + ^ compiler/testData/cli/jvm/instanceAccessBeforeSuperCall.kt:12:9: error: cannot access '' before superclass constructor has been called this ^ diff --git a/compiler/testData/diagnostics/tests/inference/completion/postponedArgumentsAnalysis/basic.fir.kt b/compiler/testData/diagnostics/tests/inference/completion/postponedArgumentsAnalysis/basic.fir.kt index 6a405239001..5e89719d737 100644 --- a/compiler/testData/diagnostics/tests/inference/completion/postponedArgumentsAnalysis/basic.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/completion/postponedArgumentsAnalysis/basic.fir.kt @@ -142,13 +142,13 @@ fun main() { val x18: (C) -> Unit = select(id { it }, { it }, id<(B) -> Unit> { x -> x }) // Resolution of extension/non-extension functions combination - val x19: String.() -> Unit = select(")!>id { this }, ")!>id(fun(x: String) {})) - val x20: String.() -> Unit = select(")!>{ this }, (fun(x: String) {})) + val x19: String.() -> Unit = select(")!>id { this }, ")!>id(fun(x: String) {})) + val x20: String.() -> Unit = select(")!>{ this }, (fun(x: String) {})) val x21: String.() -> Unit = select(")!>id(fun(x: String) {}), ")!>id(fun(x: String) {})) select(id Unit>(fun(x: String) {}), ")!>id(fun(x: String) {})) select(")!>id(fun String.(x: String) {}), ")!>id(fun(x: String, y: String) {})) - select(id(fun String.(x: String) {}), id(fun(x: String, y: String) { }), { x: String -> this }) - select(id(fun String.(x: String) {}), id(fun(x: String, y: String) { }), { x -> this }) + select(id(fun String.(x: String) {}), id(fun(x: String, y: String) { }), { x: String -> this }) + select(id(fun String.(x: String) {}), id(fun(x: String, y: String) { }), { x -> this }) select(id(fun String.(x: String) {}), id(fun(x: String, y: String) { }), { x: String, y: String -> x }) // Convert to extension lambda is impossible because the lambda parameter types aren't specified explicitly select(id(fun String.(x: String) {}), id(fun(x: String, y: String) { }), { x, y -> x })