Refactoring. Convert KotlinType to kotlin.
This commit is contained in:
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -85,7 +85,7 @@ class LazyJavaAnnotationDescriptor(
|
||||
}
|
||||
}
|
||||
|
||||
private fun getAnnotationClass() = getType().getConstructor().declarationDescriptor as ClassDescriptor
|
||||
private fun getAnnotationClass() = getType().constructor.declarationDescriptor as ClassDescriptor
|
||||
|
||||
private fun resolveAnnotationArgument(argument: JavaAnnotationArgument?): ConstantValue<*>? {
|
||||
return when (argument) {
|
||||
@@ -103,7 +103,7 @@ class LazyJavaAnnotationDescriptor(
|
||||
}
|
||||
|
||||
private fun resolveFromArray(argumentName: Name, elements: List<JavaAnnotationArgument>): ConstantValue<*>? {
|
||||
if (getType().isError()) return null
|
||||
if (getType().isError) return null
|
||||
|
||||
val valueParameter = DescriptorResolverUtils.getAnnotationParameterByName(argumentName, getAnnotationClass()) ?: return null
|
||||
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -678,7 +678,7 @@ class LazyJavaClassMemberScope(
|
||||
|
||||
return memberIndex().getAllFieldNames() +
|
||||
ownerDescriptor.getTypeConstructor().getSupertypes().flatMapTo(LinkedHashSet<Name>()) { supertype ->
|
||||
supertype.getMemberScope().getContributedDescriptors(kindFilter, nameFilter).map { variable ->
|
||||
supertype.memberScope.getContributedDescriptors(kindFilter, nameFilter).map { variable ->
|
||||
variable.getName()
|
||||
}
|
||||
}
|
||||
|
||||
+4
-5
@@ -183,12 +183,11 @@ class LazyJavaTypeResolver(
|
||||
// such as collections with no generics, so the Java types are not raw, formally, but they don't match with
|
||||
// their Kotlin analogs, so we treat them as raw to avoid exceptions
|
||||
// No type arguments, but some are expected => raw
|
||||
return javaType.typeArguments.isEmpty() && !getConstructor().parameters.isEmpty()
|
||||
return javaType.typeArguments.isEmpty() && !constructor.parameters.isEmpty()
|
||||
}
|
||||
|
||||
override fun computeArguments(): List<TypeProjection> {
|
||||
val typeConstructor = getConstructor()
|
||||
val typeParameters = typeConstructor.parameters
|
||||
val typeParameters = constructor.parameters
|
||||
if (isRaw()) {
|
||||
return typeParameters.map {
|
||||
parameter ->
|
||||
@@ -259,7 +258,7 @@ class LazyJavaTypeResolver(
|
||||
return this != typeParameter.variance
|
||||
}
|
||||
|
||||
override fun getCapabilities(): TypeCapabilities = if (isRaw()) RawTypeCapabilities else TypeCapabilities.NONE
|
||||
override val capabilities: TypeCapabilities get() = if (isRaw()) RawTypeCapabilities else TypeCapabilities.NONE
|
||||
|
||||
private val nullable = c.storageManager.createLazyValue l@ {
|
||||
if (attr.flexibility == FLEXIBLE_LOWER_BOUND) return@l false
|
||||
@@ -278,7 +277,7 @@ class LazyJavaTypeResolver(
|
||||
}
|
||||
}
|
||||
|
||||
override fun isMarkedNullable(): Boolean = nullable()
|
||||
override val isMarkedNullable: Boolean get() = nullable()
|
||||
|
||||
override fun getAnnotations() = annotations
|
||||
}
|
||||
|
||||
+4
-4
@@ -95,7 +95,7 @@ private fun KotlinType.enhanceInflexible(qualifiers: (Int) -> JavaTypeQualifiers
|
||||
|
||||
var globalArgIndex = index + 1
|
||||
var wereChanges = enhancedMutabilityAnnotations != null
|
||||
val enhancedArguments = getArguments().mapIndexed {
|
||||
val enhancedArguments = arguments.mapIndexed {
|
||||
localArgIndex, arg ->
|
||||
if (arg.isStarProjection) {
|
||||
globalArgIndex++
|
||||
@@ -138,7 +138,7 @@ private fun KotlinType.enhanceInflexible(qualifiers: (Int) -> JavaTypeQualifiers
|
||||
enhancedArguments,
|
||||
if (enhancedClassifier is ClassDescriptor)
|
||||
enhancedClassifier.getMemberScope(newSubstitution)
|
||||
else enhancedClassifier.getDefaultType().getMemberScope(),
|
||||
else enhancedClassifier.getDefaultType().memberScope,
|
||||
newCapabilities
|
||||
)
|
||||
return Result(enhancedType, subtreeSize, wereChanges = true)
|
||||
@@ -180,12 +180,12 @@ private fun ClassifierDescriptor.enhanceMutability(qualifiers: JavaTypeQualifier
|
||||
}
|
||||
|
||||
private fun KotlinType.getEnhancedNullability(qualifiers: JavaTypeQualifiers, position: TypeComponentPosition): EnhancementResult<Boolean> {
|
||||
if (!position.shouldEnhance()) return this.isMarkedNullable().noChange()
|
||||
if (!position.shouldEnhance()) return this.isMarkedNullable.noChange()
|
||||
|
||||
return when (qualifiers.nullability) {
|
||||
NULLABLE -> true.enhancedNullability()
|
||||
NOT_NULL -> false.enhancedNullability()
|
||||
else -> this.isMarkedNullable().noChange()
|
||||
else -> this.isMarkedNullable.noChange()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -101,7 +101,7 @@ fun KotlinType.computeIndexedQualifiersForOverride(fromSupertypes: Collection<Ko
|
||||
|
||||
fun add(type: KotlinType) {
|
||||
list.add(type)
|
||||
for (arg in type.getArguments()) {
|
||||
for (arg in type.arguments) {
|
||||
if (arg.isStarProjection) {
|
||||
list.add(arg.type)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user