diff --git a/analysis/analysis-api/testData/components/callResolver/resolveCall/hiddenConstructor.txt b/analysis/analysis-api/testData/components/callResolver/resolveCall/hiddenConstructor.txt index 8da3015e509..590bfc20f05 100644 --- a/analysis/analysis-api/testData/components/callResolver/resolveCall/hiddenConstructor.txt +++ b/analysis/analysis-api/testData/components/callResolver/resolveCall/hiddenConstructor.txt @@ -1,17 +1,3 @@ KtErrorCallInfo: - candidateCalls = [ - KtSimpleFunctionCall: - isImplicitInvoke = false - partiallyAppliedSymbol = KtPartiallyAppliedSymbol: - dispatchReceiver = null - extensionReceiver = null - signature = KtFunctionLikeSignature: - receiverType = null - returnType = Obj - symbol = (): Obj - valueParameters = [] - callableIdIfNonLocal = null - typeArgumentsMapping = {} - argumentMapping = {} - ] - diagnostic = ERROR \ No newline at end of file + candidateCalls = [] + diagnostic = ERROR diff --git a/analysis/analysis-api/testData/components/callResolver/resolveCandidates/singleCandidate/hiddenConstructor.descriptors.txt b/analysis/analysis-api/testData/components/callResolver/resolveCandidates/singleCandidate/hiddenConstructor.descriptors.txt deleted file mode 100644 index 0656468e3ff..00000000000 --- a/analysis/analysis-api/testData/components/callResolver/resolveCandidates/singleCandidate/hiddenConstructor.descriptors.txt +++ /dev/null @@ -1 +0,0 @@ -NO_CANDIDATES diff --git a/analysis/analysis-api/testData/components/callResolver/resolveCandidates/singleCandidate/hiddenConstructor.txt b/analysis/analysis-api/testData/components/callResolver/resolveCandidates/singleCandidate/hiddenConstructor.txt index 95fe3573fda..0656468e3ff 100644 --- a/analysis/analysis-api/testData/components/callResolver/resolveCandidates/singleCandidate/hiddenConstructor.txt +++ b/analysis/analysis-api/testData/components/callResolver/resolveCandidates/singleCandidate/hiddenConstructor.txt @@ -1,16 +1 @@ -KtInapplicableCallCandidateInfo: - diagnostic = ERROR - candidate = KtSimpleFunctionCall: - isImplicitInvoke = false - partiallyAppliedSymbol = KtPartiallyAppliedSymbol: - dispatchReceiver = null - extensionReceiver = null - signature = KtFunctionLikeSignature: - receiverType = null - returnType = Obj - symbol = (): Obj - valueParameters = [] - callableIdIfNonLocal = null - typeArgumentsMapping = {} - argumentMapping = {} - isInBestCandidates = true +NO_CANDIDATES diff --git a/compiler/fir/analysis-tests/testData/resolve/visibility/singletonConstructors.fir.txt b/compiler/fir/analysis-tests/testData/resolve/visibility/singletonConstructors.fir.txt index 5e5bbf9764f..6480fe4b937 100644 --- a/compiler/fir/analysis-tests/testData/resolve/visibility/singletonConstructors.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/visibility/singletonConstructors.fir.txt @@ -12,7 +12,7 @@ FILE: singletonConstructors.kt } public final fun foo(): R|kotlin/Unit| { - #() + #() } } @@ -21,7 +21,7 @@ FILE: singletonConstructors.kt super() } - private final val x: R|B| = #() + private final val x: R|B| = #() private get(): R|B| } diff --git a/compiler/fir/analysis-tests/testData/resolve/visibility/singletonConstructors.kt b/compiler/fir/analysis-tests/testData/resolve/visibility/singletonConstructors.kt index 0d4bcd67c04..eeded920422 100644 --- a/compiler/fir/analysis-tests/testData/resolve/visibility/singletonConstructors.kt +++ b/compiler/fir/analysis-tests/testData/resolve/visibility/singletonConstructors.kt @@ -2,12 +2,12 @@ class A { companion object Comp {} fun foo() { - Comp() + Comp() } } object B { - private val x = B() + private val x = B() } class D { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolutionStages.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolutionStages.kt index 52f9e085bd3..ccc7aa3f2a5 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolutionStages.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolutionStages.kt @@ -525,7 +525,7 @@ internal object CheckVisibility : CheckerStage() { val visibilityChecker = callInfo.session.visibilityChecker val symbol = candidate.symbol val declaration = symbol.fir - if (declaration is FirMemberDeclaration) { + if (declaration is FirMemberDeclaration && declaration !is FirConstructor) { if (!visibilityChecker.isVisible(declaration, candidate)) { sink.yieldDiagnostic(VisibilityError) return @@ -538,13 +538,16 @@ internal object CheckVisibility : CheckerStage() { if (classSymbol is FirRegularClassSymbol) { if (classSymbol.fir.classKind.isSingleton) { - sink.yieldDiagnostic(VisibilityError) + sink.yieldDiagnostic(HiddenCandidate) } - if (!visibilityChecker.isVisible( - declaration, candidate.callInfo, dispatchReceiverValue = null, importedQualifierForStatic = null - ) - ) { + val visible = visibilityChecker.isVisible( + declaration, + candidate.callInfo, + dispatchReceiverValue = null, + importedQualifierForStatic = null + ) + if (!visible) { sink.yieldDiagnostic(VisibilityError) } } diff --git a/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/tower/CandidateApplicability.kt b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/tower/CandidateApplicability.kt index f1d2726157a..cc59f9e5c9b 100644 --- a/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/tower/CandidateApplicability.kt +++ b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/tower/CandidateApplicability.kt @@ -18,11 +18,6 @@ enum class CandidateApplicability { */ HIDDEN, - /** - * Candidate isn't visible. Provokes INVISIBLE_REFERENCE. - */ - K2_VISIBILITY_ERROR, - /** * Candidate could be successful but requires an unsupported feature. * Reported for references to local variables in K2. @@ -62,6 +57,11 @@ enum class CandidateApplicability { */ K1_RUNTIME_ERROR, + /** + * Candidate isn't visible. Provokes INVISIBLE_REFERENCE. + */ + K2_VISIBILITY_ERROR, + /** * Candidate could be successful but receiver (or argument?) nullability doesn't match */ diff --git a/compiler/testData/codegen/box/annotations/suppressInvisibleMember.kt b/compiler/testData/codegen/box/annotations/suppressInvisibleMember.kt index 60c88ce2c65..27c3d2a7442 100644 --- a/compiler/testData/codegen/box/annotations/suppressInvisibleMember.kt +++ b/compiler/testData/codegen/box/annotations/suppressInvisibleMember.kt @@ -1,6 +1,4 @@ // TARGET_BACKEND: JVM_IR -// IGNORE_BACKEND_K2: JVM_IR -// FIR_STATUS: KT-55026 // ISSUE: KT-55026 // MODULE: lib diff --git a/compiler/testData/diagnostics/tests/ConstructorsOfPrimitives.fir.kt b/compiler/testData/diagnostics/tests/ConstructorsOfPrimitives.fir.kt index c44df05e35c..65e00fb96bc 100644 --- a/compiler/testData/diagnostics/tests/ConstructorsOfPrimitives.fir.kt +++ b/compiler/testData/diagnostics/tests/ConstructorsOfPrimitives.fir.kt @@ -1,10 +1,10 @@ fun test() { - Double() - Float() - Long() - Int() - Short() - Byte() + Double() + Float() + Long() + Int() + Short() + Byte() Char() - Boolean() + Boolean() } diff --git a/compiler/testData/diagnostics/tests/annotations/requireKotlin.fir.kt b/compiler/testData/diagnostics/tests/annotations/requireKotlin.fir.kt index a57ce10c79e..d9671963b41 100644 --- a/compiler/testData/diagnostics/tests/annotations/requireKotlin.fir.kt +++ b/compiler/testData/diagnostics/tests/annotations/requireKotlin.fir.kt @@ -8,5 +8,5 @@ class IllegalVersion() @RequireKotlin("1.2") class LegalMinimum() -@RequireKotlin("1.2", versionKind = RequireKotlinVersionKind.COMPILER_VERSION, message = "Requires newer compiler version to be inlined correctly.") +@RequireKotlin("1.2", versionKind = RequireKotlinVersionKind.COMPILER_VERSION, message = "Requires newer compiler version to be inlined correctly.") class LegalStdLib() diff --git a/compiler/testData/diagnostics/tests/imports/ImportOverloadFunctions.fir.kt b/compiler/testData/diagnostics/tests/imports/ImportOverloadFunctions.fir.kt index 9999be53404..8e7c2ff1520 100644 --- a/compiler/testData/diagnostics/tests/imports/ImportOverloadFunctions.fir.kt +++ b/compiler/testData/diagnostics/tests/imports/ImportOverloadFunctions.fir.kt @@ -1,4 +1,5 @@ // !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE +// FIR_DIFFERENCE: KT-55234 // FILE: 1.kt package k @@ -26,17 +27,17 @@ import k.two import k.all fun test() { - zero() - zero(1) - zero("") + zero() + zero(1) + zero("") one() - one(1) - one("") + one(1) + one("") two() two(1) - two("") + two("") all() all(1) diff --git a/compiler/testData/diagnostics/tests/imports/ImportOverloadFunctions.kt b/compiler/testData/diagnostics/tests/imports/ImportOverloadFunctions.kt index e2081d0e7db..0ac657100e2 100644 --- a/compiler/testData/diagnostics/tests/imports/ImportOverloadFunctions.kt +++ b/compiler/testData/diagnostics/tests/imports/ImportOverloadFunctions.kt @@ -1,4 +1,5 @@ // !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE +// FIR_DIFFERENCE: KT-55234 // FILE: 1.kt package k diff --git a/compiler/testData/diagnostics/tests/incompleteCode/kt2014.fir.kt b/compiler/testData/diagnostics/tests/incompleteCode/kt2014.fir.kt index 85ef6c8f80b..f801c4eee02 100644 --- a/compiler/testData/diagnostics/tests/incompleteCode/kt2014.fir.kt +++ b/compiler/testData/diagnostics/tests/incompleteCode/kt2014.fir.kt @@ -14,7 +14,7 @@ fun x(f : Foo) { f.a() c() - R() + R() } object R {} diff --git a/compiler/testData/diagnostics/tests/j+k/packageVisibility.fir.kt b/compiler/testData/diagnostics/tests/j+k/packageVisibility.fir.kt index b1913801299..b19201c5fae 100644 --- a/compiler/testData/diagnostics/tests/j+k/packageVisibility.fir.kt +++ b/compiler/testData/diagnostics/tests/j+k/packageVisibility.fir.kt @@ -28,9 +28,9 @@ import a.MyJavaClass val mc1 = MyJavaClass() -val x = MyJavaClass.staticMethod() -val y = MyJavaClass.NestedClass.staticMethodOfNested() -val z = MyJavaClass.NestedClass() +val x = MyJavaClass.staticMethod() +val y = MyJavaClass.NestedClass.staticMethodOfNested() +val z = MyJavaClass.NestedClass() //FILE: c.kt package a.c @@ -39,6 +39,6 @@ import a.MyJavaClass val mc1 = MyJavaClass() -val x = MyJavaClass.staticMethod() -val y = MyJavaClass.NestedClass.staticMethodOfNested() -val z = MyJavaClass.NestedClass() +val x = MyJavaClass.staticMethod() +val y = MyJavaClass.NestedClass.staticMethodOfNested() +val z = MyJavaClass.NestedClass() diff --git a/compiler/testData/diagnostics/tests/j+k/privateNestedClassStaticMember.fir.kt b/compiler/testData/diagnostics/tests/j+k/privateNestedClassStaticMember.fir.kt index eeb612f19b3..8d6148f6287 100644 --- a/compiler/testData/diagnostics/tests/j+k/privateNestedClassStaticMember.fir.kt +++ b/compiler/testData/diagnostics/tests/j+k/privateNestedClassStaticMember.fir.kt @@ -14,5 +14,5 @@ public class Foo { // FILE: 1.kt fun main() { - javaPackage.Foo.Bar.doSmth() + javaPackage.Foo.Bar.doSmth() } diff --git a/compiler/testData/diagnostics/tests/resolve/noCandidates/resolvedToClassifier.fir.kt b/compiler/testData/diagnostics/tests/resolve/noCandidates/resolvedToClassifier.fir.kt index f1c9b80554e..33fc0acf15b 100644 --- a/compiler/testData/diagnostics/tests/resolve/noCandidates/resolvedToClassifier.fir.kt +++ b/compiler/testData/diagnostics/tests/resolve/noCandidates/resolvedToClassifier.fir.kt @@ -9,7 +9,7 @@ fun test() { val interface_as_fun = A() val interface_as_val = A - val object_as_fun = B() + val object_as_fun = B() val class_as_val = C } diff --git a/compiler/testData/diagnostics/tests/resolve/noCandidates/resolvedToClassifierWithReceiver.fir.kt b/compiler/testData/diagnostics/tests/resolve/noCandidates/resolvedToClassifierWithReceiver.fir.kt index 8f0ebd30b33..f3cffaadb1a 100644 --- a/compiler/testData/diagnostics/tests/resolve/noCandidates/resolvedToClassifierWithReceiver.fir.kt +++ b/compiler/testData/diagnostics/tests/resolve/noCandidates/resolvedToClassifierWithReceiver.fir.kt @@ -11,7 +11,7 @@ fun testX() { val interface_as_fun = X.A() val interface_as_val = X.A - val object_as_fun = X.B() + val object_as_fun = X.B() val class_as_val = X.C } @@ -26,7 +26,7 @@ fun testY() { val interface_as_fun = Y.A() val interface_as_val = Y.A - val object_as_fun = Y.B() + val object_as_fun = Y.B() val class_as_val = Y.C } diff --git a/compiler/testData/diagnostics/tests/scopes/protectedVisibility/constructors.fir.kt b/compiler/testData/diagnostics/tests/scopes/protectedVisibility/constructors.fir.kt index 9ab38cf1aaa..e88739944bb 100644 --- a/compiler/testData/diagnostics/tests/scopes/protectedVisibility/constructors.fir.kt +++ b/compiler/testData/diagnostics/tests/scopes/protectedVisibility/constructors.fir.kt @@ -7,7 +7,7 @@ open class A protected constructor(x: Int) { } fun foo() { - A() + A() A(1.0) } diff --git a/compiler/testData/diagnostics/tests/sealed/privateSealedConstructors_error.fir.kt b/compiler/testData/diagnostics/tests/sealed/privateSealedConstructors_error.fir.kt index e8b2b43353b..a4d1d3788f3 100644 --- a/compiler/testData/diagnostics/tests/sealed/privateSealedConstructors_error.fir.kt +++ b/compiler/testData/diagnostics/tests/sealed/privateSealedConstructors_error.fir.kt @@ -7,15 +7,15 @@ sealed class SealedBase(x: Int) { class SealedNested : SealedBase("nested") } -class SealedOuter : SealedBase("outer") +class SealedOuter : SealedBase("outer") abstract class RegularBase(x: Int) { private constructor(y: String) : this(y.length) class RegularNested : RegularBase("nested") } -class RegularOuter : RegularBase("outer") +class RegularOuter : RegularBase("outer") // FILE: derived.kt -class SealedOuterInDifferentFile : SealedBase("other file") +class SealedOuterInDifferentFile : SealedBase("other file") diff --git a/compiler/testData/diagnostics/tests/sealed/privateSealedConstructors_warning.fir.kt b/compiler/testData/diagnostics/tests/sealed/privateSealedConstructors_warning.fir.kt index 11ec3ec4690..2050abc3bc2 100644 --- a/compiler/testData/diagnostics/tests/sealed/privateSealedConstructors_warning.fir.kt +++ b/compiler/testData/diagnostics/tests/sealed/privateSealedConstructors_warning.fir.kt @@ -7,15 +7,15 @@ sealed class SealedBase(x: Int) { class SealedNested : SealedBase("nested") } -class SealedOuter : SealedBase("outer") +class SealedOuter : SealedBase("outer") abstract class RegularBase(x: Int) { private constructor(y: String) : this(y.length) class RegularNested : RegularBase("nested") } -class RegularOuter : RegularBase("outer") +class RegularOuter : RegularBase("outer") // FILE: derived.kt -class SealedOuterInDifferentFile : SealedBase("other file") +class SealedOuterInDifferentFile : SealedBase("other file") diff --git a/compiler/testData/diagnostics/tests/sealed/protectedConstructors_disabled.fir.kt b/compiler/testData/diagnostics/tests/sealed/protectedConstructors_disabled.fir.kt index 431489a5bfb..dabc2634b55 100644 --- a/compiler/testData/diagnostics/tests/sealed/protectedConstructors_disabled.fir.kt +++ b/compiler/testData/diagnostics/tests/sealed/protectedConstructors_disabled.fir.kt @@ -22,7 +22,7 @@ sealed class Case3 private constructor(val x: Int) { class Inheritor2 : Case3("Hello") } -class Case3Inheritor3 : Case3(20) // should be an error in 1.8 +class Case3Inheritor3 : Case3(20) // should be an error in 1.8 sealed class Case4 { protected constructor(x: Int) diff --git a/compiler/testData/diagnostics/tests/sealed/protectedConstructors_enabled.fir.kt b/compiler/testData/diagnostics/tests/sealed/protectedConstructors_enabled.fir.kt index c28a5e213c0..ed6abdc888d 100644 --- a/compiler/testData/diagnostics/tests/sealed/protectedConstructors_enabled.fir.kt +++ b/compiler/testData/diagnostics/tests/sealed/protectedConstructors_enabled.fir.kt @@ -22,7 +22,7 @@ sealed class Case3 private constructor(val x: Int) { class Inheritor2 : Case3("Hello") } -class Case3Inheritor3 : Case3(20) +class Case3Inheritor3 : Case3(20) sealed class Case4 { protected constructor(x: Int) diff --git a/compiler/testData/diagnostics/tests/typealias/privateInFile.fir.kt b/compiler/testData/diagnostics/tests/typealias/privateInFile.fir.kt index b64b21dd89f..24dbbbaea0a 100644 --- a/compiler/testData/diagnostics/tests/typealias/privateInFile.fir.kt +++ b/compiler/testData/diagnostics/tests/typealias/privateInFile.fir.kt @@ -9,14 +9,14 @@ private typealias TA = C private val test1: C = C() private val test1co: C.Companion = C -private val test2: TA = TA() +private val test2: TA = TA() private val test2co = TA // FILE: file2.kt private val test1: C = C() private val test1co: C.Companion = C -private val test2: TA = TA() +private val test2: TA = TA() private val test2co = TA private class C diff --git a/compiler/testData/diagnostics/tests/typealias/typeAliasConstructor.fir.kt b/compiler/testData/diagnostics/tests/typealias/typeAliasConstructor.fir.kt index a1d2bdc5a75..8fd8bab2106 100644 --- a/compiler/testData/diagnostics/tests/typealias/typeAliasConstructor.fir.kt +++ b/compiler/testData/diagnostics/tests/typealias/typeAliasConstructor.fir.kt @@ -20,5 +20,5 @@ typealias TO = AnObject val test6 = TI() val test6a = Interface() -val test7 = TO() -val test7a = AnObject() +val test7 = TO() +val test7a = AnObject() diff --git a/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorWrongVisibility.fir.kt b/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorWrongVisibility.fir.kt index 525bef71b3a..dafb82b5d3b 100644 --- a/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorWrongVisibility.fir.kt +++ b/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorWrongVisibility.fir.kt @@ -9,18 +9,18 @@ open class MyClass private constructor(val x: Int) { typealias MyAlias = MyClass -val test1 = MyAlias(1) -val test1a = MyClass(1) +val test1 = MyAlias(1) +val test1a = MyClass(1) -val test2 = MyAlias("") -val test2a = MyClass("") +val test2 = MyAlias("") +val test2a = MyClass("") val test3 = MyAlias(1.0) val test3a = MyClass(1.0) class MyDerived : MyClass(1.0) { - val test4 = MyAlias(1) - val test4a = MyClass(1) + val test4 = MyAlias(1) + val test4a = MyClass(1) val test5 = MyAlias("") val test5a = MyClass("") val test6 = MyAlias(1.0)