Change MISSING_CONSTRUCTOR_KEYWORD severity to error
And adjust testData
This commit is contained in:
@@ -158,7 +158,7 @@ public interface Errors {
|
|||||||
DiagnosticFactory0<JetNullableType> NULLABLE_SUPERTYPE = DiagnosticFactory0.create(ERROR, NULLABLE_TYPE);
|
DiagnosticFactory0<JetNullableType> NULLABLE_SUPERTYPE = DiagnosticFactory0.create(ERROR, NULLABLE_TYPE);
|
||||||
DiagnosticFactory0<JetTypeReference> DYNAMIC_SUPERTYPE = DiagnosticFactory0.create(ERROR);
|
DiagnosticFactory0<JetTypeReference> DYNAMIC_SUPERTYPE = DiagnosticFactory0.create(ERROR);
|
||||||
|
|
||||||
DiagnosticFactory0<JetElement> MISSING_CONSTRUCTOR_KEYWORD = DiagnosticFactory0.create(WARNING);
|
DiagnosticFactory0<JetElement> MISSING_CONSTRUCTOR_KEYWORD = DiagnosticFactory0.create(ERROR);
|
||||||
|
|
||||||
// Secondary constructors
|
// Secondary constructors
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class Foo private(val param: String = "OK") {
|
class Foo private constructor(val param: String = "OK") {
|
||||||
companion object {
|
companion object {
|
||||||
val s = Foo()
|
val s = Foo()
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
var state: String = "Fail"
|
var state: String = "Fail"
|
||||||
|
|
||||||
class A private(x: String = "OK") {
|
class A private constructor(x: String = "OK") {
|
||||||
init {
|
init {
|
||||||
state = x
|
state = x
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
package someTest
|
package someTest
|
||||||
|
|
||||||
public class Some private(val v: String) {
|
public class Some private constructor(val v: String) {
|
||||||
companion object {
|
companion object {
|
||||||
public fun init(v: String): Some {
|
public fun init(v: String): Some {
|
||||||
return Some(v)
|
return Some(v)
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ data class A1(val prop1: String) {
|
|||||||
fun f(): String = "$prop1#$prop2#$prop3"
|
fun f(): String = "$prop1#$prop2#$prop3"
|
||||||
}
|
}
|
||||||
|
|
||||||
data class A2 private () {
|
data class A2 private constructor() {
|
||||||
var prop1: String = ""
|
var prop1: String = ""
|
||||||
var prop2: String = "const2"
|
var prop2: String = "const2"
|
||||||
var prop3: String = ""
|
var prop3: String = ""
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
var sideEffects: String = ""
|
var sideEffects: String = ""
|
||||||
|
|
||||||
abstract class B protected(val arg: Int) {
|
abstract class B protected constructor(val arg: Int) {
|
||||||
val parentProp: String
|
val parentProp: String
|
||||||
init {
|
init {
|
||||||
sideEffects += "zero#"
|
sideEffects += "zero#"
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
// This is crucial for some JVM frameworks like Quasar which rely on the bytecode being similar to the one generated by javac
|
// This is crucial for some JVM frameworks like Quasar which rely on the bytecode being similar to the one generated by javac
|
||||||
// See https://youtrack.jetbrains.com/issue/KT-6870
|
// See https://youtrack.jetbrains.com/issue/KT-6870
|
||||||
|
|
||||||
class PrivateConstructor private() {
|
class PrivateConstructor private constructor() {
|
||||||
class Nested { val a = PrivateConstructor() }
|
class Nested { val a = PrivateConstructor() }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
class Foo private(val a: Int = 1) {}
|
class Foo private constructor(val a: Int = 1) {}
|
||||||
|
|
||||||
// CLASS: Foo
|
// CLASS: Foo
|
||||||
// HAS_DEFAULT_CONSTRUCTOR: false
|
// HAS_DEFAULT_CONSTRUCTOR: false
|
||||||
|
|||||||
Vendored
+1
-1
@@ -1,3 +1,3 @@
|
|||||||
package test
|
package test
|
||||||
|
|
||||||
class TestConstructor private(p: Int = 1)
|
class TestConstructor private constructor(p: Int = 1)
|
||||||
|
|||||||
+1
-1
@@ -1,3 +1,3 @@
|
|||||||
package test
|
package test
|
||||||
|
|
||||||
public class InternalConstructor internal()
|
public class InternalConstructor internal constructor()
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ public class AnnotationGenTest extends CodegenTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testConstructor() throws NoSuchFieldException, NoSuchMethodException {
|
public void testConstructor() throws NoSuchFieldException, NoSuchMethodException {
|
||||||
loadText("class A @[Deprecated] () {}");
|
loadText("class A @[Deprecated] constructor() {}");
|
||||||
Class<?> aClass = generateClass("A");
|
Class<?> aClass = generateClass("A");
|
||||||
Constructor x = aClass.getDeclaredConstructor();
|
Constructor x = aClass.getDeclaredConstructor();
|
||||||
Deprecated annotation = (Deprecated) x.getAnnotation(Deprecated.class);
|
Deprecated annotation = (Deprecated) x.getAnnotation(Deprecated.class);
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
// INTENTION_TEXT: Make public
|
// INTENTION_TEXT: Make public
|
||||||
class C <caret>private (val v: Int)
|
class C <caret>private constructor(val v: Int)
|
||||||
+1
-1
@@ -1,2 +1,2 @@
|
|||||||
// INTENTION_TEXT: Make public
|
// INTENTION_TEXT: Make public
|
||||||
class C <caret>public (val v: Int)
|
class C <caret>public constructor(val v: Int)
|
||||||
+3
@@ -1,4 +1,7 @@
|
|||||||
// "Add missing 'constructor' keyword in whole project" "true"
|
// "Add missing 'constructor' keyword in whole project" "true"
|
||||||
|
// ERROR: Use 'constructor' keyword after modifiers of primary constructor
|
||||||
|
// ERROR: Use 'constructor' keyword after modifiers of primary constructor
|
||||||
|
// ERROR: Use 'constructor' keyword after modifiers of primary constructor
|
||||||
|
|
||||||
annotation class Ann(val x: Int = 1)
|
annotation class Ann(val x: Int = 1)
|
||||||
|
|
||||||
|
|||||||
Vendored
+3
@@ -1,4 +1,7 @@
|
|||||||
// "Add missing 'constructor' keyword in whole project" "true"
|
// "Add missing 'constructor' keyword in whole project" "true"
|
||||||
|
// ERROR: Use 'constructor' keyword after modifiers of primary constructor
|
||||||
|
// ERROR: Use 'constructor' keyword after modifiers of primary constructor
|
||||||
|
// ERROR: Use 'constructor' keyword after modifiers of primary constructor
|
||||||
|
|
||||||
annotation class Ann(val x: Int = 1)
|
annotation class Ann(val x: Int = 1)
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// "Remove 'protected' modifier" "true"
|
// "Remove 'protected' modifier" "true"
|
||||||
|
|
||||||
class A private <caret>protected () {
|
class A private <caret>protected constructor() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// "Remove 'protected' modifier" "true"
|
// "Remove 'protected' modifier" "true"
|
||||||
|
|
||||||
class A private () {
|
class A private constructor() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// "Add constructor parameters from Base(Int, Int)" "true"
|
// "Add constructor parameters from Base(Int, Int)" "true"
|
||||||
open class Base(p1: Int, val p2: Int)
|
open class Base(p1: Int, val p2: Int)
|
||||||
|
|
||||||
class C private : Base<caret>
|
class C private constructor : Base<caret>
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
// "Add constructor parameters from Base(Int, Int)" "true"
|
// "Add constructor parameters from Base(Int, Int)" "true"
|
||||||
open class Base(p1: Int, val p2: Int)
|
open class Base(p1: Int, val p2: Int)
|
||||||
|
|
||||||
class C private (p1: Int, p2: Int) : Base<caret>(p1, p2)
|
class C private constructor(p1: Int, p2: Int) : Base<caret>(p1, p2)
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
// "class org.jetbrains.kotlin.idea.quickfix.SuperClassNotInitialized$AddParenthesisFix" "false"
|
// "class org.jetbrains.kotlin.idea.quickfix.SuperClassNotInitialized$AddParenthesisFix" "false"
|
||||||
// ERROR: This type has a constructor, and thus must be initialized here
|
// ERROR: This type has a constructor, and thus must be initialized here
|
||||||
open class Base private(p: Int)
|
open class Base private constructor(p: Int)
|
||||||
|
|
||||||
class C : Base<caret>
|
class C : Base<caret>
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
// "Add constructor parameters from Base(String)" "true"
|
// "Add constructor parameters from Base(String)" "true"
|
||||||
open class Base private(p1: Int, val p2: Int) {
|
open class Base private constructor(p1: Int, val p2: Int) {
|
||||||
private constructor() : this(0, 1)
|
private constructor() : this(0, 1)
|
||||||
protected constructor(s: String) : this(s.length(), 1)
|
protected constructor(s: String) : this(s.length(), 1)
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
// "Add constructor parameters from Base(String)" "true"
|
// "Add constructor parameters from Base(String)" "true"
|
||||||
open class Base private(p1: Int, val p2: Int) {
|
open class Base private constructor(p1: Int, val p2: Int) {
|
||||||
private constructor() : this(0, 1)
|
private constructor() : this(0, 1)
|
||||||
protected constructor(s: String) : this(s.length(), 1)
|
protected constructor(s: String) : this(s.length(), 1)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user