Get rid of underscores in private property names
They were used to workaround duplicate signature errors, but this is no longer relevant since no accessors are generated for private properties with backing fields
This commit is contained in:
+2
-2
@@ -48,7 +48,7 @@ public class LazyJavaPackageFragmentProvider(
|
||||
outerContext.moduleClassResolver
|
||||
)
|
||||
|
||||
private val _packageFragments: MemoizedFunctionToNullable<FqName, LazyJavaPackageFragment> =
|
||||
private val packageFragments: MemoizedFunctionToNullable<FqName, LazyJavaPackageFragment> =
|
||||
c.storageManager.createMemoizedFunctionWithNullableValues {
|
||||
fqName ->
|
||||
val jPackage = c.finder.findPackage(fqName)
|
||||
@@ -74,7 +74,7 @@ public class LazyJavaPackageFragmentProvider(
|
||||
)
|
||||
}
|
||||
|
||||
fun getPackageFragment(fqName: FqName) = _packageFragments(fqName)
|
||||
fun getPackageFragment(fqName: FqName) = packageFragments(fqName)
|
||||
|
||||
override fun getPackageFragments(fqName: FqName) = getPackageFragment(fqName)?.let {listOf(it)}.orEmpty()
|
||||
|
||||
|
||||
+2
-2
@@ -60,7 +60,7 @@ class LazyJavaAnnotationDescriptor(
|
||||
else kotlinFqNameToJavaFqName(classId.asSingleFqName())
|
||||
}
|
||||
|
||||
private val _type = c.storageManager.createLazyValue {() : JetType ->
|
||||
private val type = c.storageManager.createLazyValue {(): JetType ->
|
||||
val fqName = fqName()
|
||||
if (fqName == null) return@createLazyValue ErrorUtils.createErrorType("No fqName: $javaAnnotation")
|
||||
val annotationClass = JavaToKotlinClassMap.getInstance().mapKotlinClass(fqName, TypeUsage.MEMBER_SIGNATURE_INVARIANT)
|
||||
@@ -68,7 +68,7 @@ class LazyJavaAnnotationDescriptor(
|
||||
annotationClass?.getDefaultType() ?: ErrorUtils.createErrorType(fqName.asString())
|
||||
}
|
||||
|
||||
override fun getType(): JetType = _type()
|
||||
override fun getType(): JetType = type()
|
||||
|
||||
private val nameToArgument = c.storageManager.createLazyValue {
|
||||
var arguments: Collection<JavaAnnotationArgument> = javaAnnotation.getArguments()
|
||||
|
||||
+30
-30
@@ -49,70 +49,70 @@ class LazyJavaClassDescriptor(
|
||||
c.javaResolverCache.recordClass(jClass, this)
|
||||
}
|
||||
|
||||
private val _kind = when {
|
||||
private val kind = when {
|
||||
jClass.isAnnotationType() -> ClassKind.ANNOTATION_CLASS
|
||||
jClass.isInterface() -> ClassKind.TRAIT
|
||||
jClass.isEnum() -> ClassKind.ENUM_CLASS
|
||||
else -> ClassKind.CLASS
|
||||
}
|
||||
|
||||
private val _modality = if (jClass.isAnnotationType())
|
||||
Modality.FINAL
|
||||
else Modality.convertFromFlags(jClass.isAbstract() || jClass.isInterface(), !jClass.isFinal())
|
||||
private val modality = if (jClass.isAnnotationType())
|
||||
Modality.FINAL
|
||||
else Modality.convertFromFlags(jClass.isAbstract() || jClass.isInterface(), !jClass.isFinal())
|
||||
|
||||
private val _visibility = jClass.getVisibility()
|
||||
private val _isInner = jClass.getOuterClass() != null && !jClass.isStatic()
|
||||
private val visibility = jClass.getVisibility()
|
||||
private val isInner = jClass.getOuterClass() != null && !jClass.isStatic()
|
||||
|
||||
override fun getKind() = _kind
|
||||
override fun getModality() = _modality
|
||||
override fun getVisibility() = _visibility
|
||||
override fun isInner() = _isInner
|
||||
override fun getKind() = kind
|
||||
override fun getModality() = modality
|
||||
override fun getVisibility() = visibility
|
||||
override fun isInner() = isInner
|
||||
|
||||
private val _typeConstructor = c.storageManager.createLazyValue { LazyJavaClassTypeConstructor() }
|
||||
override fun getTypeConstructor(): TypeConstructor = _typeConstructor()
|
||||
private val typeConstructor = c.storageManager.createLazyValue { LazyJavaClassTypeConstructor() }
|
||||
override fun getTypeConstructor(): TypeConstructor = typeConstructor()
|
||||
|
||||
private val _scopeForMemberLookup = LazyJavaClassMemberScope(c, this, jClass)
|
||||
override fun getScopeForMemberLookup() = _scopeForMemberLookup
|
||||
private val scopeForMemberLookup = LazyJavaClassMemberScope(c, this, jClass)
|
||||
override fun getScopeForMemberLookup() = scopeForMemberLookup
|
||||
|
||||
private val _innerClassesScope = InnerClassesScopeWrapper(getScopeForMemberLookup())
|
||||
override fun getUnsubstitutedInnerClassesScope(): JetScope = _innerClassesScope
|
||||
private val innerClassesScope = InnerClassesScopeWrapper(getScopeForMemberLookup())
|
||||
override fun getUnsubstitutedInnerClassesScope(): JetScope = innerClassesScope
|
||||
|
||||
private val _staticScope = LazyJavaStaticClassScope(c, jClass, this)
|
||||
override fun getStaticScope(): JetScope = _staticScope
|
||||
private val staticScope = LazyJavaStaticClassScope(c, jClass, this)
|
||||
override fun getStaticScope(): JetScope = staticScope
|
||||
|
||||
override fun getUnsubstitutedPrimaryConstructor(): ConstructorDescriptor? = null
|
||||
|
||||
override fun getClassObjectDescriptor(): ClassDescriptor? = null
|
||||
override fun getClassObjectType(): JetType? = getClassObjectDescriptor()?.let { d -> d.getDefaultType() }
|
||||
|
||||
override fun getConstructors() = _scopeForMemberLookup.constructors()
|
||||
override fun getConstructors() = scopeForMemberLookup.constructors()
|
||||
|
||||
private val _annotations = c.storageManager.createLazyValue { c.resolveAnnotations(jClass) }
|
||||
override fun getAnnotations() = _annotations()
|
||||
private val annotations = c.storageManager.createLazyValue { c.resolveAnnotations(jClass) }
|
||||
override fun getAnnotations() = annotations()
|
||||
|
||||
private val _functionTypeForSamInterface = c.storageManager.createNullableLazyValue {
|
||||
private val functionTypeForSamInterface = c.storageManager.createNullableLazyValue {
|
||||
c.samConversionResolver.resolveFunctionTypeIfSamInterface(this) { method ->
|
||||
_scopeForMemberLookup.resolveMethodToFunctionDescriptor(method, false)
|
||||
scopeForMemberLookup.resolveMethodToFunctionDescriptor(method, false)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getFunctionTypeForSamInterface(): JetType? = _functionTypeForSamInterface()
|
||||
override fun getFunctionTypeForSamInterface(): JetType? = functionTypeForSamInterface()
|
||||
|
||||
override fun toString() = "lazy java class $fqName"
|
||||
|
||||
private inner class LazyJavaClassTypeConstructor : AbstractClassTypeConstructor() {
|
||||
|
||||
private val _parameters = c.storageManager.createLazyValue {
|
||||
jClass.getTypeParameters().map({
|
||||
private val parameters = c.storageManager.createLazyValue {
|
||||
jClass.getTypeParameters().map {
|
||||
p ->
|
||||
c.typeParameterResolver.resolveTypeParameter(p)
|
||||
?: throw AssertionError("Parameter $p surely belongs to class ${jClass}, so it must be resolved")
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
override fun getParameters(): List<TypeParameterDescriptor> = _parameters()
|
||||
override fun getParameters(): List<TypeParameterDescriptor> = parameters()
|
||||
|
||||
private val _supertypes = c.storageManager.createLazyValue<Collection<JetType>> {
|
||||
private val supertypes = c.storageManager.createLazyValue<Collection<JetType>> {
|
||||
jClass.getSupertypes().stream()
|
||||
.map {
|
||||
supertype ->
|
||||
@@ -125,7 +125,7 @@ class LazyJavaClassDescriptor(
|
||||
}
|
||||
}
|
||||
|
||||
override fun getSupertypes(): Collection<JetType> = _supertypes()
|
||||
override fun getSupertypes(): Collection<JetType> = supertypes()
|
||||
|
||||
override fun getAnnotations() = Annotations.EMPTY
|
||||
|
||||
|
||||
+6
-6
@@ -47,9 +47,9 @@ import org.jetbrains.jet.lang.descriptors.annotations.Annotations
|
||||
|
||||
public abstract class LazyJavaMemberScope(
|
||||
protected val c: LazyJavaResolverContextWithTypes,
|
||||
private val _containingDeclaration: DeclarationDescriptor
|
||||
private val containingDeclaration: DeclarationDescriptor
|
||||
) : JetScope {
|
||||
private val _allDescriptors = c.storageManager.createRecursionTolerantLazyValue<Collection<DeclarationDescriptor>>(
|
||||
private val allDescriptors = c.storageManager.createRecursionTolerantLazyValue<Collection<DeclarationDescriptor>>(
|
||||
{computeAllDescriptors()},
|
||||
// This is to avoid the following recursive case:
|
||||
// when computing getAllPackageNames() we ask the JavaPsiFacade for all subpackages of foo
|
||||
@@ -58,7 +58,7 @@ public abstract class LazyJavaMemberScope(
|
||||
listOf()
|
||||
)
|
||||
|
||||
override fun getContainingDeclaration() = _containingDeclaration
|
||||
override fun getContainingDeclaration() = containingDeclaration
|
||||
|
||||
protected val memberIndex: NotNullLazyValue<MemberIndex> = c.storageManager.createLazyValue {
|
||||
computeMemberIndex()
|
||||
@@ -105,7 +105,7 @@ public abstract class LazyJavaMemberScope(
|
||||
|
||||
val annotations = c.resolveAnnotations(method)
|
||||
val functionDescriptorImpl = JavaMethodDescriptor.createJavaMethod(
|
||||
_containingDeclaration, annotations, method.getName(), c.sourceElementFactory.source(method)
|
||||
containingDeclaration, annotations, method.getName(), c.sourceElementFactory.source(method)
|
||||
)
|
||||
|
||||
val c = c.child(functionDescriptorImpl, method.getTypeParameters().toSet())
|
||||
@@ -255,7 +255,7 @@ public abstract class LazyJavaMemberScope(
|
||||
val annotations = c.resolveAnnotations(field)
|
||||
val propertyName = field.getName()
|
||||
|
||||
return JavaPropertyDescriptor(_containingDeclaration, annotations, visibility, isVar, propertyName,
|
||||
return JavaPropertyDescriptor(containingDeclaration, annotations, visibility, isVar, propertyName,
|
||||
c.sourceElementFactory.source(field))
|
||||
}
|
||||
|
||||
@@ -283,7 +283,7 @@ public abstract class LazyJavaMemberScope(
|
||||
override fun getDeclarationsByLabel(labelName: Name) = listOf<DeclarationDescriptor>()
|
||||
|
||||
override fun getOwnDeclaredDescriptors() = getAllDescriptors()
|
||||
override fun getAllDescriptors() = _allDescriptors()
|
||||
override fun getAllDescriptors() = allDescriptors()
|
||||
|
||||
private fun computeAllDescriptors(): List<DeclarationDescriptor> {
|
||||
val result = LinkedHashSet<DeclarationDescriptor>()
|
||||
|
||||
+2
-2
@@ -25,9 +25,9 @@ class LazyJavaPackageFragment(
|
||||
private val c: LazyJavaResolverContext,
|
||||
private val jPackage: JavaPackage
|
||||
) : PackageFragmentDescriptorImpl(c.packageFragmentProvider.module, jPackage.getFqName()) {
|
||||
private val _memberScope by Delegates.lazy { LazyPackageFragmentScopeForJavaPackage(c, jPackage, this) }
|
||||
private val scope by Delegates.lazy { LazyPackageFragmentScopeForJavaPackage(c, jPackage, this) }
|
||||
|
||||
override fun getMemberScope() = _memberScope
|
||||
override fun getMemberScope() = scope
|
||||
|
||||
override fun toString() = "lazy java package fragment: $fqName"
|
||||
}
|
||||
|
||||
+2
-2
@@ -116,7 +116,7 @@ public class LazyPackageFragmentScopeForJavaPackage(
|
||||
.map { c -> c.getName() }.toList()
|
||||
}
|
||||
|
||||
private val _subPackages = c.storageManager.createRecursionTolerantLazyValue(
|
||||
private val subPackages = c.storageManager.createRecursionTolerantLazyValue(
|
||||
{
|
||||
jPackage.getSubPackages().map { sp -> sp.getFqName() }
|
||||
},
|
||||
@@ -128,7 +128,7 @@ public class LazyPackageFragmentScopeForJavaPackage(
|
||||
result.addIfNotNull(c.samConversionResolver.resolveSamConstructor(name, this))
|
||||
}
|
||||
|
||||
override fun getSubPackages() = _subPackages()
|
||||
override fun getSubPackages() = subPackages()
|
||||
|
||||
override fun getAllPropertyNames() = Collections.emptyList<Name>()
|
||||
}
|
||||
|
||||
+5
-5
@@ -35,7 +35,6 @@ import org.jetbrains.jet.lang.resolve.java.PLATFORM_TYPES
|
||||
import org.jetbrains.jet.lang.resolve.java.lazy.types.JavaTypeFlexibility.*
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.Annotations
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmAnnotationNames
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName
|
||||
import kotlin.platform.platformStatic
|
||||
|
||||
class LazyJavaTypeResolver(
|
||||
@@ -248,11 +247,11 @@ class LazyJavaTypeResolver(
|
||||
return (descriptor as ClassDescriptor).getMemberScope(getArguments())
|
||||
}
|
||||
|
||||
private val _nullable = c.storageManager.createLazyValue @nullable{
|
||||
private val nullable = c.storageManager.createLazyValue @l {
|
||||
(): Boolean ->
|
||||
when (attr.flexibility) {
|
||||
FLEXIBLE_LOWER_BOUND -> return@nullable false
|
||||
FLEXIBLE_UPPER_BOUND -> return@nullable true
|
||||
FLEXIBLE_LOWER_BOUND -> return@l false
|
||||
FLEXIBLE_UPPER_BOUND -> return@l true
|
||||
}
|
||||
!attr.isMarkedNotNull &&
|
||||
// 'L extends List<T>' in Java is a List<T> in Kotlin, not a List<T?>
|
||||
@@ -269,7 +268,8 @@ class LazyJavaTypeResolver(
|
||||
else -> error("Unknown classifier: ${classifier()}")
|
||||
}
|
||||
}
|
||||
override fun isNullable(): Boolean = _nullable()
|
||||
|
||||
override fun isNullable(): Boolean = nullable()
|
||||
|
||||
override fun getAnnotations() = attr.annotations
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user