KT-56891 SLC Don't include abstract members in DefaultImpls
This commit is contained in:
committed by
Space Team
parent
331cc1465a
commit
378bb4c4ac
+7
-3
@@ -9,6 +9,7 @@ import com.intellij.psi.PsiManager
|
||||
import com.intellij.psi.PsiMethod
|
||||
import com.intellij.psi.PsiReferenceList
|
||||
import org.jetbrains.kotlin.analysis.api.KtAnalysisSession
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KtCallableSymbol
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KtClassKind
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KtFunctionSymbol
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KtNamedClassOrObjectSymbol
|
||||
@@ -55,9 +56,7 @@ internal open class SymbolLightClassForInterface : SymbolLightClassForInterfaceO
|
||||
withClassOrObjectSymbol { classOrObjectSymbol ->
|
||||
val result = mutableListOf<KtLightMethod>()
|
||||
|
||||
val visibleDeclarations = classOrObjectSymbol.getDeclaredMemberScope().getCallableSymbols()
|
||||
.filterNot { it is KtFunctionSymbol && it.visibility.isPrivateOrPrivateToThis() }
|
||||
.filterNot { it.hasTypeForValueClassInSignature() }
|
||||
val visibleDeclarations = classOrObjectSymbol.getDeclaredMemberScope().getCallableSymbols().filter { acceptCallableSymbol(it) }
|
||||
|
||||
createMethods(visibleDeclarations, result)
|
||||
addMethodsFromCompanionIfNeeded(result, classOrObjectSymbol)
|
||||
@@ -66,6 +65,11 @@ internal open class SymbolLightClassForInterface : SymbolLightClassForInterfaceO
|
||||
}
|
||||
}
|
||||
|
||||
context(KtAnalysisSession)
|
||||
protected open fun acceptCallableSymbol(symbol: KtCallableSymbol): Boolean =
|
||||
!(symbol is KtFunctionSymbol && symbol.visibility.isPrivateOrPrivateToThis() || symbol.hasTypeForValueClassInSignature())
|
||||
|
||||
|
||||
override fun getOwnMethods(): List<PsiMethod> = _ownMethods
|
||||
|
||||
override fun copy(): SymbolLightClassForInterface =
|
||||
|
||||
+9
@@ -7,7 +7,11 @@ package org.jetbrains.kotlin.light.classes.symbol.classes
|
||||
|
||||
import com.intellij.psi.*
|
||||
import com.intellij.util.IncorrectOperationException
|
||||
import org.jetbrains.kotlin.analysis.api.KtAnalysisSession
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KtCallableSymbol
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KtClassKind
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.markers.KtSymbolWithModality
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.light.classes.symbol.modifierLists.InitializedModifiersBox
|
||||
import org.jetbrains.kotlin.light.classes.symbol.modifierLists.SymbolLightClassModifierList
|
||||
import org.jetbrains.kotlin.load.java.JvmAbi
|
||||
@@ -62,4 +66,9 @@ internal class SymbolLightClassForInterfaceDefaultImpls(private val containingCl
|
||||
override fun getContainingClass() = containingClass
|
||||
|
||||
override fun getOwnInnerClasses() = emptyList<PsiClass>()
|
||||
|
||||
context(KtAnalysisSession)
|
||||
override fun acceptCallableSymbol(symbol: KtCallableSymbol): Boolean {
|
||||
return super.acceptCallableSymbol(symbol) && (symbol as? KtSymbolWithModality)?.modality != Modality.ABSTRACT
|
||||
}
|
||||
}
|
||||
|
||||
compiler/testData/asJava/lightClasses/lightClassByFqName/ExtendingInterfaceWithDefaultImpls.fir.java
Vendored
+3
@@ -2,6 +2,9 @@ public abstract interface C /* p.C*/ extends p.B {
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public abstract java.lang.String c();// c()
|
||||
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public abstract java.lang.String more();// more()
|
||||
|
||||
public static final class DefaultImpls /* p.C.DefaultImpls*/ {
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public java.lang.String c();// c()
|
||||
|
||||
Vendored
+3
@@ -2,6 +2,9 @@ public abstract interface C /* p.C*/ extends p.B {
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public abstract java.lang.String c();// c()
|
||||
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public abstract java.lang.String more();// more()
|
||||
|
||||
public static final class DefaultImpls /* p.C.DefaultImpls*/ {
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public static java.lang.String a(@org.jetbrains.annotations.NotNull() p.C);// a(p.C)
|
||||
|
||||
Vendored
+2
@@ -11,4 +11,6 @@ interface B: A {
|
||||
|
||||
interface C : B {
|
||||
fun c() = "c"
|
||||
|
||||
fun more(): String
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user