Change MISSING_CONSTRUCTOR_KEYWORD severity to error

And adjust testData
This commit is contained in:
Denis Zharkov
2015-06-10 12:46:14 +03:00
parent eb7114bd53
commit e3c3af6aab
22 changed files with 26 additions and 20 deletions
@@ -158,7 +158,7 @@ public interface Errors {
DiagnosticFactory0<JetNullableType> NULLABLE_SUPERTYPE = DiagnosticFactory0.create(ERROR, NULLABLE_TYPE);
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
@@ -1,4 +1,4 @@
class Foo private(val param: String = "OK") {
class Foo private constructor(val param: String = "OK") {
companion object {
val s = Foo()
}
@@ -1,6 +1,6 @@
var state: String = "Fail"
class A private(x: String = "OK") {
class A private constructor(x: String = "OK") {
init {
state = x
}
+1 -1
View File
@@ -1,6 +1,6 @@
package someTest
public class Some private(val v: String) {
public class Some private constructor(val v: String) {
companion object {
public fun init(v: String): Some {
return Some(v)
@@ -12,7 +12,7 @@ data class A1(val prop1: String) {
fun f(): String = "$prop1#$prop2#$prop3"
}
data class A2 private () {
data class A2 private constructor() {
var prop1: String = ""
var prop2: String = "const2"
var prop3: String = ""
@@ -1,6 +1,6 @@
var sideEffects: String = ""
abstract class B protected(val arg: Int) {
abstract class B protected constructor(val arg: Int) {
val parentProp: String
init {
sideEffects += "zero#"
@@ -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
// See https://youtrack.jetbrains.com/issue/KT-6870
class PrivateConstructor private() {
class PrivateConstructor private constructor() {
class Nested { val a = PrivateConstructor() }
}
@@ -1,4 +1,4 @@
class Foo private(val a: Int = 1) {}
class Foo private constructor(val a: Int = 1) {}
// CLASS: Foo
// HAS_DEFAULT_CONSTRUCTOR: false
@@ -1,3 +1,3 @@
package test
class TestConstructor private(p: Int = 1)
class TestConstructor private constructor(p: Int = 1)
@@ -1,3 +1,3 @@
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 {
loadText("class A @[Deprecated] () {}");
loadText("class A @[Deprecated] constructor() {}");
Class<?> aClass = generateClass("A");
Constructor x = aClass.getDeclaredConstructor();
Deprecated annotation = (Deprecated) x.getAnnotation(Deprecated.class);
@@ -1,2 +1,2 @@
// INTENTION_TEXT: Make public
class C <caret>private (val v: Int)
class C <caret>private constructor(val v: Int)
@@ -1,2 +1,2 @@
// INTENTION_TEXT: Make public
class C <caret>public (val v: Int)
class C <caret>public constructor(val v: Int)
@@ -1,4 +1,7 @@
// "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)
@@ -1,4 +1,7 @@
// "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)
@@ -1,5 +1,5 @@
// "Remove 'protected' modifier" "true"
class A private <caret>protected () {
class A private <caret>protected constructor() {
}
@@ -1,5 +1,5 @@
// "Remove 'protected' modifier" "true"
class A private () {
class A private constructor() {
}
@@ -1,4 +1,4 @@
// "Add constructor parameters from Base(Int, Int)" "true"
open class Base(p1: Int, val p2: Int)
class C private : Base<caret>
class C private constructor : Base<caret>
@@ -1,4 +1,4 @@
// "Add constructor parameters from Base(Int, Int)" "true"
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"
// 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>
@@ -1,5 +1,5 @@
// "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)
protected constructor(s: String) : this(s.length(), 1)
}
@@ -1,5 +1,5 @@
// "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)
protected constructor(s: String) : this(s.length(), 1)
}