diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/Candidate.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/Candidate.kt index 1ac8ab87e40..61c29e67933 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/Candidate.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/Candidate.kt @@ -25,7 +25,7 @@ import org.jetbrains.kotlin.resolve.calls.inference.model.ConstraintStorage import org.jetbrains.kotlin.resolve.calls.model.PostponedResolvedAtomMarker import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind -class CallInfo( +data class CallInfo( val callKind: CallKind, val name: Name, diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/FirTowerResolver.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/FirTowerResolver.kt index de5ed64b7a1..1560f0fe44c 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/FirTowerResolver.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/FirTowerResolver.kt @@ -5,18 +5,32 @@ package org.jetbrains.kotlin.fir.resolve.calls +import org.jetbrains.kotlin.descriptors.ClassKind import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.declarations.FirRegularClass +import org.jetbrains.kotlin.fir.declarations.impl.FirImportImpl +import org.jetbrains.kotlin.fir.declarations.impl.FirResolvedImportImpl import org.jetbrains.kotlin.fir.declarations.isInner +import org.jetbrains.kotlin.fir.expressions.FirResolvedQualifier +import org.jetbrains.kotlin.fir.expressions.impl.FirQualifiedAccessExpressionImpl import org.jetbrains.kotlin.fir.resolve.BodyResolveComponents import org.jetbrains.kotlin.fir.resolve.calls.TowerDataKind.* +import org.jetbrains.kotlin.fir.resolve.transformQualifiedAccessUsingSmartcastInfo import org.jetbrains.kotlin.fir.resolve.transformers.ReturnTypeCalculator +import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.firUnsafe import org.jetbrains.kotlin.fir.scopes.FirScope +import org.jetbrains.kotlin.fir.scopes.ProcessorAction import org.jetbrains.kotlin.fir.scopes.ProcessorAction.NONE +import org.jetbrains.kotlin.fir.scopes.impl.FirExplicitSimpleImportingScope import org.jetbrains.kotlin.fir.scopes.impl.FirLocalScope +import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol import org.jetbrains.kotlin.fir.types.ConeIntegerLiteralType import org.jetbrains.kotlin.fir.types.coneTypeSafe +import org.jetbrains.kotlin.name.FqName +import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind import org.jetbrains.kotlin.resolve.descriptorUtil.HIDES_MEMBERS_NAME_LIST +import org.jetbrains.kotlin.util.OperatorNameConventions enum class TowerDataKind { EMPTY, // Corresponds to stub tower level which is replaced by receiver-related level @@ -228,13 +242,100 @@ class FirTowerResolver( } } + private fun createExplicitReceiverForInvoke(candidate: Candidate): FirQualifiedAccessExpressionImpl { + val symbol = candidate.symbol as FirCallableSymbol<*> + return FirQualifiedAccessExpressionImpl(null).apply { + calleeReference = FirNamedReferenceWithCandidate( + null, + symbol.callableId.callableName, + candidate + ) + dispatchReceiver = candidate.dispatchReceiverExpression() + typeRef = typeCalculator.tryCalculateReturnType(symbol.firUnsafe()) + } + } + + // Only case when qualifiedReceiver is a package (no classId) is handled here + private fun runResolverForFullyQualifiedReceiver( + implicitReceiverValues: List>, + info: CallInfo, + collector: CandidateCollector, + qualifiedReceiver: FirResolvedQualifier + ): CandidateCollector { + val qualifierScope = FirExplicitSimpleImportingScope( + listOf( + FirResolvedImportImpl( + FirImportImpl(null, FqName.topLevel(info.name), false, null), + qualifiedReceiver.packageFqName, + qualifiedReceiver.relativeClassFqName + ) + ), session, components.scopeSession + ) + val candidateFactory = CandidateFactory(components, info) + + when (info.callKind) { + CallKind.VariableAccess -> { + qualifierScope.processPropertiesByName(info.name) { + collector.consumeCandidate(0, candidateFactory.createCandidate(it, ExplicitReceiverKind.NO_EXPLICIT_RECEIVER)) + ProcessorAction.NEXT + } + qualifierScope.processClassifiersByName(info.name) { + if (it is FirClassSymbol<*> && it.fir.classKind == ClassKind.OBJECT) { + collector.consumeCandidate(0, candidateFactory.createCandidate(it, ExplicitReceiverKind.NO_EXPLICIT_RECEIVER)) + } + ProcessorAction.NEXT + } + } + CallKind.Function -> { + qualifierScope.processFunctionsAndConstructorsByName(info.name, session, components) { + collector.consumeCandidate(0, candidateFactory.createCandidate(it, ExplicitReceiverKind.NO_EXPLICIT_RECEIVER)) + ProcessorAction.NEXT + } + + val invokeReceiverCollector = CandidateCollector(components, components.resolutionStageRunner) + val invokeReceiverCandidateFactory = CandidateFactory( + components, + info.replaceWithVariableAccess() + ) + + qualifierScope.processPropertiesByName(info.name) { + invokeReceiverCollector.consumeCandidate( + 0, invokeReceiverCandidateFactory.createCandidate(it, ExplicitReceiverKind.NO_EXPLICIT_RECEIVER) + ) + ProcessorAction.NEXT + } + if (invokeReceiverCollector.isSuccess()) { + for (invokeReceiverCandidate in invokeReceiverCollector.bestCandidates()) { + val invokeReceiverExpression = createExplicitReceiverForInvoke(invokeReceiverCandidate).let { + components.transformQualifiedAccessUsingSmartcastInfo(it) + } + runResolver( + implicitReceiverValues, + info.copy(explicitReceiver = invokeReceiverExpression, name = OperatorNameConventions.INVOKE), + collector + ) + } + } + } + CallKind.CallableReference -> return collector + else -> throw AssertionError("Unsupported call kind in tower resolver: ${info.callKind}") + } + return collector + } + fun runResolver( - implicitReceiverValues: List>, info: CallInfo, + implicitReceiverValues: List>, + info: CallInfo, collector: CandidateCollector = this.collector ): CandidateCollector { this.implicitReceiverValues = implicitReceiverValues - towerDataConsumer = towerDataConsumer(info, collector) + val receiver = info.explicitReceiver + if (receiver is FirResolvedQualifier && receiver.classId == null) { + return runResolverForFullyQualifiedReceiver(implicitReceiverValues, info, collector, receiver) + } + + towerDataConsumer = towerDataConsumer(info, collector) val shouldProcessExtensionsBeforeMembers = info.callKind == CallKind.Function && info.name in HIDES_MEMBERS_NAME_LIST val shouldProcessExplicitReceiverScopeOnly = diff --git a/compiler/fir/resolve/testData/resolve/qualifierWithCompanion.kt b/compiler/fir/resolve/testData/resolve/qualifierWithCompanion.kt new file mode 100644 index 00000000000..a777ee49e24 --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/qualifierWithCompanion.kt @@ -0,0 +1,19 @@ +package my + +class A { + companion object X { + fun foo() {} + } +} + +val xx = A() + +fun test() { + val x = A + A.foo() + A.X.foo() + + fun A.invoke() {} + + my.xx() +} \ No newline at end of file diff --git a/compiler/fir/resolve/testData/resolve/qualifierWithCompanion.txt b/compiler/fir/resolve/testData/resolve/qualifierWithCompanion.txt new file mode 100644 index 00000000000..c25149157ab --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/qualifierWithCompanion.txt @@ -0,0 +1,28 @@ +FILE: qualifierWithCompanion.kt + public final class A : R|kotlin/Any| { + public constructor(): R|my/A| { + super() + } + + public final companion object X : R|kotlin/Any| { + private constructor(): R|my/A.X| { + super() + } + + public final fun foo(): R|kotlin/Unit| { + } + + } + + } + public final val xx: R|my/A| = R|my/A.A|() + public get(): R|my/A| + public final fun test(): R|kotlin/Unit| { + lval x: R|my/A.X| = Q|my/A| + Q|my/A|.R|my/A.X.foo|() + Q|my/A.X|.R|my/A.X.foo|() + local final fun R|my/A|.invoke(): R|kotlin/Unit| { + } + + R|my/xx|.R|/invoke|() + } diff --git a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java index d95e42f82ec..d543e53741e 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java @@ -178,6 +178,11 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest { runTest("compiler/fir/resolve/testData/resolve/problems2.kt"); } + @TestMetadata("qualifierWithCompanion.kt") + public void testQualifierWithCompanion() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/qualifierWithCompanion.kt"); + } + @TestMetadata("recursiveCallOnWhenWithSealedClass.kt") public void testRecursiveCallOnWhenWithSealedClass() throws Exception { runTest("compiler/fir/resolve/testData/resolve/recursiveCallOnWhenWithSealedClass.kt"); diff --git a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java index 5793fe0016c..cbf13093e22 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java @@ -178,6 +178,11 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos runTest("compiler/fir/resolve/testData/resolve/problems2.kt"); } + @TestMetadata("qualifierWithCompanion.kt") + public void testQualifierWithCompanion() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/qualifierWithCompanion.kt"); + } + @TestMetadata("recursiveCallOnWhenWithSealedClass.kt") public void testRecursiveCallOnWhenWithSealedClass() throws Exception { runTest("compiler/fir/resolve/testData/resolve/recursiveCallOnWhenWithSealedClass.kt"); diff --git a/compiler/testData/codegen/box/primitiveTypes/kt243.kt b/compiler/testData/codegen/box/primitiveTypes/kt243.kt index bcf7f9ac7fa..b1339085237 100644 --- a/compiler/testData/codegen/box/primitiveTypes/kt243.kt +++ b/compiler/testData/codegen/box/primitiveTypes/kt243.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM fun box() : String { diff --git a/compiler/testData/diagnostics/tests/cast/nothingAs.fir.kt b/compiler/testData/diagnostics/tests/cast/nothingAs.fir.kt index 55e07cfd39f..3b822c57db8 100644 --- a/compiler/testData/diagnostics/tests/cast/nothingAs.fir.kt +++ b/compiler/testData/diagnostics/tests/cast/nothingAs.fir.kt @@ -1,6 +1,6 @@ // !DIAGNOSTICS: -UNREACHABLE_CODE -fun TODO(): Nothing = throw java.lang.IllegalStateException() +fun TODO(): Nothing = throw java.lang.IllegalStateException() open class OpenClass class FinalClass : OpenClass() diff --git a/compiler/testData/diagnostics/tests/controlFlowAnalysis/deadCode/deadCodeDifferentExamples.fir.kt b/compiler/testData/diagnostics/tests/controlFlowAnalysis/deadCode/deadCodeDifferentExamples.fir.kt index 02e113dc355..9da253daa3b 100644 --- a/compiler/testData/diagnostics/tests/controlFlowAnalysis/deadCode/deadCodeDifferentExamples.fir.kt +++ b/compiler/testData/diagnostics/tests/controlFlowAnalysis/deadCode/deadCodeDifferentExamples.fir.kt @@ -151,7 +151,7 @@ fun foo(a : Nothing) : Unit { } fun fail() : Nothing { - throw java.lang.RuntimeException() + throw java.lang.RuntimeException() } fun nullIsNotNothing() : Unit { diff --git a/compiler/testData/diagnostics/tests/controlStructures/kt770.fir.kt351.fir.kt735_StatementType.fir.kt b/compiler/testData/diagnostics/tests/controlStructures/kt770.fir.kt351.fir.kt735_StatementType.fir.kt index 04ddcacfd16..7fe506f722b 100644 --- a/compiler/testData/diagnostics/tests/controlStructures/kt770.fir.kt351.fir.kt735_StatementType.fir.kt +++ b/compiler/testData/diagnostics/tests/controlStructures/kt770.fir.kt351.fir.kt735_StatementType.fir.kt @@ -140,7 +140,7 @@ fun testCoercionToAny() { fun fooWithAnuNullableResult(s: String?, name: String, optional: Boolean): Any? { return if (s == null) { if (!optional) { - throw java.lang.IllegalArgumentException("Parameter '$name' was not found in the request") + throw java.lang.IllegalArgumentException("Parameter '$name' was not found in the request") } null } else { diff --git a/compiler/testData/diagnostics/tests/extensions/GenericIterator.fir.kt b/compiler/testData/diagnostics/tests/extensions/GenericIterator.fir.kt index 480c208080f..fdb80f439aa 100644 --- a/compiler/testData/diagnostics/tests/extensions/GenericIterator.fir.kt +++ b/compiler/testData/diagnostics/tests/extensions/GenericIterator.fir.kt @@ -23,7 +23,7 @@ operator fun T?.iterator() = object : MyIterator { hasNext = false return this@iterator!! } - throw java.util.NoSuchElementException() + throw java.util.NoSuchElementException() } } diff --git a/compiler/testData/diagnostics/tests/generics/projectionsScope/flexibleProjectedScope.fir.kt b/compiler/testData/diagnostics/tests/generics/projectionsScope/flexibleProjectedScope.fir.kt index 1556a5dd960..75900129d50 100644 --- a/compiler/testData/diagnostics/tests/generics/projectionsScope/flexibleProjectedScope.fir.kt +++ b/compiler/testData/diagnostics/tests/generics/projectionsScope/flexibleProjectedScope.fir.kt @@ -11,6 +11,6 @@ public class Clazz { public fun > Iterable.filterTo(destination: C, predicate: (T) -> Boolean) {} fun test(clazz: Clazz) { - val result = java.util.ArrayList() - clazz.foo().filterTo(result) { x -> true } + val result = java.util.ArrayList() + clazz.foo().filterTo(result) { x -> true } } diff --git a/compiler/testData/diagnostics/tests/generics/wrongNumberOfTypeArgumentsDiagnostic.fir.kt b/compiler/testData/diagnostics/tests/generics/wrongNumberOfTypeArgumentsDiagnostic.fir.kt index 84e29cfaf8c..ca978f6d492 100644 --- a/compiler/testData/diagnostics/tests/generics/wrongNumberOfTypeArgumentsDiagnostic.fir.kt +++ b/compiler/testData/diagnostics/tests/generics/wrongNumberOfTypeArgumentsDiagnostic.fir.kt @@ -10,7 +10,7 @@ fun test1() { } fun test2() { - val m0 = java.util.HashMap() - val m1 = java.util.HashMap() - val m2 = java.util.HashMap() + val m0 = java.util.HashMap() + val m1 = java.util.HashMap() + val m2 = java.util.HashMap() } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt2179.fir.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt2179.fir.kt index 5e0aa34d03d..b19c3e751d1 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt2179.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt2179.fir.kt @@ -28,7 +28,7 @@ fun test() { fun arrayList(vararg values: T) : ArrayList = values.toCollection(ArrayList(values.size)) fun Collection.map(transform : (T) -> R) : List { - return mapTo(java.util.ArrayList(this.size), transform) + return mapTo(java.util.ArrayList(this.size), transform) } fun > Collection.mapTo(result: C, transform : (T) -> R) : C { diff --git a/compiler/testData/diagnostics/tests/j+k/UnboxingNulls.fir.kt b/compiler/testData/diagnostics/tests/j+k/UnboxingNulls.fir.kt index 4e69df6f24c..f988db2b0e2 100644 --- a/compiler/testData/diagnostics/tests/j+k/UnboxingNulls.fir.kt +++ b/compiler/testData/diagnostics/tests/j+k/UnboxingNulls.fir.kt @@ -9,5 +9,5 @@ package a fun foo() { // If this fails, it means that we have broken the rule that Java returns are always nullable - a.Test().t() + 1 + a.Test().t() + 1 } diff --git a/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt1270.fir.kt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt1270.fir.kt index da7a0604f37..fc22dedc602 100644 --- a/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt1270.fir.kt +++ b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt1270.fir.kt @@ -4,8 +4,8 @@ package kt1270 fun foo() { - val sc = java.util.HashMap()[""] - val value = sc.value + val sc = java.util.HashMap()[""] + val value = sc.value } private class SomeClass() { diff --git a/compiler/testData/diagnostics/tests/regressions/kt459.fir.kt b/compiler/testData/diagnostics/tests/regressions/kt459.fir.kt index 02c5f40b7d2..c2b93e0e6a1 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt459.fir.kt +++ b/compiler/testData/diagnostics/tests/regressions/kt459.fir.kt @@ -1,7 +1,7 @@ // KT-459 Type argument inference fails when class names are fully qualified fun test() { - val attributes : java.util.HashMap = java.util.HashMap() // failure! + val attributes : java.util.HashMap = java.util.HashMap() // failure! attributes["href"] = "1" // inference fails, but it shouldn't } diff --git a/compiler/testData/diagnostics/tests/regressions/kt549.fir.kt b/compiler/testData/diagnostics/tests/regressions/kt549.fir.kt index 4f1e0359083..872ae3bc2a4 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt549.fir.kt +++ b/compiler/testData/diagnostics/tests/regressions/kt549.fir.kt @@ -3,9 +3,9 @@ package demo fun filter(list : Array, filter : (T) -> Boolean) : List { - val answer = java.util.ArrayList(); + val answer = java.util.ArrayList(); for (l in list) { - if (filter(l)) answer.add(l) + if (filter(l)) answer.add(l) } return answer; } diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/inlinedLambdaAlwaysThrows.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/inlinedLambdaAlwaysThrows.fir.kt index 8ccf5757a7f..fc8123558a6 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/inlinedLambdaAlwaysThrows.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/inlinedLambdaAlwaysThrows.fir.kt @@ -12,6 +12,6 @@ inline fun myRun(block: () -> Unit): Unit { } fun test() { - myRun { throw java.lang.IllegalArgumentException() } + myRun { throw java.lang.IllegalArgumentException() } val x: Int = 42 } \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/throwIfNotCalled.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/throwIfNotCalled.fir.kt index 326fedbe978..979b54e2721 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/throwIfNotCalled.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/throwIfNotCalled.fir.kt @@ -22,7 +22,7 @@ fun throwIfNotCalled() { return@outer } } - throw java.lang.IllegalArgumentException() + throw java.lang.IllegalArgumentException() } // x *is* initialized here, because if myRun was never called -> exception // were thrown and control flow wouldn't be here @@ -39,7 +39,7 @@ fun catchThrowIfNotCalled() { return@outer } } - throw java.lang.IllegalArgumentException() + throw java.lang.IllegalArgumentException() } } catch (ignored: java.lang.IllegalArgumentException) { } diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/unreachableCode.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/unreachableCode.fir.kt index 46fa3404a18..d19c6127d7b 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/unreachableCode.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/controlflow/flowInlining/unreachableCode.fir.kt @@ -12,6 +12,6 @@ inline fun myRun(block: () -> T): T { } fun throwInLambda(): Int { - val x = myRun { throw java.lang.IllegalArgumentException(); 42 } + val x = myRun { throw java.lang.IllegalArgumentException(); 42 } return x } \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/booleanComparisons.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/booleanComparisons.fir.kt index c0c46f6f189..b65f3ded19a 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/booleanComparisons.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/dsl/errors/booleanComparisons.fir.kt @@ -18,6 +18,6 @@ fun bar(b: Boolean?): Boolean { // not pointless, but not supported yet returns(true) implies (b == true) } - if (b == null) throw java.lang.IllegalArgumentException("") + if (b == null) throw java.lang.IllegalArgumentException("") return b } \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/fromStdlib/check.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/fromStdlib/check.fir.kt index c995b305d84..178e729256b 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/fromStdlib/check.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/fromStdlib/check.fir.kt @@ -18,7 +18,7 @@ fun testCheckWithMessage(x: Any?) { } fun testCheckWithFailingMessage(x: Any?) { - check(x is String) { throw kotlin.IllegalStateException("What a strange idea") } + check(x is String) { throw kotlin.IllegalStateException("What a strange idea") } x.length } diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/fromStdlib/require.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/fromStdlib/require.fir.kt index 69c93de9dab..d7f45912906 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/fromStdlib/require.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/fromStdlib/require.fir.kt @@ -17,7 +17,7 @@ fun testRequireWithMessage(x: Any?) { } fun testRequireWithFailingMessage(x: Any?) { - require(x is String) { throw kotlin.IllegalStateException("What a strange idea") } + require(x is String) { throw kotlin.IllegalStateException("What a strange idea") } x.length } diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/callWithDefaultValue.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/callWithDefaultValue.fir.kt index 5a9eb941860..52a26b6c3e6 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/callWithDefaultValue.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/callWithDefaultValue.fir.kt @@ -8,7 +8,7 @@ fun myAssert(condition: Boolean, message: String = "") { contract { returns() implies (condition) } - if (!condition) throw kotlin.IllegalArgumentException(message) + if (!condition) throw kotlin.IllegalArgumentException(message) } fun test(x: Any?) { diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/catchExceptionSpilling.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/catchExceptionSpilling.fir.kt index 1ff2a9cb789..27f981a82c9 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/catchExceptionSpilling.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/catchExceptionSpilling.fir.kt @@ -8,7 +8,7 @@ fun myAssert(condition: Boolean) { contract { returns() implies (condition) } - if (!condition) throw kotlin.IllegalArgumentException("Assertion failed") + if (!condition) throw kotlin.IllegalArgumentException("Assertion failed") } fun testWithCatch(x: Any?) { diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/deeplyNested.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/deeplyNested.fir.kt index 547e0691f2c..29421c67cd6 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/deeplyNested.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/deeplyNested.fir.kt @@ -9,7 +9,7 @@ fun myAssert(condition: Boolean) { contract { returns() implies (condition) } - if (!condition) throw kotlin.IllegalArgumentException("Assertion failed") + if (!condition) throw kotlin.IllegalArgumentException("Assertion failed") } fun isString(x: Any?): Boolean { diff --git a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/throwsEffect.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/throwsEffect.fir.kt index 9a045826426..c54df88cf4c 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/throwsEffect.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/contracts/smartcasts/throwsEffect.fir.kt @@ -8,7 +8,7 @@ fun myAssert(condition: Boolean) { contract { returns() implies (condition) } - if (!condition) throw kotlin.IllegalArgumentException("Assertion failed") + if (!condition) throw kotlin.IllegalArgumentException("Assertion failed") } fun testAssertSmartcast(x: Any?) { diff --git a/compiler/testData/diagnostics/testsWithStdLib/java/concurrentHashMapContains.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/java/concurrentHashMapContains.fir.kt index 3ab06eb5330..3822790bf66 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/java/concurrentHashMapContains.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/java/concurrentHashMapContains.fir.kt @@ -18,14 +18,14 @@ class C : java.util.concurrent.ConcurrentHashMap() { } fun main() { - val hm = java.util.concurrent.ConcurrentHashMap() + val hm = java.util.concurrent.ConcurrentHashMap() "" in hm "" !in hm - 1 !in hm - 2 in hm + 1 !in hm + 2 in hm hm.contains("") - hm.contains(1) + hm.contains(1) "" in (hm as Map) "" !in (hm as Map) diff --git a/compiler/testData/diagnostics/testsWithStdLib/java/concurrentHashMapContainsError.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/java/concurrentHashMapContainsError.fir.kt index 2b8476b7c5b..5d66e168b78 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/java/concurrentHashMapContainsError.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/java/concurrentHashMapContainsError.fir.kt @@ -18,14 +18,14 @@ class C : java.util.concurrent.ConcurrentHashMap() { } fun main() { - val hm = java.util.concurrent.ConcurrentHashMap() + val hm = java.util.concurrent.ConcurrentHashMap() "" in hm "" !in hm - 1 !in hm - 2 in hm + 1 !in hm + 2 in hm hm.contains("") - hm.contains(1) + hm.contains(1) "" in (hm as Map) "" !in (hm as Map) diff --git a/compiler/testData/diagnostics/testsWithStdLib/kt7585/delegate.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/kt7585/delegate.fir.kt index 3867393a3f2..557e9ba6a6b 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/kt7585/delegate.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/kt7585/delegate.fir.kt @@ -70,7 +70,7 @@ class My(val x: Int) { when { y > 0 -> MyBase.derivedWrapper() x < 0 -> MyBase.exoticWrapper(x) - else -> throw java.lang.NullPointerException("") + else -> throw java.lang.NullPointerException("") } } } diff --git a/compiler/testData/diagnostics/testsWithStdLib/resolve/javaPackageMembers.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/resolve/javaPackageMembers.fir.kt index 16749b92a94..26068f65a79 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/resolve/javaPackageMembers.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/resolve/javaPackageMembers.fir.kt @@ -1,9 +1,9 @@ -fun fn(): Nothing = throw java.lang.RuntimeException("oops") +fun fn(): Nothing = throw java.lang.RuntimeException("oops") -val x: Nothing = throw java.lang.RuntimeException("oops") +val x: Nothing = throw java.lang.RuntimeException("oops") class SomeClass { fun method() { - throw java.lang.AssertionError("!!!") + throw java.lang.AssertionError("!!!") } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/targetedBuiltIns/unsupportedFeature.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/targetedBuiltIns/unsupportedFeature.fir.kt index 5839abbd937..3f1d73aa51d 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/targetedBuiltIns/unsupportedFeature.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/targetedBuiltIns/unsupportedFeature.fir.kt @@ -42,7 +42,7 @@ fun Throwable.fillInStackTrace() = 1 fun foo(x: List, y: Throwable, z: A3) { x.stream() - java.util.ArrayList().stream() + java.util.ArrayList().stream() y.fillInStackTrace() checkType { _() } diff --git a/compiler/testData/diagnostics/testsWithStdLib/typealias/exceptionTypeAliases.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/typealias/exceptionTypeAliases.fir.kt index f986b5d6eb6..7639d72c72f 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/typealias/exceptionTypeAliases.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/typealias/exceptionTypeAliases.fir.kt @@ -1,3 +1,3 @@ // FILE: test.kt val fooException = Exception("foo") -val barException = kotlin.Exception("bar") +val barException = kotlin.Exception("bar") diff --git a/compiler/testData/diagnostics/testsWithStdLib/typealias/exceptionTypeAliasesInvisibleWithApiVersion1_0.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/typealias/exceptionTypeAliasesInvisibleWithApiVersion1_0.fir.kt index 80cc7440061..ac7a8639686 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/typealias/exceptionTypeAliasesInvisibleWithApiVersion1_0.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/typealias/exceptionTypeAliasesInvisibleWithApiVersion1_0.fir.kt @@ -2,4 +2,4 @@ // !API_VERSION: 1.0 // FILE: test.kt val fooException = Exception("foo") -val barException = kotlin.Exception("bar") +val barException = kotlin.Exception("bar") diff --git a/compiler/testData/diagnostics/testsWithStdLib/typealias/exceptionTypeAliasesInvisibleWithoutFeature.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/typealias/exceptionTypeAliasesInvisibleWithoutFeature.fir.kt index 66b41670c8e..9df3938bc68 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/typealias/exceptionTypeAliasesInvisibleWithoutFeature.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/typealias/exceptionTypeAliasesInvisibleWithoutFeature.fir.kt @@ -1,4 +1,4 @@ // !LANGUAGE: -TypeAliases // FILE: test.kt val fooException = Exception("foo") -val barException = kotlin.Exception("bar") +val barException = kotlin.Exception("bar")