Prohibit secondary constructors in traits
This commit is contained in:
@@ -36,9 +36,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static org.jetbrains.kotlin.diagnostics.Errors.MANY_DEFAULT_OBJECTS;
|
import static org.jetbrains.kotlin.diagnostics.Errors.*;
|
||||||
import static org.jetbrains.kotlin.diagnostics.Errors.SECONDARY_CONSTRUCTOR_IN_OBJECT;
|
|
||||||
import static org.jetbrains.kotlin.diagnostics.Errors.UNSUPPORTED;
|
|
||||||
|
|
||||||
public class LazyTopDownAnalyzer {
|
public class LazyTopDownAnalyzer {
|
||||||
private BindingTrace trace;
|
private BindingTrace trace;
|
||||||
@@ -206,6 +204,9 @@ public class LazyTopDownAnalyzer {
|
|||||||
if (DescriptorUtils.isSingletonOrAnonymousObject(classDescriptor)) {
|
if (DescriptorUtils.isSingletonOrAnonymousObject(classDescriptor)) {
|
||||||
trace.report(SECONDARY_CONSTRUCTOR_IN_OBJECT.on((JetSecondaryConstructor) jetDeclaration));
|
trace.report(SECONDARY_CONSTRUCTOR_IN_OBJECT.on((JetSecondaryConstructor) jetDeclaration));
|
||||||
}
|
}
|
||||||
|
else if (classDescriptor.getKind() == ClassKind.TRAIT) {
|
||||||
|
trace.report(CONSTRUCTOR_IN_TRAIT.on(jetDeclaration));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
trait A {
|
||||||
|
<!CONSTRUCTOR_IN_TRAIT!>constructor() {}<!>
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
internal trait A {
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
@@ -10421,6 +10421,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("constructorInTrait.kt")
|
||||||
|
public void testConstructorInTrait() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/secondaryConstructors/constructorInTrait.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("cyclicDelegationCalls.kt")
|
@TestMetadata("cyclicDelegationCalls.kt")
|
||||||
public void testCyclicDelegationCalls() throws Exception {
|
public void testCyclicDelegationCalls() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/secondaryConstructors/cyclicDelegationCalls.kt");
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/secondaryConstructors/cyclicDelegationCalls.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user