-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIR] Prohibit referencing java field in case of conflict with proper…
…ty.. ..from companion object of the derived class ^KT-68056 Fixed
- Loading branch information
1 parent
b239239
commit b618ee4
Showing
9 changed files
with
130 additions
and
7 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
...el/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
...c/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
...en/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
...ests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
compiler/testData/codegen/box/javaFieldAndKotlinProperty/javaFieldAndCompanionProperty.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
...gnostics/tests/properties/javaFieldAndKotlinProperty/javaFieldAndCompanionProperty.fir.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// LANGUAGE: -ProperFieldAccessGenerationForFieldAccessShadowedByKotlinProperty | ||
// ISSUE: KT-52338 | ||
|
||
// FILE: Base.java | ||
public class Base { | ||
protected String TAG = "OK"; | ||
|
||
public String foo() { | ||
return TAG; | ||
} | ||
} | ||
|
||
// FILE: Sub.kt | ||
|
||
class Sub : Base() { | ||
companion object { | ||
val TAG = "FAIL" | ||
} | ||
|
||
fun log() = <!JAVA_FIELD_SHADOWED_BY_KOTLIN_PROPERTY!>TAG<!> | ||
|
||
fun logReference() = this::<!JAVA_FIELD_SHADOWED_BY_KOTLIN_PROPERTY!>TAG<!>.get() | ||
|
||
fun logAssignment(): String { | ||
<!JAVA_FIELD_SHADOWED_BY_KOTLIN_PROPERTY!>TAG<!> = "12" | ||
if (foo() != "12") return "Error writing: ${foo()}" | ||
return "OK" | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
.../diagnostics/tests/properties/javaFieldAndKotlinProperty/javaFieldAndCompanionProperty.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// LANGUAGE: -ProperFieldAccessGenerationForFieldAccessShadowedByKotlinProperty | ||
// ISSUE: KT-52338 | ||
|
||
// FILE: Base.java | ||
public class Base { | ||
protected String TAG = "OK"; | ||
|
||
public String foo() { | ||
return TAG; | ||
} | ||
} | ||
|
||
// FILE: Sub.kt | ||
|
||
class Sub : Base() { | ||
companion object { | ||
val TAG = "FAIL" | ||
} | ||
|
||
fun log() = TAG | ||
|
||
fun logReference() = this::TAG.get() | ||
|
||
fun logAssignment(): String { | ||
TAG = "12" | ||
if (foo() != "12") return "Error writing: ${foo()}" | ||
return "OK" | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
...tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.