[FIR] Avoid AST loading in KtPrimaryConstructor.toFirConstructor
- `getConstructorKeyword` forces an AST load due to a child search. In most cases, we don't need to check the constructor keyword in primary constructors at all (e.g. `class ABC()` with an implicit primary constructor). The keyword check is only needed when there are primary constructor modifiers (e.g. `class ABC constructor()`). Thanks to Dima Gridin for the suggested fix. ^KT-61635 fixed
This commit is contained in:
+2
-2
@@ -1083,9 +1083,9 @@ open class PsiRawFirBuilder(
|
||||
isFromSealedClass = owner.hasModifier(SEALED_KEYWORD) && explicitVisibility !== Visibilities.Private
|
||||
isFromEnumClass = owner.hasModifier(ENUM_KEYWORD)
|
||||
}
|
||||
val hasConstructorKeyword = this@toFirConstructor?.getConstructorKeyword() != null
|
||||
|
||||
val builder = when {
|
||||
this?.modifierList != null && !hasConstructorKeyword -> createErrorConstructorBuilder(ConeMissingConstructorKeyword)
|
||||
this?.modifierList != null && getConstructorKeyword() == null -> createErrorConstructorBuilder(ConeMissingConstructorKeyword)
|
||||
isErrorConstructor -> createErrorConstructorBuilder(ConeNoConstructorError)
|
||||
else -> FirPrimaryConstructorBuilder()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user