diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java index 739611cf9a3..0daa6285114 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java @@ -158,7 +158,7 @@ public interface Errors { DiagnosticFactory0 NULLABLE_SUPERTYPE = DiagnosticFactory0.create(ERROR, NULLABLE_TYPE); DiagnosticFactory0 DYNAMIC_SUPERTYPE = DiagnosticFactory0.create(ERROR); - DiagnosticFactory0 MISSING_CONSTRUCTOR_KEYWORD = DiagnosticFactory0.create(WARNING); + DiagnosticFactory0 MISSING_CONSTRUCTOR_KEYWORD = DiagnosticFactory0.create(ERROR); // Secondary constructors diff --git a/compiler/testData/codegen/box/defaultArguments/constructor/kt3060.kt b/compiler/testData/codegen/box/defaultArguments/constructor/kt3060.kt index f41e711b1dc..ca4275a7403 100644 --- a/compiler/testData/codegen/box/defaultArguments/constructor/kt3060.kt +++ b/compiler/testData/codegen/box/defaultArguments/constructor/kt3060.kt @@ -1,4 +1,4 @@ -class Foo private(val param: String = "OK") { +class Foo private constructor(val param: String = "OK") { companion object { val s = Foo() } diff --git a/compiler/testData/codegen/box/defaultArguments/private/primaryConstructor.kt b/compiler/testData/codegen/box/defaultArguments/private/primaryConstructor.kt index 51c45f4b8fd..7b4ba263678 100644 --- a/compiler/testData/codegen/box/defaultArguments/private/primaryConstructor.kt +++ b/compiler/testData/codegen/box/defaultArguments/private/primaryConstructor.kt @@ -1,6 +1,6 @@ var state: String = "Fail" -class A private(x: String = "OK") { +class A private constructor(x: String = "OK") { init { state = x } diff --git a/compiler/testData/codegen/box/functions/kt2716.kt b/compiler/testData/codegen/box/functions/kt2716.kt index 3a1220b0593..0ba57fd380a 100644 --- a/compiler/testData/codegen/box/functions/kt2716.kt +++ b/compiler/testData/codegen/box/functions/kt2716.kt @@ -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) diff --git a/compiler/testData/codegen/box/secondaryConstructors/dataClasses.kt b/compiler/testData/codegen/box/secondaryConstructors/dataClasses.kt index 1db78322746..36db3835ec7 100644 --- a/compiler/testData/codegen/box/secondaryConstructors/dataClasses.kt +++ b/compiler/testData/codegen/box/secondaryConstructors/dataClasses.kt @@ -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 = "" diff --git a/compiler/testData/codegen/box/secondaryConstructors/superCallPrimary.kt b/compiler/testData/codegen/box/secondaryConstructors/superCallPrimary.kt index 3fe1038172e..7225bc1af4f 100644 --- a/compiler/testData/codegen/box/secondaryConstructors/superCallPrimary.kt +++ b/compiler/testData/codegen/box/secondaryConstructors/superCallPrimary.kt @@ -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#" diff --git a/compiler/testData/codegen/boxWithStdlib/synthetic/syntheticAccessorNames.kt b/compiler/testData/codegen/boxWithStdlib/synthetic/syntheticAccessorNames.kt index f7499261bb1..cee187def83 100644 --- a/compiler/testData/codegen/boxWithStdlib/synthetic/syntheticAccessorNames.kt +++ b/compiler/testData/codegen/boxWithStdlib/synthetic/syntheticAccessorNames.kt @@ -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() } } diff --git a/compiler/testData/codegen/defaultArguments/reflection/privateConstructor.kt b/compiler/testData/codegen/defaultArguments/reflection/privateConstructor.kt index 7b8a429f6bc..b507a8e6dc9 100644 --- a/compiler/testData/codegen/defaultArguments/reflection/privateConstructor.kt +++ b/compiler/testData/codegen/defaultArguments/reflection/privateConstructor.kt @@ -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 diff --git a/compiler/testData/loadJava/compiledKotlin/constructor/PrivateConstructor1WithParamDefaultValue.kt b/compiler/testData/loadJava/compiledKotlin/constructor/PrivateConstructor1WithParamDefaultValue.kt index a37d4e7ad8b..f6c86821956 100644 --- a/compiler/testData/loadJava/compiledKotlin/constructor/PrivateConstructor1WithParamDefaultValue.kt +++ b/compiler/testData/loadJava/compiledKotlin/constructor/PrivateConstructor1WithParamDefaultValue.kt @@ -1,3 +1,3 @@ package test -class TestConstructor private(p: Int = 1) +class TestConstructor private constructor(p: Int = 1) diff --git a/compiler/testData/loadJava/compiledKotlin/visibility/InternalConstructor.kt b/compiler/testData/loadJava/compiledKotlin/visibility/InternalConstructor.kt index 522101a8bca..2241a68ea18 100644 --- a/compiler/testData/loadJava/compiledKotlin/visibility/InternalConstructor.kt +++ b/compiler/testData/loadJava/compiledKotlin/visibility/InternalConstructor.kt @@ -1,3 +1,3 @@ package test -public class InternalConstructor internal() +public class InternalConstructor internal constructor() diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/AnnotationGenTest.java b/compiler/tests/org/jetbrains/kotlin/codegen/AnnotationGenTest.java index 9a448ab186c..9eb66220640 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/AnnotationGenTest.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/AnnotationGenTest.java @@ -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); diff --git a/idea/testData/intentions/changeVisibility/public/primaryConstructor.kt b/idea/testData/intentions/changeVisibility/public/primaryConstructor.kt index 322e8163e72..6cd8d40f7c9 100644 --- a/idea/testData/intentions/changeVisibility/public/primaryConstructor.kt +++ b/idea/testData/intentions/changeVisibility/public/primaryConstructor.kt @@ -1,2 +1,2 @@ // INTENTION_TEXT: Make public -class C private (val v: Int) \ No newline at end of file +class C private constructor(val v: Int) \ No newline at end of file diff --git a/idea/testData/intentions/changeVisibility/public/primaryConstructor.kt.after b/idea/testData/intentions/changeVisibility/public/primaryConstructor.kt.after index 8d6399bce6e..147d6ae6057 100644 --- a/idea/testData/intentions/changeVisibility/public/primaryConstructor.kt.after +++ b/idea/testData/intentions/changeVisibility/public/primaryConstructor.kt.after @@ -1,2 +1,2 @@ // INTENTION_TEXT: Make public -class C public (val v: Int) \ No newline at end of file +class C public constructor(val v: Int) \ No newline at end of file diff --git a/idea/testData/quickfix/migration/missingConstructorKeyword/manyFilesMuitliple.after.kt b/idea/testData/quickfix/migration/missingConstructorKeyword/manyFilesMuitliple.after.kt index 438f84e0da6..f62c0a567ee 100644 --- a/idea/testData/quickfix/migration/missingConstructorKeyword/manyFilesMuitliple.after.kt +++ b/idea/testData/quickfix/migration/missingConstructorKeyword/manyFilesMuitliple.after.kt @@ -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) diff --git a/idea/testData/quickfix/migration/missingConstructorKeyword/manyFilesMuitliple.before.Main.kt b/idea/testData/quickfix/migration/missingConstructorKeyword/manyFilesMuitliple.before.Main.kt index ff08607318d..bbc90199f08 100644 --- a/idea/testData/quickfix/migration/missingConstructorKeyword/manyFilesMuitliple.before.Main.kt +++ b/idea/testData/quickfix/migration/missingConstructorKeyword/manyFilesMuitliple.before.Main.kt @@ -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) diff --git a/idea/testData/quickfix/modifiers/removeProtectedModifier.kt b/idea/testData/quickfix/modifiers/removeProtectedModifier.kt index 09aa27be5ae..633f449798e 100644 --- a/idea/testData/quickfix/modifiers/removeProtectedModifier.kt +++ b/idea/testData/quickfix/modifiers/removeProtectedModifier.kt @@ -1,5 +1,5 @@ // "Remove 'protected' modifier" "true" -class A private protected () { +class A private protected constructor() { } diff --git a/idea/testData/quickfix/modifiers/removeProtectedModifier.kt.after b/idea/testData/quickfix/modifiers/removeProtectedModifier.kt.after index 06d1d1406c3..cb41cc26b7d 100644 --- a/idea/testData/quickfix/modifiers/removeProtectedModifier.kt.after +++ b/idea/testData/quickfix/modifiers/removeProtectedModifier.kt.after @@ -1,5 +1,5 @@ // "Remove 'protected' modifier" "true" -class A private () { +class A private constructor() { } diff --git a/idea/testData/quickfix/supertypeInitialization/incompleteConstructor.kt b/idea/testData/quickfix/supertypeInitialization/incompleteConstructor.kt index 99541d57c07..dbe8ed1a8e2 100644 --- a/idea/testData/quickfix/supertypeInitialization/incompleteConstructor.kt +++ b/idea/testData/quickfix/supertypeInitialization/incompleteConstructor.kt @@ -1,4 +1,4 @@ // "Add constructor parameters from Base(Int, Int)" "true" open class Base(p1: Int, val p2: Int) -class C private : Base \ No newline at end of file +class C private constructor : Base \ No newline at end of file diff --git a/idea/testData/quickfix/supertypeInitialization/incompleteConstructor.kt.after b/idea/testData/quickfix/supertypeInitialization/incompleteConstructor.kt.after index 3cd783ad4e3..f8dcf5499a2 100644 --- a/idea/testData/quickfix/supertypeInitialization/incompleteConstructor.kt.after +++ b/idea/testData/quickfix/supertypeInitialization/incompleteConstructor.kt.after @@ -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(p1, p2) \ No newline at end of file +class C private constructor(p1: Int, p2: Int) : Base(p1, p2) \ No newline at end of file diff --git a/idea/testData/quickfix/supertypeInitialization/noAccessibleConstructors.kt b/idea/testData/quickfix/supertypeInitialization/noAccessibleConstructors.kt index 75820c038fd..319a116dc75 100644 --- a/idea/testData/quickfix/supertypeInitialization/noAccessibleConstructors.kt +++ b/idea/testData/quickfix/supertypeInitialization/noAccessibleConstructors.kt @@ -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 diff --git a/idea/testData/quickfix/supertypeInitialization/primaryConstructorInaccessible.kt b/idea/testData/quickfix/supertypeInitialization/primaryConstructorInaccessible.kt index e51f67afa26..67e71e7d938 100644 --- a/idea/testData/quickfix/supertypeInitialization/primaryConstructorInaccessible.kt +++ b/idea/testData/quickfix/supertypeInitialization/primaryConstructorInaccessible.kt @@ -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) } diff --git a/idea/testData/quickfix/supertypeInitialization/primaryConstructorInaccessible.kt.after b/idea/testData/quickfix/supertypeInitialization/primaryConstructorInaccessible.kt.after index 56f567a4ef9..159dc4e4743 100644 --- a/idea/testData/quickfix/supertypeInitialization/primaryConstructorInaccessible.kt.after +++ b/idea/testData/quickfix/supertypeInitialization/primaryConstructorInaccessible.kt.after @@ -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) }