From dccb7faf2e63425a1bf77d38e60010d9576d36d8 Mon Sep 17 00:00:00 2001 From: Nikolay Lunyak Date: Wed, 7 Sep 2022 13:56:49 +0300 Subject: [PATCH] [FIR] KT-53479: Paraphrase INSTANCE_ACCESS_BEFORE_SUPER_CALL --- .../diagnostics/instanceAccessBeforeSuperCall.fir.txt | 2 +- .../fir/analysis/diagnostics/FirErrorsDefaultMessages.kt | 2 +- .../kotlin/fir/resolve/diagnostics/ConeDiagnostics.kt | 2 +- .../diagnostics/rendering/DefaultErrorMessages.java | 2 +- .../testData/cli/jvm/instanceAccessBeforeSuperCall.out | 8 ++++---- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/instanceAccessBeforeSuperCall.fir.txt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/instanceAccessBeforeSuperCall.fir.txt index 10056871e2f..52f36df040d 100644 --- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/instanceAccessBeforeSuperCall.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/instanceAccessBeforeSuperCall.fir.txt @@ -25,7 +25,7 @@ FILE: instanceAccessBeforeSuperCall.kt } public constructor(x: R|kotlin/Int|): R|C| { - this(fun (): '' before superclass constructor has been called> { + this(fun (): '' before the instance has been initialized> { lval a: R|kotlin/Int| = Int(10) ^ this@R|/C| } diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrorsDefaultMessages.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrorsDefaultMessages.kt index ed9a74c9af2..d1142002b3a 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrorsDefaultMessages.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrorsDefaultMessages.kt @@ -664,7 +664,7 @@ object FirErrorsDefaultMessages : BaseDiagnosticRendererFactory() { ) map.put( INSTANCE_ACCESS_BEFORE_SUPER_CALL, - "Cannot access ''{0}'' before superclass constructor has been called", + "Cannot access ''{0}'' before the instance has been initialized", TO_STRING ) map.put(CREATING_AN_INSTANCE_OF_ABSTRACT_CLASS, "Cannot create an instance of an abstract class") diff --git a/compiler/fir/semantics/src/org/jetbrains/kotlin/fir/resolve/diagnostics/ConeDiagnostics.kt b/compiler/fir/semantics/src/org/jetbrains/kotlin/fir/resolve/diagnostics/ConeDiagnostics.kt index 317ef394621..1234ea1b7f1 100644 --- a/compiler/fir/semantics/src/org/jetbrains/kotlin/fir/resolve/diagnostics/ConeDiagnostics.kt +++ b/compiler/fir/semantics/src/org/jetbrains/kotlin/fir/resolve/diagnostics/ConeDiagnostics.kt @@ -172,7 +172,7 @@ class ConeOuterClassArgumentsRequired( } class ConeInstanceAccessBeforeSuperCall(val target: String) : ConeDiagnostic { - override val reason: String get() = "Cannot access ''${target}'' before superclass constructor has been called" + override val reason: String get() = "Cannot access ''${target}'' before the instance has been initialized" } class ConeUnsupportedCallableReferenceTarget(override val candidate: AbstractCandidate) : ConeDiagnosticWithSingleCandidate { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java index 8bd84cce0a7..d592c32b8b7 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java @@ -698,7 +698,7 @@ public class DefaultErrorMessages { MAP.put(EXPLICIT_DELEGATION_CALL_REQUIRED, "Explicit 'this' or 'super' call is required. There is no constructor in superclass that can be called without arguments"); - MAP.put(INSTANCE_ACCESS_BEFORE_SUPER_CALL, "Cannot access ''{0}'' before superclass constructor has been called", NAME); + MAP.put(INSTANCE_ACCESS_BEFORE_SUPER_CALL, "Cannot access ''{0}'' before the instance has been initialized", NAME); MAP.put(ILLEGAL_SELECTOR, "The expression cannot be a selector (occur after a dot)"); diff --git a/compiler/testData/cli/jvm/instanceAccessBeforeSuperCall.out b/compiler/testData/cli/jvm/instanceAccessBeforeSuperCall.out index 446e2212b9e..c5a74d7b293 100644 --- a/compiler/testData/cli/jvm/instanceAccessBeforeSuperCall.out +++ b/compiler/testData/cli/jvm/instanceAccessBeforeSuperCall.out @@ -4,7 +4,7 @@ warning: ATTENTION! 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 +compiler/testData/cli/jvm/instanceAccessBeforeSuperCall.kt:2:51: error: cannot access '' before the instance has been initialized constructor(x: Int = getSomeInt(), other: A = this, header: String = keker) {} ^ compiler/testData/cli/jvm/instanceAccessBeforeSuperCall.kt:2:74: error: unresolved reference: keker @@ -13,13 +13,13 @@ compiler/testData/cli/jvm/instanceAccessBeforeSuperCall.kt:2:74: error: unresolv 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: argument type mismatch: actual type is kotlin/Function0'' before superclass constructor has been called> but kotlin/Int was expected +compiler/testData/cli/jvm/instanceAccessBeforeSuperCall.kt:10:32: error: argument type mismatch: actual type is kotlin/Function0'' before the instance has been initialized> but kotlin/Int was expected constructor(x: Int) : this({ ^ -compiler/testData/cli/jvm/instanceAccessBeforeSuperCall.kt:12:9: error: argument type mismatch: actual type is ERROR CLASS: Cannot access '''' before superclass constructor has been called but ERROR CLASS: Unknown return lambda parameter type was expected +compiler/testData/cli/jvm/instanceAccessBeforeSuperCall.kt:12:9: error: argument type mismatch: actual type is ERROR CLASS: Cannot access '''' before the instance has been initialized but ERROR CLASS: Unknown return lambda parameter type was expected this ^ -compiler/testData/cli/jvm/instanceAccessBeforeSuperCall.kt:12:9: error: cannot access '' before superclass constructor has been called +compiler/testData/cli/jvm/instanceAccessBeforeSuperCall.kt:12:9: error: cannot access '' before the instance has been initialized this ^ COMPILATION_ERROR