Revert "Generate descriptor for trait constructor. Exception is thrown otherwise (EA-38416)"
This reverts commit 6ba120bba8.
This commit is contained in:
+23
-20
@@ -274,28 +274,25 @@ public open class LazyClassMemberScope(
|
|||||||
public fun getPrimaryConstructor(): ConstructorDescriptor? = primaryConstructor()
|
public fun getPrimaryConstructor(): ConstructorDescriptor? = primaryConstructor()
|
||||||
|
|
||||||
protected open fun resolvePrimaryConstructor(): ConstructorDescriptor? {
|
protected open fun resolvePrimaryConstructor(): ConstructorDescriptor? {
|
||||||
val ownerInfo = declarationProvider.getOwnerInfo()
|
if (GENERATE_CONSTRUCTORS_FOR.contains(thisDescriptor.getKind())) {
|
||||||
val classOrObject = ownerInfo.getCorrespondingClassOrObject()
|
val ownerInfo = declarationProvider.getOwnerInfo()
|
||||||
if (!thisDescriptor.getKind().isSingleton() && !classOrObject.isObjectLiteral()) {
|
val classOrObject = ownerInfo.getCorrespondingClassOrObject()
|
||||||
assert(classOrObject is JetClass) { "No JetClass for $thisDescriptor" }
|
if (!thisDescriptor.getKind().isSingleton() && !classOrObject.isObjectLiteral()) {
|
||||||
classOrObject as JetClass
|
assert(classOrObject is JetClass) { "No JetClass for $thisDescriptor" }
|
||||||
|
classOrObject as JetClass
|
||||||
if (DescriptorUtils.isTrait(thisDescriptor) && declarationProvider.getOwnerInfo().getPrimaryConstructorParameters().isEmpty()) {
|
val constructor = c.descriptorResolver.resolvePrimaryConstructorDescriptor(
|
||||||
return null
|
thisDescriptor.getScopeForClassHeaderResolution(), thisDescriptor, classOrObject, trace)
|
||||||
|
constructor ?: return null
|
||||||
|
setDeferredReturnType(constructor)
|
||||||
|
return constructor
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
val constructor = DescriptorResolver.createAndRecordPrimaryConstructorForObject(classOrObject, thisDescriptor, trace)
|
||||||
|
setDeferredReturnType(constructor)
|
||||||
|
return constructor
|
||||||
}
|
}
|
||||||
|
|
||||||
val constructor = c.descriptorResolver.resolvePrimaryConstructorDescriptor(
|
|
||||||
thisDescriptor.getScopeForClassHeaderResolution(), thisDescriptor, classOrObject, trace)
|
|
||||||
|
|
||||||
assert(constructor != null) { "No constructor created for $thisDescriptor" }
|
|
||||||
setDeferredReturnType(constructor)
|
|
||||||
return constructor
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
val constructor = DescriptorResolver.createAndRecordPrimaryConstructorForObject(classOrObject, thisDescriptor, trace)
|
|
||||||
setDeferredReturnType(constructor)
|
|
||||||
return constructor
|
|
||||||
}
|
}
|
||||||
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun resolveSecondaryConstructors(): Collection<ConstructorDescriptor> {
|
private fun resolveSecondaryConstructors(): Collection<ConstructorDescriptor> {
|
||||||
@@ -321,6 +318,12 @@ public open class LazyClassMemberScope(
|
|||||||
override fun toString() = "lazy scope for class ${thisDescriptor.getName()}"
|
override fun toString() = "lazy scope for class ${thisDescriptor.getName()}"
|
||||||
|
|
||||||
default object {
|
default object {
|
||||||
|
private val GENERATE_CONSTRUCTORS_FOR = setOf(ClassKind.CLASS,
|
||||||
|
ClassKind.ANNOTATION_CLASS,
|
||||||
|
ClassKind.OBJECT,
|
||||||
|
ClassKind.ENUM_CLASS,
|
||||||
|
ClassKind.ENUM_ENTRY)
|
||||||
|
|
||||||
private val EXTRACT_FUNCTIONS: MemberExtractor<FunctionDescriptor> = object : MemberExtractor<FunctionDescriptor> {
|
private val EXTRACT_FUNCTIONS: MemberExtractor<FunctionDescriptor> = object : MemberExtractor<FunctionDescriptor> {
|
||||||
override fun extract(extractFrom: JetType, name: Name): Collection<FunctionDescriptor> {
|
override fun extract(extractFrom: JetType, name: Name): Collection<FunctionDescriptor> {
|
||||||
return extractFrom.getMemberScope().getFunctions(name)
|
return extractFrom.getMemberScope().getFunctions(name)
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
class C(val a: String) {}
|
|
||||||
|
|
||||||
trait T1<!CONSTRUCTOR_IN_TRAIT!>(val x: String)<!> {}
|
|
||||||
|
|
||||||
trait T2<!CONSTRUCTOR_IN_TRAIT!>()<!> {}
|
|
||||||
|
|
||||||
trait T3<!CONSTRUCTOR_IN_TRAIT!>(<!UNUSED_PARAMETER!>a<!>: Int)<!> {}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
package
|
|
||||||
|
|
||||||
internal final class C {
|
|
||||||
public constructor C(/*0*/ a: kotlin.String)
|
|
||||||
internal final val a: kotlin.String
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
internal trait T1 {
|
|
||||||
public constructor T1(/*0*/ x: kotlin.String)
|
|
||||||
internal final val x: kotlin.String
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
internal trait T2 {
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
internal trait T3 {
|
|
||||||
public constructor T3(/*0*/ a: kotlin.Int)
|
|
||||||
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
|
|
||||||
}
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
trait TestTrait(val a: Int, var b: String, c: Double)
|
|
||||||
trait TestTrait()
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
JetFile: TraitConstructor.kt
|
|
||||||
PACKAGE_DIRECTIVE
|
|
||||||
<empty list>
|
|
||||||
CLASS
|
|
||||||
PsiElement(trait)('trait')
|
|
||||||
PsiWhiteSpace(' ')
|
|
||||||
PsiElement(IDENTIFIER)('TestTrait')
|
|
||||||
VALUE_PARAMETER_LIST
|
|
||||||
PsiElement(LPAR)('(')
|
|
||||||
VALUE_PARAMETER
|
|
||||||
PsiElement(val)('val')
|
|
||||||
PsiWhiteSpace(' ')
|
|
||||||
PsiElement(IDENTIFIER)('a')
|
|
||||||
PsiElement(COLON)(':')
|
|
||||||
PsiWhiteSpace(' ')
|
|
||||||
TYPE_REFERENCE
|
|
||||||
USER_TYPE
|
|
||||||
REFERENCE_EXPRESSION
|
|
||||||
PsiElement(IDENTIFIER)('Int')
|
|
||||||
PsiElement(COMMA)(',')
|
|
||||||
PsiWhiteSpace(' ')
|
|
||||||
VALUE_PARAMETER
|
|
||||||
PsiElement(var)('var')
|
|
||||||
PsiWhiteSpace(' ')
|
|
||||||
PsiElement(IDENTIFIER)('b')
|
|
||||||
PsiElement(COLON)(':')
|
|
||||||
PsiWhiteSpace(' ')
|
|
||||||
TYPE_REFERENCE
|
|
||||||
USER_TYPE
|
|
||||||
REFERENCE_EXPRESSION
|
|
||||||
PsiElement(IDENTIFIER)('String')
|
|
||||||
PsiElement(COMMA)(',')
|
|
||||||
PsiWhiteSpace(' ')
|
|
||||||
VALUE_PARAMETER
|
|
||||||
PsiElement(IDENTIFIER)('c')
|
|
||||||
PsiElement(COLON)(':')
|
|
||||||
PsiWhiteSpace(' ')
|
|
||||||
TYPE_REFERENCE
|
|
||||||
USER_TYPE
|
|
||||||
REFERENCE_EXPRESSION
|
|
||||||
PsiElement(IDENTIFIER)('Double')
|
|
||||||
PsiElement(RPAR)(')')
|
|
||||||
PsiWhiteSpace('\n')
|
|
||||||
CLASS
|
|
||||||
PsiElement(trait)('trait')
|
|
||||||
PsiWhiteSpace(' ')
|
|
||||||
PsiElement(IDENTIFIER)('TestTrait')
|
|
||||||
VALUE_PARAMETER_LIST
|
|
||||||
PsiElement(LPAR)('(')
|
|
||||||
PsiElement(RPAR)(')')
|
|
||||||
@@ -563,12 +563,6 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("TraitWithConstructor.kt")
|
|
||||||
public void testTraitWithConstructor() throws Exception {
|
|
||||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/TraitWithConstructor.kt");
|
|
||||||
doTest(fileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("TypeInference.kt")
|
@TestMetadata("TypeInference.kt")
|
||||||
public void testTypeInference() throws Exception {
|
public void testTypeInference() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/TypeInference.kt");
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/TypeInference.kt");
|
||||||
|
|||||||
@@ -543,12 +543,6 @@ public class JetParsingTestGenerated extends AbstractJetParsingTest {
|
|||||||
doParsingTest(fileName);
|
doParsingTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("TraitConstructor.kt")
|
|
||||||
public void testTraitConstructor() throws Exception {
|
|
||||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/TraitConstructor.kt");
|
|
||||||
doParsingTest(fileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("TryRecovery.kt")
|
@TestMetadata("TryRecovery.kt")
|
||||||
public void testTryRecovery() throws Exception {
|
public void testTryRecovery() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/TryRecovery.kt");
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/TryRecovery.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user