Cleanup: apply "Use synthetic property access syntax"
This commit is contained in:
@@ -1326,7 +1326,7 @@ class ControlFlowProcessor(private val trace: BindingTrace) {
|
||||
}
|
||||
|
||||
private fun generateHeaderDelegationSpecifiers(classOrObject: KtClassOrObject) {
|
||||
for (specifier in classOrObject.getSuperTypeListEntries()) {
|
||||
for (specifier in classOrObject.superTypeListEntries) {
|
||||
generateInstructions(specifier)
|
||||
}
|
||||
}
|
||||
@@ -1351,7 +1351,7 @@ class ControlFlowProcessor(private val trace: BindingTrace) {
|
||||
|
||||
override fun visitClass(klass: KtClass) {
|
||||
if (klass.hasPrimaryConstructor()) {
|
||||
processParameters(klass.getPrimaryConstructorParameters())
|
||||
processParameters(klass.primaryConstructorParameters)
|
||||
|
||||
// delegation specifiers of primary constructor, anonymous class and property initializers
|
||||
generateHeaderDelegationSpecifiers(klass)
|
||||
@@ -1379,7 +1379,7 @@ class ControlFlowProcessor(private val trace: BindingTrace) {
|
||||
}
|
||||
|
||||
private fun generateDeclarationForLocalClassOrObjectIfNeeded(classOrObject: KtClassOrObject) {
|
||||
if (classOrObject.isLocal()) {
|
||||
if (classOrObject.isLocal) {
|
||||
for (declaration in classOrObject.declarations) {
|
||||
if (declaration is KtSecondaryConstructor ||
|
||||
declaration is KtProperty ||
|
||||
|
||||
@@ -54,17 +54,17 @@ import org.jetbrains.kotlin.types.TypeUtils
|
||||
import java.util.*
|
||||
|
||||
fun getReceiverTypePredicate(resolvedCall: ResolvedCall<*>, receiverValue: ReceiverValue): TypePredicate? {
|
||||
val callableDescriptor = resolvedCall.getResultingDescriptor() ?: return null
|
||||
val callableDescriptor = resolvedCall.resultingDescriptor ?: return null
|
||||
|
||||
when (receiverValue) {
|
||||
resolvedCall.getExtensionReceiver() -> {
|
||||
val receiverParameter = callableDescriptor.getExtensionReceiverParameter()
|
||||
if (receiverParameter != null) return receiverParameter.getType().getSubtypesPredicate()
|
||||
resolvedCall.extensionReceiver -> {
|
||||
val receiverParameter = callableDescriptor.extensionReceiverParameter
|
||||
if (receiverParameter != null) return receiverParameter.type.getSubtypesPredicate()
|
||||
}
|
||||
resolvedCall.getDispatchReceiver() -> {
|
||||
resolvedCall.dispatchReceiver -> {
|
||||
val rootCallableDescriptors = callableDescriptor.findTopMostOverriddenDescriptors()
|
||||
return or(rootCallableDescriptors.mapNotNull {
|
||||
it.getDispatchReceiverParameter()?.getType()?.let { TypeUtils.makeNullableIfNeeded(it, resolvedCall.call.isSafeCall()) }?.getSubtypesPredicate()
|
||||
it.dispatchReceiverParameter?.type?.let { TypeUtils.makeNullableIfNeeded(it, resolvedCall.call.isSafeCall()) }?.getSubtypesPredicate()
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -90,14 +90,14 @@ fun getExpectedTypePredicate(
|
||||
fun getTypePredicateForUnresolvedCallArgument(to: KtElement, inputValueIndex: Int): TypePredicate? {
|
||||
if (inputValueIndex < 0) return null
|
||||
val call = to.getCall(bindingContext) ?: return null
|
||||
val callee = call.getCalleeExpression() ?: return null
|
||||
val callee = call.calleeExpression ?: return null
|
||||
|
||||
val candidates = callee.getReferenceTargets(bindingContext)
|
||||
.filterIsInstance<FunctionDescriptor>()
|
||||
.sortedBy { DescriptorRenderer.FQ_NAMES_IN_TYPES.render(it) }
|
||||
if (candidates.isEmpty()) return null
|
||||
|
||||
val explicitReceiver = call.getExplicitReceiver()
|
||||
val explicitReceiver = call.explicitReceiver
|
||||
val argValueOffset = if (explicitReceiver != null) 1 else 0
|
||||
|
||||
val predicates = ArrayList<TypePredicate>()
|
||||
@@ -120,10 +120,10 @@ fun getExpectedTypePredicate(
|
||||
TracingStrategy.EMPTY,
|
||||
candidateCall,
|
||||
LinkedHashSet())
|
||||
if (!status.isSuccess()) continue
|
||||
if (!status.isSuccess) continue
|
||||
|
||||
val candidateArgumentMap = candidateCall.getValueArguments()
|
||||
val callArguments = call.getValueArguments()
|
||||
val candidateArgumentMap = candidateCall.valueArguments
|
||||
val callArguments = call.valueArguments
|
||||
val i = inputValueIndex - argValueOffset
|
||||
if (i < 0 || i >= callArguments.size) continue
|
||||
|
||||
@@ -135,7 +135,7 @@ fun getExpectedTypePredicate(
|
||||
val expectedType = if (resolvedArgument is VarargValueArgument)
|
||||
candidateParameter.varargElementType
|
||||
else
|
||||
candidateParameter.getType()
|
||||
candidateParameter.type
|
||||
|
||||
predicates.add(if (expectedType != null) AllSubtypes(expectedType) else AllTypes)
|
||||
}
|
||||
@@ -152,14 +152,14 @@ fun getExpectedTypePredicate(
|
||||
is KtReturnExpression -> returnElement.getTargetFunctionDescriptor(bindingContext)
|
||||
else -> bindingContext[DECLARATION_TO_DESCRIPTOR, pseudocode.correspondingElement]
|
||||
}
|
||||
addSubtypesOf((functionDescriptor as? CallableDescriptor)?.getReturnType())
|
||||
addSubtypesOf((functionDescriptor as? CallableDescriptor)?.returnType)
|
||||
}
|
||||
|
||||
is ConditionalJumpInstruction ->
|
||||
addSubtypesOf(builtIns.getBooleanType())
|
||||
addSubtypesOf(builtIns.booleanType)
|
||||
|
||||
is ThrowExceptionInstruction ->
|
||||
addSubtypesOf(builtIns.getThrowable().getDefaultType())
|
||||
addSubtypesOf(builtIns.throwable.defaultType)
|
||||
|
||||
is MergeInstruction ->
|
||||
addTypePredicates(it.outputValue)
|
||||
@@ -190,11 +190,11 @@ fun getExpectedTypePredicate(
|
||||
}
|
||||
else {
|
||||
it.arguments[value]?.let { parameter ->
|
||||
val expectedType = when (it.resolvedCall.getValueArguments()[parameter]) {
|
||||
val expectedType = when (it.resolvedCall.valueArguments[parameter]) {
|
||||
is VarargValueArgument ->
|
||||
parameter.varargElementType
|
||||
else ->
|
||||
parameter.getType()
|
||||
parameter.type
|
||||
}
|
||||
addSubtypesOf(expectedType)
|
||||
}
|
||||
@@ -203,7 +203,7 @@ fun getExpectedTypePredicate(
|
||||
|
||||
is MagicInstruction -> @Suppress("NON_EXHAUSTIVE_WHEN") when (it.kind) {
|
||||
AND, OR ->
|
||||
addSubtypesOf(builtIns.getBooleanType())
|
||||
addSubtypesOf(builtIns.booleanType)
|
||||
|
||||
LOOP_RANGE_ITERATION ->
|
||||
addByExplicitReceiver(bindingContext[LOOP_RANGE_ITERATOR_RESOLVED_CALL, value.element as? KtExpression])
|
||||
@@ -211,18 +211,18 @@ fun getExpectedTypePredicate(
|
||||
VALUE_CONSUMER -> {
|
||||
val element = it.element
|
||||
when {
|
||||
element.getStrictParentOfType<KtWhileExpression>()?.getCondition() == element ->
|
||||
addSubtypesOf(builtIns.getBooleanType())
|
||||
element.getStrictParentOfType<KtWhileExpression>()?.condition == element ->
|
||||
addSubtypesOf(builtIns.booleanType)
|
||||
|
||||
element is KtProperty -> {
|
||||
val propertyDescriptor = bindingContext[DECLARATION_TO_DESCRIPTOR, element] as? PropertyDescriptor
|
||||
propertyDescriptor?.getAccessors()?.map {
|
||||
propertyDescriptor?.accessors?.map {
|
||||
addByExplicitReceiver(bindingContext[DELEGATED_PROPERTY_RESOLVED_CALL, it])
|
||||
}
|
||||
}
|
||||
|
||||
element is KtDelegatedSuperTypeEntry ->
|
||||
addSubtypesOf(bindingContext[TYPE, element.getTypeReference()])
|
||||
addSubtypesOf(bindingContext[TYPE, element.typeReference])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -256,7 +256,7 @@ fun Instruction.calcSideEffectFree(): Boolean {
|
||||
return when (this) {
|
||||
is ReadValueInstruction -> target.let {
|
||||
when (it) {
|
||||
is AccessTarget.Call -> when (it.resolvedCall.getResultingDescriptor()) {
|
||||
is AccessTarget.Call -> when (it.resolvedCall.resultingDescriptor) {
|
||||
is LocalVariableDescriptor, is ValueParameterDescriptor, is ReceiverParameterDescriptor -> true
|
||||
else -> false
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ object PositioningStrategies {
|
||||
is KtObjectDeclaration -> {
|
||||
return markRange(
|
||||
element.getObjectKeyword()!!,
|
||||
element.getNameIdentifier() ?: element.getObjectKeyword()!!
|
||||
element.nameIdentifier ?: element.getObjectKeyword()!!
|
||||
)
|
||||
}
|
||||
is KtConstructorDelegationCall -> {
|
||||
@@ -86,7 +86,7 @@ object PositioningStrategies {
|
||||
private fun getElementToMark(declaration: KtDeclaration): PsiElement {
|
||||
val (returnTypeRef, nameIdentifierOrPlaceholder) = when (declaration) {
|
||||
is KtCallableDeclaration -> Pair(declaration.typeReference, declaration.nameIdentifier)
|
||||
is KtPropertyAccessor -> Pair(declaration.getReturnTypeReference(), declaration.getNamePlaceholder())
|
||||
is KtPropertyAccessor -> Pair(declaration.returnTypeReference, declaration.namePlaceholder)
|
||||
else -> Pair(null, null)
|
||||
}
|
||||
|
||||
@@ -127,9 +127,9 @@ object PositioningStrategies {
|
||||
}
|
||||
is KtFunction -> {
|
||||
val endOfSignatureElement =
|
||||
element.getTypeReference()
|
||||
?: element.getValueParameterList()
|
||||
?: element.getNameIdentifier()
|
||||
element.typeReference
|
||||
?: element.valueParameterList
|
||||
?: element.nameIdentifier
|
||||
?: element
|
||||
val startElement
|
||||
= if (element is KtFunctionLiteral) {
|
||||
@@ -141,19 +141,19 @@ object PositioningStrategies {
|
||||
return markRange(startElement, endOfSignatureElement)
|
||||
}
|
||||
is KtProperty -> {
|
||||
val endOfSignatureElement = element.getTypeReference() ?: element.getNameIdentifier() ?: element
|
||||
val endOfSignatureElement = element.typeReference ?: element.nameIdentifier ?: element
|
||||
return markRange(element, endOfSignatureElement)
|
||||
}
|
||||
is KtPropertyAccessor -> {
|
||||
val endOfSignatureElement =
|
||||
element.getReturnTypeReference()
|
||||
?: element.getRightParenthesis()?.getPsi()
|
||||
?: element.getNamePlaceholder()
|
||||
element.returnTypeReference
|
||||
?: element.rightParenthesis?.psi
|
||||
?: element.namePlaceholder
|
||||
|
||||
return markRange(element, endOfSignatureElement)
|
||||
}
|
||||
is KtClass -> {
|
||||
val nameAsDeclaration = element.getNameIdentifier() ?: return markElement(element)
|
||||
val nameAsDeclaration = element.nameIdentifier ?: return markElement(element)
|
||||
val primaryConstructorParameterList = element.getPrimaryConstructorParameterList() ?: return markElement(nameAsDeclaration)
|
||||
return markRange(nameAsDeclaration, primaryConstructorParameterList)
|
||||
}
|
||||
@@ -212,7 +212,7 @@ object PositioningStrategies {
|
||||
override fun mark(element: PsiElement): List<TextRange> {
|
||||
val nameIdentifier = when (element) {
|
||||
is KtNamedDeclaration -> element.nameIdentifier
|
||||
is KtFile -> element.packageDirective!!.getNameIdentifier()
|
||||
is KtFile -> element.packageDirective!!.nameIdentifier
|
||||
else -> null
|
||||
}
|
||||
|
||||
@@ -260,7 +260,7 @@ object PositioningStrategies {
|
||||
val visibilityTokens = listOf(KtTokens.PRIVATE_KEYWORD, KtTokens.PROTECTED_KEYWORD, KtTokens.PUBLIC_KEYWORD, KtTokens.INTERNAL_KEYWORD)
|
||||
val modifierList = element.modifierList
|
||||
|
||||
val result = visibilityTokens.mapNotNull { modifierList?.getModifier(it)?.getTextRange() }
|
||||
val result = visibilityTokens.mapNotNull { modifierList?.getModifier(it)?.textRange }
|
||||
if (!result.isEmpty()) return result
|
||||
|
||||
// Try to resolve situation when there's no visibility modifiers written before element
|
||||
@@ -273,10 +273,10 @@ object PositioningStrategies {
|
||||
|
||||
val elementToMark = when (element) {
|
||||
is KtObjectDeclaration -> element.getObjectKeyword()!!
|
||||
is KtPropertyAccessor -> element.getNamePlaceholder()
|
||||
is KtPropertyAccessor -> element.namePlaceholder
|
||||
is KtAnonymousInitializer -> element
|
||||
else -> throw IllegalArgumentException(
|
||||
"Can't find text range for element '${element.javaClass.getCanonicalName()}' with the text '${element.getText()}'")
|
||||
"Can't find text range for element '${element.javaClass.canonicalName}' with the text '${element.text}'")
|
||||
}
|
||||
return markElement(elementToMark)
|
||||
}
|
||||
@@ -284,13 +284,13 @@ object PositioningStrategies {
|
||||
|
||||
@JvmField val VARIANCE_IN_PROJECTION: PositioningStrategy<KtTypeProjection> = object : PositioningStrategy<KtTypeProjection>() {
|
||||
override fun mark(element: KtTypeProjection): List<TextRange> {
|
||||
return markElement(element.getProjectionToken()!!)
|
||||
return markElement(element.projectionToken!!)
|
||||
}
|
||||
}
|
||||
|
||||
@JvmField val PARAMETER_DEFAULT_VALUE: PositioningStrategy<KtParameter> = object : PositioningStrategy<KtParameter>() {
|
||||
override fun mark(element: KtParameter): List<TextRange> {
|
||||
return markNode(element.getDefaultValue()!!.node)
|
||||
return markNode(element.defaultValue!!.node)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -309,7 +309,7 @@ object PositioningStrategies {
|
||||
|
||||
@JvmField val DECLARATION_WITH_BODY: PositioningStrategy<KtDeclarationWithBody> = object : PositioningStrategy<KtDeclarationWithBody>() {
|
||||
override fun mark(element: KtDeclarationWithBody): List<TextRange> {
|
||||
val lastBracketRange = (element.bodyExpression as? KtBlockExpression)?.getLastBracketRange()
|
||||
val lastBracketRange = (element.bodyExpression as? KtBlockExpression)?.lastBracketRange
|
||||
return if (lastBracketRange != null)
|
||||
markRange(lastBracketRange)
|
||||
else
|
||||
@@ -317,7 +317,7 @@ object PositioningStrategies {
|
||||
}
|
||||
|
||||
override fun isValid(element: KtDeclarationWithBody): Boolean {
|
||||
return super.isValid(element) && (element.bodyExpression as? KtBlockExpression)?.getLastBracketRange() != null
|
||||
return super.isValid(element) && (element.bodyExpression as? KtBlockExpression)?.lastBracketRange != null
|
||||
}
|
||||
}
|
||||
|
||||
@@ -361,14 +361,14 @@ object PositioningStrategies {
|
||||
|
||||
@JvmField val NULLABLE_TYPE: PositioningStrategy<KtNullableType> = object : PositioningStrategy<KtNullableType>() {
|
||||
override fun mark(element: KtNullableType): List<TextRange> {
|
||||
return markNode(element.getQuestionMarkNode())
|
||||
return markNode(element.questionMarkNode)
|
||||
}
|
||||
}
|
||||
|
||||
@JvmField val CALL_EXPRESSION: PositioningStrategy<PsiElement> = object : PositioningStrategy<PsiElement>() {
|
||||
override fun mark(element: PsiElement): List<TextRange> {
|
||||
if (element is KtCallExpression) {
|
||||
return markRange(element, element.getTypeArgumentList() ?: element.getCalleeExpression() ?: element)
|
||||
return markRange(element, element.typeArgumentList ?: element.calleeExpression ?: element)
|
||||
}
|
||||
return markElement(element)
|
||||
}
|
||||
@@ -387,7 +387,7 @@ object PositioningStrategies {
|
||||
return markElement(valueParameterList)
|
||||
}
|
||||
if (element is KtFunctionLiteral) {
|
||||
return markNode(element.getLBrace().node)
|
||||
return markNode(element.lBrace.node)
|
||||
}
|
||||
return DECLARATION_SIGNATURE_OR_DEFAULT.mark(element)
|
||||
}
|
||||
@@ -419,7 +419,7 @@ object PositioningStrategies {
|
||||
|
||||
@JvmField val UNREACHABLE_CODE: PositioningStrategy<PsiElement> = object : PositioningStrategy<PsiElement>() {
|
||||
override fun markDiagnostic(diagnostic: ParametrizedDiagnostic<out PsiElement>): List<TextRange> {
|
||||
return Errors.UNREACHABLE_CODE.cast(diagnostic).getA()
|
||||
return Errors.UNREACHABLE_CODE.cast(diagnostic).a
|
||||
}
|
||||
}
|
||||
|
||||
@@ -443,8 +443,8 @@ object PositioningStrategies {
|
||||
override fun mark(element: KtConstructorDelegationCall): List<TextRange> {
|
||||
if (element.isImplicit) {
|
||||
val constructor = element.getStrictParentOfType<KtSecondaryConstructor>()!!
|
||||
val valueParameterList = constructor.getValueParameterList() ?: return markElement(constructor)
|
||||
return markRange(constructor.getConstructorKeyword(), valueParameterList.getLastChild())
|
||||
val valueParameterList = constructor.valueParameterList ?: return markElement(constructor)
|
||||
return markRange(constructor.getConstructorKeyword(), valueParameterList.lastChild)
|
||||
}
|
||||
return markElement(element.calleeExpression ?: element)
|
||||
}
|
||||
@@ -452,7 +452,7 @@ object PositioningStrategies {
|
||||
|
||||
@JvmField val DELEGATOR_SUPER_CALL: PositioningStrategy<KtEnumEntry> = object: PositioningStrategy<KtEnumEntry>() {
|
||||
override fun mark(element: KtEnumEntry): List<TextRange> {
|
||||
val specifiers = element.getSuperTypeListEntries()
|
||||
val specifiers = element.superTypeListEntries
|
||||
return markElement(if (specifiers.isEmpty()) element else specifiers[0])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ object Renderers {
|
||||
|
||||
@JvmField val RENDER_CLASS_OR_OBJECT = Renderer {
|
||||
classOrObject: KtClassOrObject ->
|
||||
val name = if (classOrObject.getName() != null) " '" + classOrObject.getName() + "'" else ""
|
||||
val name = if (classOrObject.name != null) " '" + classOrObject.name + "'" else ""
|
||||
if (classOrObject is KtClass) "Class" + name else "Object" + name
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ class KotlinLookupLocation(val element: KtElement) : LookupLocation {
|
||||
|
||||
override val location: LocationInfo?
|
||||
get() {
|
||||
val containingJetFile = element.getContainingKtFile()
|
||||
val containingJetFile = element.containingKtFile
|
||||
|
||||
if (containingJetFile.doNotAnalyze != null) return null
|
||||
|
||||
|
||||
@@ -42,13 +42,13 @@ class KDocImpl(buffer: CharSequence?) : LazyParseablePsiElement(KDocTokens.KDOC,
|
||||
override fun getDefaultSection(): KDocSection = getChildOfType<KDocSection>()!!
|
||||
|
||||
override fun findSectionByName(name: String): KDocSection? =
|
||||
getChildrenOfType<KDocSection>().firstOrNull { it.getName() == name }
|
||||
getChildrenOfType<KDocSection>().firstOrNull { it.name == name }
|
||||
|
||||
override fun findSectionByTag(tag: KDocKnownTag): KDocSection? =
|
||||
findSectionByName(tag.name.toLowerCase())
|
||||
|
||||
override fun findSectionByTag(tag: KDocKnownTag, subjectName: String): KDocSection? =
|
||||
getChildrenOfType<KDocSection>().firstOrNull {
|
||||
it.getName() == tag.name.toLowerCase() && it.getSubjectName() == subjectName
|
||||
it.name == tag.name.toLowerCase() && it.getSubjectName() == subjectName
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ class KDocSection(node: ASTNode) : KDocTag(node) {
|
||||
(firstChild as? KDocTag)?.getContent() ?: super.getContent()
|
||||
|
||||
fun findTagsByName(name: String): List<KDocTag> {
|
||||
return getChildrenOfType<KDocTag>().filter { it.getName() == name }
|
||||
return getChildrenOfType<KDocTag>().filter { it.name == name }
|
||||
}
|
||||
|
||||
fun findTagByName(name: String): KDocTag?
|
||||
|
||||
@@ -203,7 +203,7 @@ private object DebugTextBuildingVisitor : KtVisitor<String, Unit>() {
|
||||
append("class ")
|
||||
appendInn(klass.nameAsName)
|
||||
appendInn(klass.typeParameterList)
|
||||
appendInn(klass.getPrimaryConstructorModifierList(), prefix = " ", suffix = " ")
|
||||
appendInn(klass.primaryConstructorModifierList, prefix = " ", suffix = " ")
|
||||
appendInn(klass.getPrimaryConstructorParameterList())
|
||||
appendInn(klass.getSuperTypeList(), prefix = " : ")
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ abstract class KtClassOrObject :
|
||||
|
||||
override fun hasPrimaryConstructor(): Boolean = hasExplicitPrimaryConstructor() || !hasSecondaryConstructors()
|
||||
|
||||
private fun hasSecondaryConstructors(): Boolean = !getSecondaryConstructors().isEmpty()
|
||||
private fun hasSecondaryConstructors(): Boolean = !secondaryConstructors.isEmpty()
|
||||
|
||||
override fun getSecondaryConstructors(): List<KtSecondaryConstructor> = getBody()?.secondaryConstructors.orEmpty()
|
||||
|
||||
|
||||
@@ -160,12 +160,12 @@ abstract class KtCodeFragment(
|
||||
}
|
||||
|
||||
fun getContextContainingFile(): KtFile? {
|
||||
return (getOriginalContext() as? KtElement)?.getContainingKtFile()
|
||||
return (getOriginalContext() as? KtElement)?.containingKtFile
|
||||
}
|
||||
|
||||
fun getOriginalContext(): KtElement? {
|
||||
val contextElement = getContext() as? KtElement
|
||||
val contextFile = contextElement?.getContainingKtFile()
|
||||
val contextFile = contextElement?.containingKtFile
|
||||
if (contextFile is KtCodeFragment) {
|
||||
return contextFile.getOriginalContext()
|
||||
}
|
||||
|
||||
@@ -173,7 +173,7 @@ fun <TElement : KtElement> createByPattern(pattern: String, vararg args: Any, fa
|
||||
for ((pointer, n) in pointers) {
|
||||
var element = pointer.element!!
|
||||
if (element is KtFunctionLiteral) {
|
||||
element = element.getParent() as KtLambdaExpression
|
||||
element = element.parent as KtLambdaExpression
|
||||
}
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
val argumentType = argumentTypes[n] as PsiElementPlaceholderArgumentType<in Any, in PsiElement>
|
||||
|
||||
@@ -102,7 +102,7 @@ fun KtSimpleNameExpression.getReceiverExpression(): KtExpression? {
|
||||
parent is KtCallExpression -> {
|
||||
//This is in case `a().b()`
|
||||
val callExpression = parent
|
||||
val grandParent = callExpression.getParent()
|
||||
val grandParent = callExpression.parent
|
||||
if (grandParent is KtQualifiedExpression) {
|
||||
val parentsReceiver = grandParent.receiverExpression
|
||||
if (parentsReceiver != callExpression) {
|
||||
@@ -226,7 +226,7 @@ fun StubBasedPsiElementBase<out KotlinClassOrObjectStub<out KtClassOrObject>>.ge
|
||||
return stub.getSuperNames()
|
||||
}
|
||||
|
||||
val specifiers = (this as KtClassOrObject).getSuperTypeListEntries()
|
||||
val specifiers = (this as KtClassOrObject).superTypeListEntries
|
||||
if (specifiers.isEmpty()) return Collections.emptyList<String>()
|
||||
|
||||
val result = ArrayList<String>()
|
||||
@@ -488,7 +488,7 @@ fun KtElement.containingClass(): KtClass? = getStrictParentOfType()
|
||||
|
||||
fun KtClassOrObject.findPropertyByName(name: String): KtNamedDeclaration? {
|
||||
return declarations.firstOrNull { it is KtProperty && it.name == name } as KtNamedDeclaration?
|
||||
?: getPrimaryConstructorParameters().firstOrNull { it.hasValOrVar() && it.name == name }
|
||||
?: primaryConstructorParameters.firstOrNull { it.hasValOrVar() && it.name == name }
|
||||
}
|
||||
|
||||
fun isTypeConstructorReference(e: PsiElement): Boolean {
|
||||
|
||||
@@ -296,7 +296,7 @@ class DeclarationsChecker(
|
||||
private fun checkTypesInClassHeader(classOrObject: KtClassOrObject) {
|
||||
fun KtTypeReference.type(): KotlinType? = trace.bindingContext.get(TYPE, this)
|
||||
|
||||
for (delegationSpecifier in classOrObject.getSuperTypeListEntries()) {
|
||||
for (delegationSpecifier in classOrObject.superTypeListEntries) {
|
||||
val typeReference = delegationSpecifier.typeReference ?: continue
|
||||
typeReference.type()?.let { DescriptorResolver.checkBounds(typeReference, it, trace) }
|
||||
}
|
||||
@@ -397,7 +397,7 @@ class DeclarationsChecker(
|
||||
|
||||
private fun checkObject(declaration: KtObjectDeclaration, classDescriptor: ClassDescriptorWithResolutionScopes) {
|
||||
checkOpenMembers(classDescriptor)
|
||||
if (declaration.isLocal() && !declaration.isCompanion() && !declaration.isObjectLiteral()) {
|
||||
if (declaration.isLocal && !declaration.isCompanion() && !declaration.isObjectLiteral()) {
|
||||
trace.report(LOCAL_OBJECT_NOT_ALLOWED.on(declaration, classDescriptor))
|
||||
}
|
||||
}
|
||||
@@ -412,7 +412,7 @@ class DeclarationsChecker(
|
||||
if (aClass.isInterface()) {
|
||||
checkConstructorInInterface(aClass)
|
||||
checkMethodsOfAnyInInterface(classDescriptor)
|
||||
if (aClass.isLocal() && classDescriptor.containingDeclaration !is ClassDescriptor) {
|
||||
if (aClass.isLocal && classDescriptor.containingDeclaration !is ClassDescriptor) {
|
||||
trace.report(LOCAL_INTERFACE_NOT_ALLOWED.on(aClass, classDescriptor))
|
||||
}
|
||||
}
|
||||
@@ -427,7 +427,7 @@ class DeclarationsChecker(
|
||||
|
||||
private fun checkPrimaryConstructor(classOrObject: KtClassOrObject, classDescriptor: ClassDescriptor) {
|
||||
val primaryConstructor = classDescriptor.unsubstitutedPrimaryConstructor ?: return
|
||||
val declaration = classOrObject.getPrimaryConstructor() ?: return
|
||||
val declaration = classOrObject.primaryConstructor ?: return
|
||||
|
||||
for (parameter in declaration.valueParameters) {
|
||||
trace.get(BindingContext.PRIMARY_CONSTRUCTOR_PARAMETER, parameter)?.let {
|
||||
@@ -471,7 +471,7 @@ class DeclarationsChecker(
|
||||
}
|
||||
|
||||
private fun checkConstructorInInterface(klass: KtClass) {
|
||||
klass.getPrimaryConstructor()?.let { trace.report(CONSTRUCTOR_IN_INTERFACE.on(it)) }
|
||||
klass.primaryConstructor?.let { trace.report(CONSTRUCTOR_IN_INTERFACE.on(it)) }
|
||||
}
|
||||
|
||||
private fun checkMethodsOfAnyInInterface(classDescriptor: ClassDescriptorWithResolutionScopes) {
|
||||
@@ -494,7 +494,7 @@ class DeclarationsChecker(
|
||||
}
|
||||
|
||||
private fun checkValOnAnnotationParameter(aClass: KtClass) {
|
||||
for (parameter in aClass.getPrimaryConstructorParameters()) {
|
||||
for (parameter in aClass.primaryConstructorParameters) {
|
||||
if (!parameter.hasValOrVar()) {
|
||||
trace.report(MISSING_VAL_ON_ANNOTATION_PARAMETER.on(parameter))
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ class DelegationResolver<T : CallableMemberDescriptor> private constructor(
|
||||
|
||||
private fun generateDelegatedMembers(): Collection<T> {
|
||||
val delegatedMembers = hashSetOf<T>()
|
||||
for (delegationSpecifier in classOrObject.getSuperTypeListEntries()) {
|
||||
for (delegationSpecifier in classOrObject.superTypeListEntries) {
|
||||
if (delegationSpecifier !is KtDelegatedSuperTypeEntry) {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ class ExposedVisibilityChecker(private val trace: DiagnosticSink = DO_NOTHING) {
|
||||
var result = checkSupertypes(klass, classDescriptor)
|
||||
result = result and checkParameterBounds(klass, classDescriptor)
|
||||
|
||||
val constructor = klass.getPrimaryConstructor() ?: return result
|
||||
val constructor = klass.primaryConstructor ?: return result
|
||||
val constructorDescriptor = classDescriptor.unsubstitutedPrimaryConstructor ?: return result
|
||||
return result and checkFunction(constructor, constructorDescriptor)
|
||||
}
|
||||
@@ -122,7 +122,7 @@ class ExposedVisibilityChecker(private val trace: DiagnosticSink = DO_NOTHING) {
|
||||
private fun checkSupertypes(klass: KtClassOrObject, classDescriptor: ClassDescriptor): Boolean {
|
||||
val classVisibility = classDescriptor.effectiveVisibility()
|
||||
val isInterface = classDescriptor.kind == ClassKind.INTERFACE
|
||||
val delegationList = klass.getSuperTypeListEntries()
|
||||
val delegationList = klass.superTypeListEntries
|
||||
var result = true
|
||||
classDescriptor.typeConstructor.supertypes.forEachIndexed { i, superType ->
|
||||
if (i >= delegationList.size) return result
|
||||
|
||||
@@ -100,8 +100,8 @@ class FunctionDescriptorResolver(
|
||||
): SimpleFunctionDescriptor {
|
||||
val functionDescriptor = functionConstructor(
|
||||
containingDescriptor,
|
||||
annotationResolver.resolveAnnotationsWithoutArguments(scope, function.getModifierList(), trace),
|
||||
function.getNameAsSafeName(),
|
||||
annotationResolver.resolveAnnotationsWithoutArguments(scope, function.modifierList, trace),
|
||||
function.nameAsSafeName,
|
||||
CallableMemberDescriptor.Kind.DECLARATION,
|
||||
function.toSourceElement()
|
||||
)
|
||||
@@ -119,8 +119,8 @@ class FunctionDescriptorResolver(
|
||||
dataFlowInfo: DataFlowInfo
|
||||
) {
|
||||
if (functionDescriptor.returnType != null) return
|
||||
assert(function.getTypeReference() == null) {
|
||||
"Return type must be initialized early for function: " + function.getText() + ", at: " + DiagnosticUtils.atLocation(function) }
|
||||
assert(function.typeReference == null) {
|
||||
"Return type must be initialized early for function: " + function.text + ", at: " + DiagnosticUtils.atLocation(function) }
|
||||
|
||||
val returnType = if (function.hasBlockBody()) {
|
||||
builtIns.unitType
|
||||
@@ -251,14 +251,14 @@ class FunctionDescriptorResolver(
|
||||
classElement: KtPureClassOrObject,
|
||||
trace: BindingTrace
|
||||
): ClassConstructorDescriptorImpl? {
|
||||
if (classDescriptor.getKind() == ClassKind.ENUM_ENTRY || !classElement.hasPrimaryConstructor()) return null
|
||||
if (classDescriptor.kind == ClassKind.ENUM_ENTRY || !classElement.hasPrimaryConstructor()) return null
|
||||
return createConstructorDescriptor(
|
||||
scope,
|
||||
classDescriptor,
|
||||
true,
|
||||
classElement.getPrimaryConstructorModifierList(),
|
||||
classElement.getPrimaryConstructor() ?: classElement,
|
||||
classElement.getPrimaryConstructorParameters(),
|
||||
classElement.primaryConstructorModifierList,
|
||||
classElement.primaryConstructor ?: classElement,
|
||||
classElement.primaryConstructorParameters,
|
||||
trace
|
||||
)
|
||||
}
|
||||
@@ -273,9 +273,9 @@ class FunctionDescriptorResolver(
|
||||
scope,
|
||||
classDescriptor,
|
||||
false,
|
||||
constructor.getModifierList(),
|
||||
constructor.modifierList,
|
||||
constructor,
|
||||
constructor.getValueParameters(),
|
||||
constructor.valueParameters,
|
||||
trace
|
||||
)
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ class LazyTopDownAnalyzer(
|
||||
}
|
||||
|
||||
override fun visitImportDirective(importDirective: KtImportDirective) {
|
||||
val importResolver = fileScopeProvider.getImportResolver(importDirective.getContainingKtFile())
|
||||
val importResolver = fileScopeProvider.getImportResolver(importDirective.containingKtFile)
|
||||
importResolver.forceResolveImport(importDirective)
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ class LazyTopDownAnalyzer(
|
||||
}
|
||||
|
||||
private fun registerPrimaryConstructorParameters(klass: KtClass) {
|
||||
for (jetParameter in klass.getPrimaryConstructorParameters()) {
|
||||
for (jetParameter in klass.primaryConstructorParameters) {
|
||||
if (jetParameter.hasValOrVar()) {
|
||||
c.primaryConstructorParameterProperties.put(jetParameter, lazyDeclarationResolver.resolveToDescriptor(jetParameter) as PropertyDescriptor)
|
||||
}
|
||||
@@ -222,7 +222,7 @@ class LazyTopDownAnalyzer(
|
||||
}
|
||||
|
||||
private fun resolveImportsInAllFiles(c: TopDownAnalysisContext) {
|
||||
for (file in c.files + c.scripts.keys.map { it.getContainingKtFile() }) {
|
||||
for (file in c.files + c.scripts.keys.map { it.containingKtFile }) {
|
||||
fileScopeProvider.getImportResolver(file).forceResolveAllImports()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,7 +182,7 @@ class QualifiedExpressionResolver {
|
||||
when {
|
||||
importDirective.suppressDiagnosticsInDebugMode() -> null
|
||||
packageFragmentForVisibilityCheck is DeclarationDescriptorWithSource && packageFragmentForVisibilityCheck.source == SourceElement.NO_SOURCE -> {
|
||||
PackageFragmentWithCustomSource(packageFragmentForVisibilityCheck, KotlinSourceElement(importDirective.getContainingKtFile()))
|
||||
PackageFragmentWithCustomSource(packageFragmentForVisibilityCheck, KotlinSourceElement(importDirective.containingKtFile))
|
||||
}
|
||||
else -> packageFragmentForVisibilityCheck
|
||||
}
|
||||
@@ -601,7 +601,7 @@ class QualifiedExpressionResolver {
|
||||
if (descriptor is DeclarationDescriptorWithVisibility) {
|
||||
val fromToCheck =
|
||||
if (shouldBeVisibleFrom is PackageFragmentDescriptor && shouldBeVisibleFrom.source == SourceElement.NO_SOURCE && referenceExpression.containingFile !is DummyHolder) {
|
||||
PackageFragmentWithCustomSource(shouldBeVisibleFrom, KotlinSourceElement(referenceExpression.getContainingKtFile()))
|
||||
PackageFragmentWithCustomSource(shouldBeVisibleFrom, KotlinSourceElement(referenceExpression.containingKtFile))
|
||||
}
|
||||
else {
|
||||
shouldBeVisibleFrom
|
||||
|
||||
@@ -101,11 +101,11 @@ class TypeResolver(
|
||||
|
||||
private fun resolveType(c: TypeResolutionContext, typeReference: KtTypeReference): KotlinType {
|
||||
assert(!c.allowBareTypes) { "Use resolvePossiblyBareType() when bare types are allowed" }
|
||||
return resolvePossiblyBareType(c, typeReference).getActualType()
|
||||
return resolvePossiblyBareType(c, typeReference).actualType
|
||||
}
|
||||
|
||||
fun resolvePossiblyBareType(c: TypeResolutionContext, typeReference: KtTypeReference): PossiblyBareType {
|
||||
val cachedType = c.trace.getBindingContext().get(BindingContext.TYPE, typeReference)
|
||||
val cachedType = c.trace.bindingContext.get(BindingContext.TYPE, typeReference)
|
||||
if (cachedType != null) return type(cachedType)
|
||||
|
||||
val resolvedTypeSlice = if (c.abbreviated) BindingContext.ABBREVIATED_TYPE else BindingContext.TYPE
|
||||
@@ -120,15 +120,15 @@ class TypeResolver(
|
||||
// Bare types can be allowed only inside expressions; lazy type resolution is only relevant for declarations
|
||||
|
||||
val lazyKotlinType = LazyWrappedType(storageManager) {
|
||||
doResolvePossiblyBareType(c, typeReference).getActualType()
|
||||
doResolvePossiblyBareType(c, typeReference).actualType
|
||||
}
|
||||
c.trace.record(resolvedTypeSlice, typeReference, lazyKotlinType)
|
||||
return type(lazyKotlinType)
|
||||
}
|
||||
|
||||
val type = doResolvePossiblyBareType(c, typeReference)
|
||||
if (!type.isBare()) {
|
||||
c.trace.record(resolvedTypeSlice, typeReference, type.getActualType())
|
||||
if (!type.isBare) {
|
||||
c.trace.record(resolvedTypeSlice, typeReference, type.actualType)
|
||||
}
|
||||
return type
|
||||
}
|
||||
@@ -820,7 +820,7 @@ class TypeResolver(
|
||||
}
|
||||
}
|
||||
else {
|
||||
val type = resolveType(c.noBareTypes(), argumentElement.getTypeReference()!!)
|
||||
val type = resolveType(c.noBareTypes(), argumentElement.typeReference!!)
|
||||
val kind = resolveProjectionKind(projectionKind)
|
||||
if (constructor.parameters.size > i) {
|
||||
val parameterDescriptor = constructor.parameters[i]
|
||||
|
||||
@@ -65,7 +65,7 @@ class VarianceCheckerCore(
|
||||
if (klass is KtClass) {
|
||||
if (!checkClassHeader(klass)) return false
|
||||
}
|
||||
for (member in klass.declarations + klass.getPrimaryConstructorParameters()) {
|
||||
for (member in klass.declarations + klass.primaryConstructorParameters) {
|
||||
val descriptor = when (member) {
|
||||
is KtParameter -> context.get(BindingContext.PRIMARY_CONSTRUCTOR_PARAMETER, member)
|
||||
is KtDeclaration -> context.get(BindingContext.DECLARATION_TO_DESCRIPTOR, member)
|
||||
@@ -93,7 +93,7 @@ class VarianceCheckerCore(
|
||||
|
||||
private fun checkClassHeader(klass: KtClass): Boolean {
|
||||
var noError = true
|
||||
for (specifier in klass.getSuperTypeListEntries()) {
|
||||
for (specifier in klass.superTypeListEntries) {
|
||||
noError = noError and specifier.typeReference?.checkTypePosition(context, OUT_VARIANCE)
|
||||
}
|
||||
return noError and klass.checkTypeParameters(context, OUT_VARIANCE)
|
||||
|
||||
@@ -146,7 +146,7 @@ fun KtElement.getCall(context: BindingContext): Call? {
|
||||
val parent = element.parent
|
||||
val reference: KtExpression? = when {
|
||||
parent is KtInstanceExpressionWithLabel -> parent
|
||||
parent is KtUserType -> parent.getParent()?.getParent() as? KtConstructorCalleeExpression
|
||||
parent is KtUserType -> parent.parent?.parent as? KtConstructorCalleeExpression
|
||||
else -> element.getCalleeExpressionIfAny()
|
||||
}
|
||||
if (reference != null) {
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ class DataClassDeclarationChecker : SimpleDeclarationChecker {
|
||||
if (descriptor.unsubstitutedPrimaryConstructor == null && descriptor.constructors.isNotEmpty()) {
|
||||
declaration.nameIdentifier?.let { diagnosticHolder.report(Errors.PRIMARY_CONSTRUCTOR_REQUIRED_FOR_DATA_CLASS.on(it)) }
|
||||
}
|
||||
val primaryConstructor = declaration.getPrimaryConstructor()
|
||||
val primaryConstructor = declaration.primaryConstructor
|
||||
val parameters = primaryConstructor?.valueParameters ?: emptyList()
|
||||
if (parameters.isEmpty()) {
|
||||
(primaryConstructor?.valueParameterList ?: declaration.nameIdentifier)?.let {
|
||||
|
||||
+1
-1
@@ -58,7 +58,7 @@ class ReifiedTypeParameterAnnotationChecker : SimpleDeclarationChecker {
|
||||
|
||||
diagnosticHolder.report(
|
||||
Errors.REIFIED_TYPE_PARAMETER_NO_INLINE.on(
|
||||
typeParameterDeclaration.getModifierList()!!.getModifier(KtTokens.REIFIED_KEYWORD)!!
|
||||
typeParameterDeclaration.modifierList!!.getModifier(KtTokens.REIFIED_KEYWORD)!!
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -45,19 +45,19 @@ interface IndexedImports {
|
||||
}
|
||||
|
||||
class AllUnderImportsIndexed(allImports: Collection<KtImportDirective>) : IndexedImports {
|
||||
override val imports = allImports.filter { it.isAllUnder() }
|
||||
override val imports = allImports.filter { it.isAllUnder }
|
||||
override fun importsForName(name: Name) = imports
|
||||
}
|
||||
|
||||
class ExplicitImportsIndexed(allImports: Collection<KtImportDirective>) : IndexedImports {
|
||||
override val imports = allImports.filter { !it.isAllUnder() }
|
||||
override val imports = allImports.filter { !it.isAllUnder }
|
||||
|
||||
private val nameToDirectives: ListMultimap<Name, KtImportDirective> by lazy {
|
||||
val builder = ImmutableListMultimap.builder<Name, KtImportDirective>()
|
||||
|
||||
for (directive in imports) {
|
||||
val path = directive.getImportPath() ?: continue // parse error
|
||||
val importedName = path.getImportedName() ?: continue // parse error
|
||||
val path = directive.importPath ?: continue // parse error
|
||||
val importedName = path.importedName ?: continue // parse error
|
||||
builder.put(importedName, directive)
|
||||
}
|
||||
|
||||
@@ -241,8 +241,8 @@ class LazyImportScope(
|
||||
return importResolver.storageManager.compute {
|
||||
val descriptors = LinkedHashSet<DeclarationDescriptor>()
|
||||
for (directive in importResolver.indexedImports.imports) {
|
||||
val importPath = directive.getImportPath() ?: continue
|
||||
val importedName = importPath.getImportedName()
|
||||
val importPath = directive.importPath ?: continue
|
||||
val importedName = importPath.importedName
|
||||
if (importedName == null || nameFilter(importedName)) {
|
||||
descriptors.addAll(importResolver.getImportScope(directive).getContributedDescriptors(kindFilter, nameFilter))
|
||||
}
|
||||
|
||||
@@ -33,6 +33,6 @@ class KtScriptInfo(
|
||||
override fun getTypeParameterList() = null
|
||||
override fun getPrimaryConstructorParameters() = listOf<KtParameter>()
|
||||
override fun getClassKind() = ClassKind.CLASS
|
||||
override fun getDeclarations() = script.getDeclarations()
|
||||
override fun getDeclarations() = script.declarations
|
||||
override fun getDanglingAnnotations() = listOf<KtAnnotationEntry>()
|
||||
}
|
||||
+2
-2
@@ -358,7 +358,7 @@ open class LazyClassMemberScope(
|
||||
private fun resolveSecondaryConstructors(): Collection<ClassConstructorDescriptor> {
|
||||
val classOrObject = declarationProvider.correspondingClassOrObject ?: return emptyList()
|
||||
|
||||
return classOrObject.getSecondaryConstructors().map { constructor ->
|
||||
return classOrObject.secondaryConstructors.map { constructor ->
|
||||
val descriptor = c.functionDescriptorResolver.resolveSecondaryConstructorDescriptor(
|
||||
thisDescriptor.scopeForConstructorHeaderResolution, thisDescriptor, constructor, trace
|
||||
)
|
||||
@@ -368,7 +368,7 @@ open class LazyClassMemberScope(
|
||||
}
|
||||
|
||||
protected fun setDeferredReturnType(descriptor: ClassConstructorDescriptorImpl) {
|
||||
descriptor.returnType = DeferredType.create(c.storageManager, trace, { thisDescriptor.getDefaultType() })
|
||||
descriptor.returnType = DeferredType.create(c.storageManager, trace, { thisDescriptor.defaultType })
|
||||
}
|
||||
|
||||
override fun recordLookup(name: Name, from: LookupLocation) {
|
||||
|
||||
+1
-1
@@ -60,7 +60,7 @@ class LazyScriptDescriptor(
|
||||
|
||||
val scriptDefinition: KotlinScriptDefinition
|
||||
by lazy {
|
||||
val file = scriptInfo.script.getContainingKtFile()
|
||||
val file = scriptInfo.script.containingKtFile
|
||||
getScriptDefinition(file) ?: throw RuntimeException("file ${file.name} is not a script")
|
||||
}
|
||||
|
||||
|
||||
+7
-7
@@ -65,19 +65,19 @@ internal class FunctionsTypingVisitor(facade: ExpressionTypingInternals) : Expre
|
||||
): KotlinTypeInfo {
|
||||
if (!isDeclaration) {
|
||||
// function expression
|
||||
if (!function.getTypeParameters().isEmpty()) {
|
||||
if (!function.typeParameters.isEmpty()) {
|
||||
context.trace.report(TYPE_PARAMETERS_NOT_ALLOWED.on(function))
|
||||
}
|
||||
|
||||
if (function.getName() != null) {
|
||||
if (function.name != null) {
|
||||
context.trace.report(ANONYMOUS_FUNCTION_WITH_NAME.on(function.nameIdentifier!!))
|
||||
}
|
||||
|
||||
for (parameter in function.getValueParameters()) {
|
||||
for (parameter in function.valueParameters) {
|
||||
if (parameter.hasDefaultValue()) {
|
||||
context.trace.report(ANONYMOUS_FUNCTION_PARAMETER_WITH_DEFAULT_VALUE.on(parameter))
|
||||
}
|
||||
if (parameter.isVarArg()) {
|
||||
if (parameter.isVarArg) {
|
||||
context.trace.report(USELESS_VARARG_ON_PARAMETER.on(parameter))
|
||||
}
|
||||
}
|
||||
@@ -88,7 +88,7 @@ internal class FunctionsTypingVisitor(facade: ExpressionTypingInternals) : Expre
|
||||
functionDescriptor = components.functionDescriptorResolver.resolveFunctionDescriptor(
|
||||
context.scope.ownerDescriptor, context.scope, function, context.trace, context.dataFlowInfo)
|
||||
assert(statementScope != null) {
|
||||
"statementScope must be not null for function: " + function.getName() + " at location " + DiagnosticUtils.atLocation(function)
|
||||
"statementScope must be not null for function: " + function.name + " at location " + DiagnosticUtils.atLocation(function)
|
||||
}
|
||||
statementScope!!.addFunctionDescriptor(functionDescriptor)
|
||||
}
|
||||
@@ -112,7 +112,7 @@ internal class FunctionsTypingVisitor(facade: ExpressionTypingInternals) : Expre
|
||||
}
|
||||
|
||||
components.valueParameterResolver.resolveValueParameters(
|
||||
function.getValueParameters(), functionDescriptor.valueParameters, context.scope, context.dataFlowInfo, context.trace
|
||||
function.valueParameters, functionDescriptor.valueParameters, context.scope, context.dataFlowInfo, context.trace
|
||||
)
|
||||
|
||||
components.modifiersChecker.withTrace(context.trace).checkModifiersForLocalDeclaration(function, functionDescriptor)
|
||||
@@ -252,7 +252,7 @@ internal class FunctionsTypingVisitor(facade: ExpressionTypingInternals) : Expre
|
||||
if (returnedExpression != null) {
|
||||
val type = context.trace.getType(returnedExpression)
|
||||
if (type == null || !KotlinBuiltIns.isUnit(type)) {
|
||||
context.trace.report(RETURN_TYPE_MISMATCH.on(returnedExpression, components.builtIns.getUnitType()))
|
||||
context.trace.report(RETURN_TYPE_MISMATCH.on(returnedExpression, components.builtIns.unitType))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -74,7 +74,7 @@ class LocalClassifierAnalyzer(
|
||||
classOrObject: KtClassOrObject
|
||||
) {
|
||||
val module = DescriptorUtils.getContainingModule(containingDeclaration)
|
||||
val project = classOrObject.getProject()
|
||||
val project = classOrObject.project
|
||||
val moduleContext = globalContext.withProject(project).withModule(module)
|
||||
val container = createContainerForLazyLocalClassifierAnalyzer(
|
||||
moduleContext,
|
||||
|
||||
+1
-1
@@ -58,7 +58,7 @@ class ValueParameterResolver(
|
||||
context: ExpressionTypingContext
|
||||
) {
|
||||
if (!valueParameterDescriptor.declaresDefaultValue()) return
|
||||
val defaultValue = jetParameter.getDefaultValue() ?: return
|
||||
val defaultValue = jetParameter.defaultValue ?: return
|
||||
expressionTypingServices.getTypeInfo(defaultValue, context.replaceExpectedType(valueParameterDescriptor.type))
|
||||
if (DescriptorUtils.isAnnotationClass(DescriptorResolver.getContainingClass(context.scope))) {
|
||||
val constant = constantExpressionEvaluator.evaluateExpression(defaultValue, context.trace, valueParameterDescriptor.type)
|
||||
|
||||
Reference in New Issue
Block a user