CanBePrimaryConstructorPropertyInspection: do not report for 'open' property used in class initializer in 'open' class

This commit is contained in:
Toshiaki Kameyama
2020-02-04 13:46:28 +09:00
committed by Dmitry Gridin
parent 963258189a
commit 0b9106b0f8
3 changed files with 91 additions and 7 deletions
@@ -15,4 +15,28 @@
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Property is explicitly assigned to constructor parameter</problem_class>
<description>Property is explicitly assigned to parameter withType, can be declared directly in constructor</description>
</problem>
<problem>
<file>properties.kt</file>
<line>79</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="temp:///src/properties.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Property is explicitly assigned to constructor parameter</problem_class>
<description>Property is explicitly assigned to parameter property, can be declared directly in constructor</description>
</problem>
<problem>
<file>properties.kt</file>
<line>87</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="temp:///src/properties.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Property is explicitly assigned to constructor parameter</problem_class>
<description>Property is explicitly assigned to parameter property, can be declared directly in constructor</description>
</problem>
<problem>
<file>properties.kt</file>
<line>91</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="temp:///src/properties.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Property is explicitly assigned to constructor parameter</problem_class>
<description>Property is explicitly assigned to parameter property, can be declared directly in constructor</description>
</problem>
</problems>
@@ -44,4 +44,49 @@ class Bar(x : String) {
override val x = x // Property is assigned to parameter, can be declared in ctor
}
}
}
}
// KT-32561
open class X(property: String) {
init {
print(property)
}
open val property: String = property
}
abstract class X2(property: String) {
init {
print(property)
}
open val property: String = property
}
sealed class X3(property: String) {
init {
print(property)
}
open val property: String = property
}
open class X4(property: String) {
init {
print(property)
}
val property: String = property
}
class X5(property: String) {
init {
print(property)
}
open val property: String = property
}
open class X6(property: String) {
open val property: String = property
}