rename Jet* classes to Kt*
This commit is contained in:
@@ -41,14 +41,14 @@ public object JvmFileClassUtil {
|
||||
public val JVM_MULTIFILE_CLASS_SHORT = JVM_MULTIFILE_CLASS.shortName().asString()
|
||||
|
||||
@JvmStatic
|
||||
public fun getFileClassInfo(file: JetFile, jvmFileClassAnnotations: ParsedJmvFileClassAnnotations?): JvmFileClassInfo =
|
||||
public fun getFileClassInfo(file: KtFile, jvmFileClassAnnotations: ParsedJmvFileClassAnnotations?): JvmFileClassInfo =
|
||||
if (jvmFileClassAnnotations != null)
|
||||
getFileClassInfoForAnnotation(file, jvmFileClassAnnotations)
|
||||
else
|
||||
getDefaultFileClassInfo(file)
|
||||
|
||||
@JvmStatic
|
||||
public fun getFileClassInfoForAnnotation(file: JetFile, jvmFileClassAnnotations: ParsedJmvFileClassAnnotations): JvmFileClassInfo =
|
||||
public fun getFileClassInfoForAnnotation(file: KtFile, jvmFileClassAnnotations: ParsedJmvFileClassAnnotations): JvmFileClassInfo =
|
||||
if (jvmFileClassAnnotations.multipleFiles)
|
||||
JvmMultifileClassPartInfo(getHiddenPartFqName(file, jvmFileClassAnnotations),
|
||||
getFacadeFqName(file, jvmFileClassAnnotations))
|
||||
@@ -56,11 +56,11 @@ public object JvmFileClassUtil {
|
||||
JvmSimpleFileClassInfo(getFacadeFqName(file, jvmFileClassAnnotations), true)
|
||||
|
||||
@JvmStatic
|
||||
public fun getDefaultFileClassInfo(file: JetFile): JvmFileClassInfo =
|
||||
public fun getDefaultFileClassInfo(file: KtFile): JvmFileClassInfo =
|
||||
JvmSimpleFileClassInfo(PackagePartClassUtils.getPackagePartFqName(file.packageFqName, file.name), false)
|
||||
|
||||
@JvmStatic
|
||||
public fun getFacadeFqName(file: JetFile, jvmFileClassAnnotations: ParsedJmvFileClassAnnotations): FqName =
|
||||
public fun getFacadeFqName(file: KtFile, jvmFileClassAnnotations: ParsedJmvFileClassAnnotations): FqName =
|
||||
file.packageFqName.child(Name.identifier(jvmFileClassAnnotations.name))
|
||||
|
||||
@JvmStatic
|
||||
@@ -79,7 +79,7 @@ public object JvmFileClassUtil {
|
||||
getImplClassNameForProto(proto, nameResolver)
|
||||
|
||||
@JvmStatic
|
||||
public fun getHiddenPartFqName(file: JetFile, jvmFileClassAnnotations: ParsedJmvFileClassAnnotations): FqName =
|
||||
public fun getHiddenPartFqName(file: KtFile, jvmFileClassAnnotations: ParsedJmvFileClassAnnotations): FqName =
|
||||
file.packageFqName.child(Name.identifier(manglePartName(jvmFileClassAnnotations.name, file.name)))
|
||||
|
||||
@JvmStatic
|
||||
@@ -87,11 +87,11 @@ public object JvmFileClassUtil {
|
||||
"${facadeName}__${PackagePartClassUtils.getFilePartShortName(fileName)}"
|
||||
|
||||
@JvmStatic
|
||||
public fun getFileClassInfoNoResolve(file: JetFile): JvmFileClassInfo =
|
||||
public fun getFileClassInfoNoResolve(file: KtFile): JvmFileClassInfo =
|
||||
getFileClassInfo(file, parseJvmNameOnFileNoResolve(file))
|
||||
|
||||
@JvmStatic
|
||||
public fun parseJvmNameOnFileNoResolve(file: JetFile): ParsedJmvFileClassAnnotations? {
|
||||
public fun parseJvmNameOnFileNoResolve(file: KtFile): ParsedJmvFileClassAnnotations? {
|
||||
val jvmName = findAnnotationEntryOnFileNoResolve(file, JVM_NAME_SHORT) ?: return null
|
||||
val nameExpr = jvmName.valueArguments.firstOrNull()?.getArgumentExpression() ?: return null
|
||||
val name = getLiteralStringFromRestrictedConstExpression(nameExpr) ?: return null
|
||||
@@ -101,16 +101,16 @@ public object JvmFileClassUtil {
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
public fun findAnnotationEntryOnFileNoResolve(file: JetFile, shortName: String): JetAnnotationEntry? =
|
||||
public fun findAnnotationEntryOnFileNoResolve(file: KtFile, shortName: String): KtAnnotationEntry? =
|
||||
file.fileAnnotationList?.annotationEntries?.firstOrNull {
|
||||
it.calleeExpression?.constructorReferenceExpression?.getReferencedName() == shortName
|
||||
}
|
||||
|
||||
private @JvmStatic fun getLiteralStringFromRestrictedConstExpression(argumentExpression: JetExpression?): String? {
|
||||
val stringTemplate = argumentExpression as? JetStringTemplateExpression ?: return null
|
||||
private @JvmStatic fun getLiteralStringFromRestrictedConstExpression(argumentExpression: KtExpression?): String? {
|
||||
val stringTemplate = argumentExpression as? KtStringTemplateExpression ?: return null
|
||||
val stringTemplateEntries = stringTemplate.entries
|
||||
if (stringTemplateEntries.size() != 1) return null
|
||||
val singleEntry = stringTemplateEntries[0] as? JetLiteralStringTemplateEntry ?: return null
|
||||
val singleEntry = stringTemplateEntries[0] as? KtLiteralStringTemplateEntry ?: return null
|
||||
return singleEntry.text
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ public object JvmFileClassUtil {
|
||||
|
||||
public class ParsedJmvFileClassAnnotations(public val name: String, public val multipleFiles: Boolean)
|
||||
|
||||
public val JetFile.javaFileFacadeFqName: FqName
|
||||
public val KtFile.javaFileFacadeFqName: FqName
|
||||
get() {
|
||||
return CachedValuesManager.getCachedValue(this) {
|
||||
val facadeFqName =
|
||||
@@ -128,7 +128,7 @@ public val JetFile.javaFileFacadeFqName: FqName
|
||||
}
|
||||
}
|
||||
|
||||
public fun JetDeclaration.isInsideJvmMultifileClassFile() = JvmFileClassUtil.findAnnotationEntryOnFileNoResolve(
|
||||
public fun KtDeclaration.isInsideJvmMultifileClassFile() = JvmFileClassUtil.findAnnotationEntryOnFileNoResolve(
|
||||
getContainingJetFile(),
|
||||
JvmFileClassUtil.JVM_MULTIFILE_CLASS_SHORT
|
||||
) != null
|
||||
|
||||
+8
-8
@@ -18,12 +18,12 @@
|
||||
package org.jetbrains.kotlin.fileClasses
|
||||
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.psi.JetFile
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.resolve.jvm.JvmClassName
|
||||
import org.jetbrains.org.objectweb.asm.Type
|
||||
|
||||
public interface JvmFileClassesProvider {
|
||||
public fun getFileClassInfo(file: JetFile): JvmFileClassInfo
|
||||
public fun getFileClassInfo(file: KtFile): JvmFileClassInfo
|
||||
}
|
||||
|
||||
public fun FqName.getInternalName(): String =
|
||||
@@ -32,20 +32,20 @@ public fun FqName.getInternalName(): String =
|
||||
public fun FqName.getClassType(): Type =
|
||||
Type.getObjectType(getInternalName())
|
||||
|
||||
public fun JvmFileClassesProvider.getFileClassFqName(file: JetFile): FqName =
|
||||
public fun JvmFileClassesProvider.getFileClassFqName(file: KtFile): FqName =
|
||||
getFileClassInfo(file).fileClassFqName
|
||||
|
||||
public fun JvmFileClassesProvider.getFileClassInternalName(file: JetFile): String =
|
||||
public fun JvmFileClassesProvider.getFileClassInternalName(file: KtFile): String =
|
||||
getFileClassFqName(file).getInternalName()
|
||||
|
||||
public fun JvmFileClassesProvider.getFileClassType(file: JetFile): Type =
|
||||
public fun JvmFileClassesProvider.getFileClassType(file: KtFile): Type =
|
||||
getFileClassFqName(file).getClassType()
|
||||
|
||||
public fun JvmFileClassesProvider.getFacadeClassFqName(file: JetFile): FqName =
|
||||
public fun JvmFileClassesProvider.getFacadeClassFqName(file: KtFile): FqName =
|
||||
getFileClassInfo(file).facadeClassFqName
|
||||
|
||||
public fun JvmFileClassesProvider.getFacadeClassInternalName(file: JetFile): String =
|
||||
public fun JvmFileClassesProvider.getFacadeClassInternalName(file: KtFile): String =
|
||||
getFacadeClassFqName(file).getInternalName()
|
||||
|
||||
public fun JvmFileClassesProvider.getFacadeClassType(file: JetFile): Type =
|
||||
public fun JvmFileClassesProvider.getFacadeClassType(file: KtFile): Type =
|
||||
getFacadeClassFqName(file).getClassType()
|
||||
+2
-2
@@ -17,10 +17,10 @@
|
||||
package org.jetbrains.kotlin.fileClasses
|
||||
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.psi.JetFile
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
|
||||
|
||||
public object NoResolveFileClassesProvider : JvmFileClassesProvider {
|
||||
override fun getFileClassInfo(file: JetFile): JvmFileClassInfo =
|
||||
override fun getFileClassInfo(file: KtFile): JvmFileClassInfo =
|
||||
JvmFileClassUtil.getFileClassInfo(file, JvmFileClassUtil.parseJvmNameOnFileNoResolve(file))
|
||||
}
|
||||
@@ -20,36 +20,36 @@ import com.intellij.openapi.util.text.StringUtil
|
||||
import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor
|
||||
import org.jetbrains.kotlin.load.java.JvmAnnotationNames
|
||||
import org.jetbrains.kotlin.jvm.bindingContextSlices.RUNTIME_ASSERTION_INFO
|
||||
import org.jetbrains.kotlin.psi.JetExpression
|
||||
import org.jetbrains.kotlin.psi.KtExpression
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.calls.checkers.AdditionalTypeChecker
|
||||
import org.jetbrains.kotlin.resolve.calls.context.CallResolutionContext
|
||||
import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
||||
import org.jetbrains.kotlin.types.JetType
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
import org.jetbrains.kotlin.types.checker.JetTypeChecker
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
|
||||
import org.jetbrains.kotlin.types.upperIfFlexible
|
||||
|
||||
public class RuntimeAssertionInfo(public val needNotNullAssertion: Boolean, public val message: String) {
|
||||
public interface DataFlowExtras {
|
||||
class OnlyMessage(message: String) : DataFlowExtras {
|
||||
override val canBeNull: Boolean get() = true
|
||||
override val possibleTypes: Set<JetType> get() = setOf()
|
||||
override val possibleTypes: Set<KtType> get() = setOf()
|
||||
override val presentableText: String = message
|
||||
}
|
||||
|
||||
val canBeNull: Boolean
|
||||
val possibleTypes: Set<JetType>
|
||||
val possibleTypes: Set<KtType>
|
||||
val presentableText: String
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
public fun create(
|
||||
expectedType: JetType,
|
||||
expressionType: JetType,
|
||||
expectedType: KtType,
|
||||
expressionType: KtType,
|
||||
dataFlowExtras: DataFlowExtras
|
||||
): RuntimeAssertionInfo? {
|
||||
fun assertNotNull(): Boolean {
|
||||
@@ -78,13 +78,13 @@ public class RuntimeAssertionInfo(public val needNotNullAssertion: Boolean, publ
|
||||
null
|
||||
}
|
||||
|
||||
private fun JetType.hasEnhancedNullability()
|
||||
private fun KtType.hasEnhancedNullability()
|
||||
= getAnnotations().findAnnotation(JvmAnnotationNames.ENHANCED_NULLABILITY_ANNOTATION) != null
|
||||
}
|
||||
}
|
||||
|
||||
public object RuntimeAssertionsTypeChecker : AdditionalTypeChecker {
|
||||
override fun checkType(expression: JetExpression, expressionType: JetType, expressionTypeWithSmartCast: JetType, c: ResolutionContext<*>) {
|
||||
override fun checkType(expression: KtExpression, expressionType: KtType, expressionTypeWithSmartCast: KtType, c: ResolutionContext<*>) {
|
||||
if (TypeUtils.noExpectedType(c.expectedType)) return
|
||||
|
||||
val assertionInfo = RuntimeAssertionInfo.create(
|
||||
@@ -93,7 +93,7 @@ public object RuntimeAssertionsTypeChecker : AdditionalTypeChecker {
|
||||
object : RuntimeAssertionInfo.DataFlowExtras {
|
||||
override val canBeNull: Boolean
|
||||
get() = c.dataFlowInfo.getNullability(dataFlowValue).canBeNull()
|
||||
override val possibleTypes: Set<JetType>
|
||||
override val possibleTypes: Set<KtType>
|
||||
get() = c.dataFlowInfo.getPossibleTypes(dataFlowValue)
|
||||
override val presentableText: String
|
||||
get() = StringUtil.trimMiddle(expression.getText(), 50)
|
||||
|
||||
@@ -17,10 +17,10 @@
|
||||
package org.jetbrains.kotlin.jvm.bindingContextSlices
|
||||
|
||||
import org.jetbrains.kotlin.jvm.RuntimeAssertionInfo
|
||||
import org.jetbrains.kotlin.psi.JetExpression
|
||||
import org.jetbrains.kotlin.psi.KtExpression
|
||||
import org.jetbrains.kotlin.util.slicedMap.BasicWritableSlice
|
||||
import org.jetbrains.kotlin.util.slicedMap.RewritePolicy
|
||||
import org.jetbrains.kotlin.util.slicedMap.WritableSlice
|
||||
import org.jetbrains.kotlin.utils.DO_NOTHING
|
||||
|
||||
public val RUNTIME_ASSERTION_INFO: WritableSlice<JetExpression, RuntimeAssertionInfo> = BasicWritableSlice(RewritePolicy.DO_NOTHING)
|
||||
public val RUNTIME_ASSERTION_INFO: WritableSlice<KtExpression, RuntimeAssertionInfo> = BasicWritableSlice(RewritePolicy.DO_NOTHING)
|
||||
|
||||
@@ -24,7 +24,7 @@ import com.intellij.psi.search.DelegatingGlobalSearchScope;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.idea.JetFileType;
|
||||
import org.jetbrains.kotlin.idea.KotlinFileType;
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaClass;
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaPackage;
|
||||
import org.jetbrains.kotlin.load.java.structure.impl.JavaClassImpl;
|
||||
@@ -64,7 +64,7 @@ public class JavaClassFinderImpl implements JavaClassFinder {
|
||||
javaSearchScope = new DelegatingGlobalSearchScope(baseScope) {
|
||||
@Override
|
||||
public boolean contains(@NotNull VirtualFile file) {
|
||||
return myBaseScope.contains(file) && (file.isDirectory() || file.getFileType() != JetFileType.INSTANCE);
|
||||
return myBaseScope.contains(file) && (file.isDirectory() || file.getFileType() != KotlinFileType.INSTANCE);
|
||||
}
|
||||
|
||||
//NOTE: expected by class finder to be not null
|
||||
|
||||
+6
-6
@@ -33,7 +33,7 @@ import org.jetbrains.kotlin.resolve.jvm.JavaDescriptorResolverKt;
|
||||
import org.jetbrains.kotlin.resolve.jvm.kotlinSignature.AlternativeFieldSignatureData;
|
||||
import org.jetbrains.kotlin.resolve.jvm.kotlinSignature.AlternativeMethodSignatureData;
|
||||
import org.jetbrains.kotlin.resolve.jvm.kotlinSignature.SignaturesPropagationData;
|
||||
import org.jetbrains.kotlin.types.JetType;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -55,8 +55,8 @@ public class TraceBasedExternalSignatureResolver implements ExternalSignatureRes
|
||||
public PropagatedMethodSignature resolvePropagatedSignature(
|
||||
@NotNull JavaMethod method,
|
||||
@NotNull ClassDescriptor owner,
|
||||
@NotNull JetType returnType,
|
||||
@Nullable JetType receiverType,
|
||||
@NotNull KtType returnType,
|
||||
@Nullable KtType receiverType,
|
||||
@NotNull List<ValueParameterDescriptor> valueParameters,
|
||||
@NotNull List<TypeParameterDescriptor> typeParameters
|
||||
) {
|
||||
@@ -72,8 +72,8 @@ public class TraceBasedExternalSignatureResolver implements ExternalSignatureRes
|
||||
public AlternativeMethodSignature resolveAlternativeMethodSignature(
|
||||
@NotNull JavaMember methodOrConstructor,
|
||||
boolean hasSuperMethods,
|
||||
@Nullable JetType returnType,
|
||||
@Nullable JetType receiverType,
|
||||
@Nullable KtType returnType,
|
||||
@Nullable KtType receiverType,
|
||||
@NotNull List<ValueParameterDescriptor> valueParameters,
|
||||
@NotNull List<TypeParameterDescriptor> typeParameters,
|
||||
boolean hasStableParameterNames
|
||||
@@ -102,7 +102,7 @@ public class TraceBasedExternalSignatureResolver implements ExternalSignatureRes
|
||||
@NotNull
|
||||
public AlternativeFieldSignature resolveAlternativeFieldSignature(
|
||||
@NotNull JavaField field,
|
||||
@NotNull JetType returnType,
|
||||
@NotNull KtType returnType,
|
||||
boolean isVar
|
||||
) {
|
||||
AlternativeFieldSignatureData data = new AlternativeFieldSignatureData(field, returnType, project, isVar);
|
||||
|
||||
+6
-6
@@ -21,7 +21,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl;
|
||||
import org.jetbrains.kotlin.resolve.ExternalOverridabilityCondition;
|
||||
import org.jetbrains.kotlin.types.JetType;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.TypeSubstitutor;
|
||||
import org.jetbrains.kotlin.types.TypeUtils;
|
||||
|
||||
@@ -57,7 +57,7 @@ public class SamAdapterOverridabilityCondition implements ExternalOverridability
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean differentClasses(@NotNull JetType type1, @NotNull JetType type2) {
|
||||
private static boolean differentClasses(@NotNull KtType type1, @NotNull KtType type2) {
|
||||
DeclarationDescriptor declarationDescriptor1 = type1.getConstructor().getDeclarationDescriptor();
|
||||
if (declarationDescriptor1 == null) return true; // No class, classes are not equal
|
||||
DeclarationDescriptor declarationDescriptor2 = type2.getConstructor().getDeclarationDescriptor();
|
||||
@@ -100,7 +100,7 @@ public class SamAdapterOverridabilityCondition implements ExternalOverridability
|
||||
@Nullable
|
||||
private static SamAdapterInfo getNearestDeclarationOrSynthesized(
|
||||
@NotNull SimpleFunctionDescriptor samAdapter,
|
||||
@NotNull JetType ownerType
|
||||
@NotNull KtType ownerType
|
||||
) {
|
||||
if (samAdapter.getKind() != CallableMemberDescriptor.Kind.FAKE_OVERRIDE) {
|
||||
return new SamAdapterInfo(samAdapter, ownerType);
|
||||
@@ -109,7 +109,7 @@ public class SamAdapterOverridabilityCondition implements ExternalOverridability
|
||||
for (CallableMemberDescriptor overridden : samAdapter.getOverriddenDescriptors()) {
|
||||
ClassDescriptor containingClass = (ClassDescriptor) overridden.getContainingDeclaration();
|
||||
|
||||
for (JetType immediateSupertype : TypeUtils.getImmediateSupertypes(ownerType)) {
|
||||
for (KtType immediateSupertype : TypeUtils.getImmediateSupertypes(ownerType)) {
|
||||
if (containingClass != immediateSupertype.getConstructor().getDeclarationDescriptor()) {
|
||||
continue;
|
||||
}
|
||||
@@ -126,9 +126,9 @@ public class SamAdapterOverridabilityCondition implements ExternalOverridability
|
||||
|
||||
private static class SamAdapterInfo {
|
||||
private final SimpleFunctionDescriptor samAdapter;
|
||||
private final JetType ownerType;
|
||||
private final KtType ownerType;
|
||||
|
||||
private SamAdapterInfo(@NotNull SimpleFunctionDescriptor samAdapter, @NotNull JetType ownerType) {
|
||||
private SamAdapterInfo(@NotNull SimpleFunctionDescriptor samAdapter, @NotNull KtType ownerType) {
|
||||
this.samAdapter = samAdapter;
|
||||
this.ownerType = ownerType;
|
||||
}
|
||||
|
||||
+7
-7
@@ -18,21 +18,21 @@ package org.jetbrains.kotlin.load.java.sam
|
||||
|
||||
import org.jetbrains.kotlin.load.java.components.SamConversionResolver
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.KtScope
|
||||
import org.jetbrains.kotlin.load.java.descriptors.*
|
||||
import org.jetbrains.kotlin.load.java.lazy.descriptors.LazyJavaClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaMethod
|
||||
import org.jetbrains.kotlin.types.JetType
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.load.java.sources.JavaSourceElement
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaClass
|
||||
import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
import java.util.ArrayList
|
||||
import org.jetbrains.kotlin.types.checker.JetTypeChecker
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
|
||||
|
||||
public object SamConversionResolverImpl : SamConversionResolver {
|
||||
override fun resolveSamConstructor(name: Name, scope: JetScope): SamConstructorDescriptor? {
|
||||
override fun resolveSamConstructor(name: Name, scope: KtScope): SamConstructorDescriptor? {
|
||||
val classifier = scope.getClassifier(name) as? LazyJavaClassDescriptor ?: return null
|
||||
if (classifier.getFunctionTypeForSamInterface() == null) return null
|
||||
return SingleAbstractMethodUtils.createSamConstructorFunction(scope.getContainingDeclaration(), classifier)
|
||||
@@ -51,7 +51,7 @@ public object SamConversionResolverImpl : SamConversionResolver {
|
||||
override fun resolveFunctionTypeIfSamInterface(
|
||||
classDescriptor: JavaClassDescriptor,
|
||||
resolveMethod: (JavaMethod) -> FunctionDescriptor
|
||||
): JetType? {
|
||||
): KtType? {
|
||||
val jClass = (classDescriptor.getSource() as? JavaSourceElement)?.javaElement as? JavaClass ?: return null
|
||||
val samInterfaceMethod = SingleAbstractMethodUtils.getSamInterfaceMethod(jClass) ?: return null
|
||||
val abstractMethod = if (jClass.getFqName() == samInterfaceMethod.getContainingClass().getFqName()) {
|
||||
@@ -63,7 +63,7 @@ public object SamConversionResolverImpl : SamConversionResolver {
|
||||
return SingleAbstractMethodUtils.getFunctionTypeForAbstractMethod(abstractMethod)
|
||||
}
|
||||
|
||||
private fun findFunctionWithMostSpecificReturnType(supertypes: Set<JetType>): SimpleFunctionDescriptor {
|
||||
private fun findFunctionWithMostSpecificReturnType(supertypes: Set<KtType>): SimpleFunctionDescriptor {
|
||||
val candidates = ArrayList<SimpleFunctionDescriptor>(supertypes.size())
|
||||
for (supertype in supertypes) {
|
||||
val abstractMembers = SingleAbstractMethodUtils.getAbstractMembers(supertype)
|
||||
@@ -79,7 +79,7 @@ public object SamConversionResolverImpl : SamConversionResolver {
|
||||
val candidateReturnType = candidate.getReturnType()
|
||||
val currentMostSpecificReturnType = currentMostSpecificType.getReturnType()
|
||||
assert(candidateReturnType != null && currentMostSpecificReturnType != null) { "$candidate, $currentMostSpecificReturnType" }
|
||||
if (JetTypeChecker.DEFAULT.isSubtypeOf(candidateReturnType!!, currentMostSpecificReturnType!!)) {
|
||||
if (KotlinTypeChecker.DEFAULT.isSubtypeOf(candidateReturnType!!, currentMostSpecificReturnType!!)) {
|
||||
currentMostSpecificType = candidate
|
||||
}
|
||||
}
|
||||
|
||||
+25
-25
@@ -43,7 +43,7 @@ public class SingleAbstractMethodUtils {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static List<CallableMemberDescriptor> getAbstractMembers(@NotNull JetType type) {
|
||||
public static List<CallableMemberDescriptor> getAbstractMembers(@NotNull KtType type) {
|
||||
List<CallableMemberDescriptor> abstractMembers = new ArrayList<CallableMemberDescriptor>();
|
||||
for (DeclarationDescriptor member : type.getMemberScope().getAllDescriptors()) {
|
||||
if (member instanceof CallableMemberDescriptor && ((CallableMemberDescriptor) member).getModality() == Modality.ABSTRACT) {
|
||||
@@ -53,7 +53,7 @@ public class SingleAbstractMethodUtils {
|
||||
return abstractMembers;
|
||||
}
|
||||
|
||||
private static JetType fixProjections(@NotNull JetType functionType) {
|
||||
private static KtType fixProjections(@NotNull KtType functionType) {
|
||||
//removes redundant projection kinds and detects conflicts
|
||||
|
||||
List<TypeParameterDescriptor> typeParameters = functionType.getConstructor().getParameters();
|
||||
@@ -76,7 +76,7 @@ public class SingleAbstractMethodUtils {
|
||||
}
|
||||
ClassifierDescriptor classifier = functionType.getConstructor().getDeclarationDescriptor();
|
||||
assert classifier instanceof ClassDescriptor : "Not class: " + classifier;
|
||||
return JetTypeImpl.create(
|
||||
return KtTypeImpl.create(
|
||||
functionType.getAnnotations(),
|
||||
functionType.getConstructor(),
|
||||
functionType.isMarkedNullable(),
|
||||
@@ -86,21 +86,21 @@ public class SingleAbstractMethodUtils {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static JetType getFunctionTypeForSamType(@NotNull JetType samType) {
|
||||
public static KtType getFunctionTypeForSamType(@NotNull KtType samType) {
|
||||
// e.g. samType == Comparator<String>?
|
||||
|
||||
ClassifierDescriptor classifier = samType.getConstructor().getDeclarationDescriptor();
|
||||
if (classifier instanceof JavaClassDescriptor) {
|
||||
// Function2<T, T, Int>
|
||||
JetType functionTypeDefault = ((JavaClassDescriptor) classifier).getFunctionTypeForSamInterface();
|
||||
KtType functionTypeDefault = ((JavaClassDescriptor) classifier).getFunctionTypeForSamInterface();
|
||||
|
||||
if (functionTypeDefault != null) {
|
||||
// Function2<String, String, Int>?
|
||||
JetType substitute = TypeSubstitutor.create(samType).substitute(functionTypeDefault, Variance.INVARIANT);
|
||||
KtType substitute = TypeSubstitutor.create(samType).substitute(functionTypeDefault, Variance.INVARIANT);
|
||||
|
||||
if (substitute == null) return null;
|
||||
|
||||
JetType type = fixProjections(substitute);
|
||||
KtType type = fixProjections(substitute);
|
||||
if (type == null) return null;
|
||||
|
||||
if (JavaDescriptorResolverKt.getPLATFORM_TYPES() && FlexibleTypesKt.isNullabilityFlexible(samType)) {
|
||||
@@ -114,11 +114,11 @@ public class SingleAbstractMethodUtils {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static JetType getFunctionTypeForAbstractMethod(@NotNull FunctionDescriptor function) {
|
||||
JetType returnType = function.getReturnType();
|
||||
public static KtType getFunctionTypeForAbstractMethod(@NotNull FunctionDescriptor function) {
|
||||
KtType returnType = function.getReturnType();
|
||||
assert returnType != null : "function is not initialized: " + function;
|
||||
List<ValueParameterDescriptor> valueParameters = function.getValueParameters();
|
||||
List<JetType> parameterTypes = new ArrayList<JetType>(valueParameters.size());
|
||||
List<KtType> parameterTypes = new ArrayList<KtType>(valueParameters.size());
|
||||
for (ValueParameterDescriptor parameter : valueParameters) {
|
||||
parameterTypes.add(parameter.getType());
|
||||
}
|
||||
@@ -151,9 +151,9 @@ public class SingleAbstractMethodUtils {
|
||||
|
||||
TypeParameters typeParameters = recreateAndInitializeTypeParameters(samInterface.getTypeConstructor().getParameters(), result);
|
||||
|
||||
JetType parameterTypeUnsubstituted = getFunctionTypeForSamType(samInterface.getDefaultType());
|
||||
KtType parameterTypeUnsubstituted = getFunctionTypeForSamType(samInterface.getDefaultType());
|
||||
assert parameterTypeUnsubstituted != null : "couldn't get function type for SAM type " + samInterface.getDefaultType();
|
||||
JetType parameterType = typeParameters.substitutor.substitute(parameterTypeUnsubstituted, Variance.IN_VARIANCE);
|
||||
KtType parameterType = typeParameters.substitutor.substitute(parameterTypeUnsubstituted, Variance.IN_VARIANCE);
|
||||
assert parameterType != null : "couldn't substitute type: " + parameterTypeUnsubstituted +
|
||||
", substitutor = " + typeParameters.substitutor;
|
||||
ValueParameterDescriptor parameter = new ValueParameterDescriptorImpl(
|
||||
@@ -163,7 +163,7 @@ public class SingleAbstractMethodUtils {
|
||||
/* isNoinline = */ false,
|
||||
null, SourceElement.NO_SOURCE);
|
||||
|
||||
JetType returnType = typeParameters.substitutor.substitute(samInterface.getDefaultType(), Variance.OUT_VARIANCE);
|
||||
KtType returnType = typeParameters.substitutor.substitute(samInterface.getDefaultType(), Variance.OUT_VARIANCE);
|
||||
assert returnType != null : "couldn't substitute type: " + samInterface.getDefaultType() +
|
||||
", substitutor = " + typeParameters.substitutor;
|
||||
|
||||
@@ -180,7 +180,7 @@ public class SingleAbstractMethodUtils {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static boolean isSamType(@NotNull JetType type) {
|
||||
public static boolean isSamType(@NotNull KtType type) {
|
||||
return getFunctionTypeForSamType(type) != null;
|
||||
}
|
||||
|
||||
@@ -201,7 +201,7 @@ public class SingleAbstractMethodUtils {
|
||||
public void initialize(
|
||||
@NotNull List<TypeParameterDescriptor> typeParameters,
|
||||
@NotNull List<ValueParameterDescriptor> valueParameters,
|
||||
@NotNull JetType returnType
|
||||
@NotNull KtType returnType
|
||||
) {
|
||||
result.initialize(
|
||||
null,
|
||||
@@ -224,7 +224,7 @@ public class SingleAbstractMethodUtils {
|
||||
public void initialize(
|
||||
@NotNull List<TypeParameterDescriptor> typeParameters,
|
||||
@NotNull List<ValueParameterDescriptor> valueParameters,
|
||||
@NotNull JetType returnType
|
||||
@NotNull KtType returnType
|
||||
) {
|
||||
result.initialize(typeParameters, valueParameters, original.getVisibility());
|
||||
result.setReturnType(returnType);
|
||||
@@ -240,11 +240,11 @@ public class SingleAbstractMethodUtils {
|
||||
) {
|
||||
TypeParameters typeParameters = recreateAndInitializeTypeParameters(original.getTypeParameters(), adapter);
|
||||
|
||||
JetType returnTypeUnsubstituted = original.getReturnType();
|
||||
KtType returnTypeUnsubstituted = original.getReturnType();
|
||||
assert returnTypeUnsubstituted != null : "Creating SAM adapter for not initialized original: " + original;
|
||||
|
||||
TypeSubstitutor substitutor = typeParameters.substitutor;
|
||||
JetType returnType = substitutor.substitute(returnTypeUnsubstituted, Variance.INVARIANT);
|
||||
KtType returnType = substitutor.substitute(returnTypeUnsubstituted, Variance.INVARIANT);
|
||||
assert returnType != null : "couldn't substitute type: " + returnTypeUnsubstituted +
|
||||
", substitutor = " + substitutor;
|
||||
|
||||
@@ -264,10 +264,10 @@ public class SingleAbstractMethodUtils {
|
||||
List<ValueParameterDescriptor> originalValueParameters = original.getValueParameters();
|
||||
List<ValueParameterDescriptor> valueParameters = new ArrayList<ValueParameterDescriptor>(originalValueParameters.size());
|
||||
for (ValueParameterDescriptor originalParam : originalValueParameters) {
|
||||
JetType originalType = originalParam.getType();
|
||||
JetType functionType = getFunctionTypeForSamType(originalType);
|
||||
JetType newTypeUnsubstituted = functionType != null ? functionType : originalType;
|
||||
JetType newType = substitutor.substitute(newTypeUnsubstituted, Variance.IN_VARIANCE);
|
||||
KtType originalType = originalParam.getType();
|
||||
KtType functionType = getFunctionTypeForSamType(originalType);
|
||||
KtType newTypeUnsubstituted = functionType != null ? functionType : originalType;
|
||||
KtType newType = substitutor.substitute(newTypeUnsubstituted, Variance.IN_VARIANCE);
|
||||
assert newType != null : "couldn't substitute type: " + newTypeUnsubstituted + ", substitutor = " + substitutor;
|
||||
|
||||
ValueParameterDescriptor newParam = new ValueParameterDescriptorImpl(
|
||||
@@ -295,8 +295,8 @@ public class SingleAbstractMethodUtils {
|
||||
TypeParameterDescriptor traitTypeParameter = mapEntry.getKey();
|
||||
TypeParameterDescriptorImpl funTypeParameter = mapEntry.getValue();
|
||||
|
||||
for (JetType upperBound : traitTypeParameter.getUpperBounds()) {
|
||||
JetType upperBoundSubstituted = typeParametersSubstitutor.substitute(upperBound, Variance.INVARIANT);
|
||||
for (KtType upperBound : traitTypeParameter.getUpperBounds()) {
|
||||
KtType upperBoundSubstituted = typeParametersSubstitutor.substitute(upperBound, Variance.INVARIANT);
|
||||
assert upperBoundSubstituted != null : "couldn't substitute type: " + upperBound + ", substitutor = " + typeParametersSubstitutor;
|
||||
funTypeParameter.addUpperBound(upperBoundSubstituted);
|
||||
}
|
||||
@@ -345,7 +345,7 @@ public class SingleAbstractMethodUtils {
|
||||
public abstract void initialize(
|
||||
@NotNull List<TypeParameterDescriptor> typeParameters,
|
||||
@NotNull List<ValueParameterDescriptor> valueParameters,
|
||||
@NotNull JetType returnType
|
||||
@NotNull KtType returnType
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
+5
-5
@@ -27,8 +27,8 @@ import org.jetbrains.kotlin.load.java.components.JavaAnnotationMapper
|
||||
import org.jetbrains.kotlin.load.java.descriptors.JavaConstructorDescriptor
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.FqNameUnsafe
|
||||
import org.jetbrains.kotlin.psi.JetAnnotationEntry
|
||||
import org.jetbrains.kotlin.psi.JetExpression
|
||||
import org.jetbrains.kotlin.psi.KtAnnotationEntry
|
||||
import org.jetbrains.kotlin.psi.KtExpression
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.calls.checkers.CallChecker
|
||||
@@ -37,7 +37,7 @@ import org.jetbrains.kotlin.resolve.calls.model.ExpressionValueArgument
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedValueArgument
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm
|
||||
import org.jetbrains.kotlin.types.JetType
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
import java.lang.annotation.Target
|
||||
|
||||
@@ -52,7 +52,7 @@ public class JavaAnnotationCallChecker : CallChecker {
|
||||
}
|
||||
|
||||
private fun reportDeprecatedJavaAnnotation(resolvedCall: ResolvedCall<*>, context: BasicCallResolutionContext) {
|
||||
val annotationEntry = resolvedCall.call.callElement as? JetAnnotationEntry ?: return
|
||||
val annotationEntry = resolvedCall.call.callElement as? KtAnnotationEntry ?: return
|
||||
val type = context.trace.get(BindingContext.TYPE, annotationEntry.typeReference) ?: return
|
||||
JavaAnnotationMapper.javaToKotlinNameMap[type.constructor.declarationDescriptor?.let { DescriptorUtils.getFqNameSafe(it) }]?.let {
|
||||
context.trace.report(ErrorsJvm.DEPRECATED_JAVA_ANNOTATION.on(annotationEntry, it))
|
||||
@@ -71,7 +71,7 @@ public class JavaAnnotationCallChecker : CallChecker {
|
||||
private fun reportOnValueArgument(
|
||||
context: BasicCallResolutionContext,
|
||||
argument: Map.Entry<ValueParameterDescriptor, ResolvedValueArgument>,
|
||||
diagnostic: DiagnosticFactory0<JetExpression>
|
||||
diagnostic: DiagnosticFactory0<KtExpression>
|
||||
) {
|
||||
argument.getValue().getArguments().forEach {
|
||||
if (it.getArgumentExpression() != null) {
|
||||
|
||||
+8
-8
@@ -22,9 +22,9 @@ import org.jetbrains.annotations.TestOnly
|
||||
import org.jetbrains.kotlin.load.java.JvmAbi
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi.JetFile
|
||||
import org.jetbrains.kotlin.psi.JetNamedFunction
|
||||
import org.jetbrains.kotlin.psi.JetProperty
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.psi.KtNamedFunction
|
||||
import org.jetbrains.kotlin.psi.KtProperty
|
||||
import org.jetbrains.kotlin.resolve.jvm.JvmClassName
|
||||
import java.util.*
|
||||
|
||||
@@ -67,21 +67,21 @@ public object PackagePartClassUtils {
|
||||
|
||||
@Deprecated("Migrate to JvmFileClassesProvider")
|
||||
@JvmStatic
|
||||
public fun getPackagePartInternalName(file: JetFile): String =
|
||||
public fun getPackagePartInternalName(file: KtFile): String =
|
||||
JvmClassName.byFqNameWithoutInnerClasses(getPackagePartFqName(file)).internalName
|
||||
|
||||
@Deprecated("Migrate to JvmFileClassesProvider")
|
||||
@JvmStatic
|
||||
public fun getPackagePartFqName(file: JetFile): FqName =
|
||||
public fun getPackagePartFqName(file: KtFile): FqName =
|
||||
getPackagePartFqName(file.packageFqName, file.name)
|
||||
|
||||
@JvmStatic
|
||||
public fun getFilesWithCallables(files: Collection<JetFile>): List<JetFile> =
|
||||
public fun getFilesWithCallables(files: Collection<KtFile>): List<KtFile> =
|
||||
files.filter { fileHasTopLevelCallables(it) }
|
||||
|
||||
@JvmStatic
|
||||
public fun fileHasTopLevelCallables(file: JetFile): Boolean =
|
||||
file.declarations.any { it is JetProperty || it is JetNamedFunction }
|
||||
public fun fileHasTopLevelCallables(file: KtFile): Boolean =
|
||||
file.declarations.any { it is KtProperty || it is KtNamedFunction }
|
||||
|
||||
@JvmStatic
|
||||
public fun getFilePartShortName(fileName: String): String =
|
||||
|
||||
+11
-11
@@ -30,10 +30,10 @@ import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCache
|
||||
import org.jetbrains.kotlin.modules.TargetId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi.JetFile
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.resolve.jvm.JvmClassName
|
||||
import org.jetbrains.kotlin.resolve.scopes.ChainedScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.KtScope
|
||||
import org.jetbrains.kotlin.serialization.PackageData
|
||||
import org.jetbrains.kotlin.serialization.ProtoBuf
|
||||
import org.jetbrains.kotlin.serialization.deserialization.DeserializationComponents
|
||||
@@ -45,7 +45,7 @@ import org.jetbrains.kotlin.utils.addToStdlib.singletonOrEmptyList
|
||||
import java.util.*
|
||||
|
||||
public class IncrementalPackageFragmentProvider(
|
||||
sourceFiles: Collection<JetFile>,
|
||||
sourceFiles: Collection<KtFile>,
|
||||
val moduleDescriptor: ModuleDescriptor,
|
||||
val storageManager: StorageManager,
|
||||
val deserializationComponents: DeserializationComponents,
|
||||
@@ -56,7 +56,7 @@ public class IncrementalPackageFragmentProvider(
|
||||
companion object {
|
||||
private val LOG = Logger.getLogger(IncrementalPackageFragmentProvider::class.java)
|
||||
|
||||
public fun fqNamesToLoad(obsoletePackageParts: Collection<String>, sourceFiles: Collection<JetFile>): Set<FqName> =
|
||||
public fun fqNamesToLoad(obsoletePackageParts: Collection<String>, sourceFiles: Collection<KtFile>): Set<FqName> =
|
||||
(obsoletePackageParts.map { JvmClassName.byInternalName(it).packageFqName }
|
||||
+ PackagePartClassUtils.getFilesWithCallables(sourceFiles).map { it.packageFqName }).toSet()
|
||||
}
|
||||
@@ -97,9 +97,9 @@ public class IncrementalPackageFragmentProvider(
|
||||
public val target: TargetId
|
||||
get() = this@IncrementalPackageFragmentProvider.target
|
||||
|
||||
val memberScope: NotNullLazyValue<JetScope> = storageManager.createLazyValue {
|
||||
val memberScope: NotNullLazyValue<KtScope> = storageManager.createLazyValue {
|
||||
if (fqName !in fqNamesToLoad) {
|
||||
JetScope.Empty
|
||||
KtScope.Empty
|
||||
}
|
||||
else {
|
||||
val moduleMapping = incrementalCache.getModuleMappingData()?.let { ModuleMapping.create(it) }
|
||||
@@ -128,7 +128,7 @@ public class IncrementalPackageFragmentProvider(
|
||||
}
|
||||
|
||||
if (scopes.isEmpty()) {
|
||||
JetScope.Empty
|
||||
KtScope.Empty
|
||||
}
|
||||
else {
|
||||
ChainedScope(this, "Member scope for incremental compilation: union of package parts data", *scopes.toTypedArray())
|
||||
@@ -142,7 +142,7 @@ public class IncrementalPackageFragmentProvider(
|
||||
return IncrementalMultifileClassPackageFragment(multifileClassFqName, partsNames)
|
||||
}
|
||||
|
||||
override fun getMemberScope(): JetScope = memberScope()
|
||||
override fun getMemberScope(): KtScope = memberScope()
|
||||
|
||||
public inner class IncrementalMultifileClassPackageFragment(
|
||||
val multifileClassFqName: FqName,
|
||||
@@ -151,16 +151,16 @@ public class IncrementalPackageFragmentProvider(
|
||||
val memberScope = storageManager.createLazyValue {
|
||||
val partsData = partsNames.map { incrementalCache.getPackagePartData(it) }.filterNotNull()
|
||||
if (partsData.isEmpty())
|
||||
JetScope.Empty
|
||||
KtScope.Empty
|
||||
else {
|
||||
val scopes = partsData.map { IncrementalPackageScope(JvmProtoBufUtil.readPackageDataFrom(it.data, it.strings)) }
|
||||
ChainedScope(this,
|
||||
"Member scope for incremental compilation: union of multifile class parts data for $multifileClassFqName",
|
||||
*scopes.toTypedArray<JetScope>())
|
||||
*scopes.toTypedArray<KtScope>())
|
||||
}
|
||||
}
|
||||
|
||||
override fun getMemberScope(): JetScope = memberScope()
|
||||
override fun getMemberScope(): KtScope = memberScope()
|
||||
}
|
||||
|
||||
private inner class IncrementalPackageScope(val packageData: PackageData) : DeserializedPackageMemberScope(
|
||||
|
||||
+3
-3
@@ -21,12 +21,12 @@ import org.jetbrains.kotlin.load.kotlin.ModuleMapping
|
||||
import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCache
|
||||
import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCompilationComponents
|
||||
import org.jetbrains.kotlin.modules.TargetId
|
||||
import org.jetbrains.kotlin.psi.JetFile
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.storage.StorageManager
|
||||
|
||||
internal class IncrementalPackagePartProvider private constructor(
|
||||
private val parent: PackagePartProvider,
|
||||
sourceFiles: Collection<JetFile>,
|
||||
sourceFiles: Collection<KtFile>,
|
||||
incrementalCaches: List<IncrementalCache>,
|
||||
storageManager: StorageManager
|
||||
) : PackagePartProvider {
|
||||
@@ -46,7 +46,7 @@ internal class IncrementalPackagePartProvider private constructor(
|
||||
@JvmStatic
|
||||
public fun create(
|
||||
parent: PackagePartProvider,
|
||||
sourceFiles: Collection<JetFile>,
|
||||
sourceFiles: Collection<KtFile>,
|
||||
targets: List<TargetId>?,
|
||||
incrementalCompilationComponents: IncrementalCompilationComponents?,
|
||||
storageManager: StorageManager
|
||||
|
||||
@@ -18,14 +18,11 @@ package org.jetbrains.kotlin.load.kotlin.nativeDeclarations
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticSink
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.psi.JetDeclaration
|
||||
import org.jetbrains.kotlin.psi.JetDeclarationWithBody
|
||||
import org.jetbrains.kotlin.psi.KtDeclaration
|
||||
import org.jetbrains.kotlin.psi.KtDeclarationWithBody
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.DeclarationChecker
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.diagnostics.FUNCTION_NO_BODY_ERRORS
|
||||
import org.jetbrains.kotlin.resolve.diagnostics.SuppressDiagnosticsByAnnotations
|
||||
import org.jetbrains.kotlin.resolve.inline.InlineUtil
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm
|
||||
|
||||
@@ -35,7 +32,7 @@ public fun DeclarationDescriptor.hasNativeAnnotation(): Boolean {
|
||||
|
||||
public class NativeFunChecker : DeclarationChecker {
|
||||
override fun check(
|
||||
declaration: JetDeclaration,
|
||||
declaration: KtDeclaration,
|
||||
descriptor: DeclarationDescriptor,
|
||||
diagnosticHolder: DiagnosticSink,
|
||||
bindingContext: BindingContext
|
||||
@@ -50,7 +47,7 @@ public class NativeFunChecker : DeclarationChecker {
|
||||
diagnosticHolder.report(ErrorsJvm.EXTERNAL_DECLARATION_CANNOT_BE_ABSTRACT.on(declaration))
|
||||
}
|
||||
|
||||
if (descriptor !is ConstructorDescriptor && declaration is JetDeclarationWithBody && declaration.hasBody()) {
|
||||
if (descriptor !is ConstructorDescriptor && declaration is KtDeclarationWithBody && declaration.hasBody()) {
|
||||
diagnosticHolder.report(ErrorsJvm.EXTERNAL_DECLARATION_CANNOT_HAVE_BODY.on(declaration))
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ import org.jetbrains.kotlin.frontend.java.di.createContainerForLazyResolveWithJa
|
||||
import org.jetbrains.kotlin.load.java.lazy.ModuleClassResolverImpl
|
||||
import org.jetbrains.kotlin.descriptors.PackagePartProvider
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaClass
|
||||
import org.jetbrains.kotlin.psi.JetFile
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.resolve.CodeAnalyzerInitializer
|
||||
import org.jetbrains.kotlin.resolve.TargetEnvironment
|
||||
import org.jetbrains.kotlin.resolve.TargetPlatform
|
||||
@@ -83,7 +83,7 @@ public object JvmAnalyzerFacade : AnalyzerFacade<JvmPlatformParameters>() {
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
public fun getAllFilesToAnalyze(project: Project, moduleInfo: ModuleInfo?, baseFiles: Collection<JetFile>): List<JetFile> {
|
||||
public fun getAllFilesToAnalyze(project: Project, moduleInfo: ModuleInfo?, baseFiles: Collection<KtFile>): List<KtFile> {
|
||||
val allFiles = ArrayList(baseFiles)
|
||||
for (externalDeclarationsProvider in ExternalDeclarationsProvider.getInstances(project)) {
|
||||
allFiles.addAll(externalDeclarationsProvider.getExternalDeclarations(moduleInfo))
|
||||
|
||||
+5
-5
@@ -38,7 +38,7 @@ import org.jetbrains.kotlin.modules.Module;
|
||||
import org.jetbrains.kotlin.modules.TargetId;
|
||||
import org.jetbrains.kotlin.modules.TargetIdKt;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.psi.JetFile;
|
||||
import org.jetbrains.kotlin.psi.KtFile;
|
||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
||||
import org.jetbrains.kotlin.resolve.BindingTrace;
|
||||
import org.jetbrains.kotlin.resolve.TopDownAnalysisMode;
|
||||
@@ -57,7 +57,7 @@ public enum TopDownAnalyzerFacadeForJVM {
|
||||
@NotNull
|
||||
public static AnalysisResult analyzeFilesWithJavaIntegrationNoIncremental(
|
||||
@NotNull ModuleContext moduleContext,
|
||||
@NotNull Collection<JetFile> files,
|
||||
@NotNull Collection<KtFile> files,
|
||||
@NotNull BindingTrace trace,
|
||||
@NotNull TopDownAnalysisMode topDownAnalysisMode,
|
||||
PackagePartProvider packagePartProvider
|
||||
@@ -68,7 +68,7 @@ public enum TopDownAnalyzerFacadeForJVM {
|
||||
@NotNull
|
||||
public static AnalysisResult analyzeFilesWithJavaIntegrationWithCustomContext(
|
||||
@NotNull ModuleContext moduleContext,
|
||||
@NotNull Collection<JetFile> files,
|
||||
@NotNull Collection<KtFile> files,
|
||||
@NotNull BindingTrace trace,
|
||||
@Nullable List<Module> modules,
|
||||
@Nullable IncrementalCompilationComponents incrementalCompilationComponents,
|
||||
@@ -82,7 +82,7 @@ public enum TopDownAnalyzerFacadeForJVM {
|
||||
@NotNull
|
||||
private static AnalysisResult analyzeFilesWithJavaIntegration(
|
||||
@NotNull ModuleContext moduleContext,
|
||||
@NotNull Collection<JetFile> files,
|
||||
@NotNull Collection<KtFile> files,
|
||||
@NotNull BindingTrace trace,
|
||||
@NotNull TopDownAnalysisMode topDownAnalysisMode,
|
||||
@Nullable List<Module> modules,
|
||||
@@ -90,7 +90,7 @@ public enum TopDownAnalyzerFacadeForJVM {
|
||||
@NotNull PackagePartProvider packagePartProvider
|
||||
) {
|
||||
Project project = moduleContext.getProject();
|
||||
List<JetFile> allFiles = JvmAnalyzerFacade.getAllFilesToAnalyze(project, null, files);
|
||||
List<KtFile> allFiles = JvmAnalyzerFacade.getAllFilesToAnalyze(project, null, files);
|
||||
|
||||
FileBasedDeclarationProviderFactory providerFactory =
|
||||
new FileBasedDeclarationProviderFactory(moduleContext.getStorageManager(), allFiles);
|
||||
|
||||
+2
-2
@@ -25,7 +25,7 @@ import org.jetbrains.kotlin.resolve.calls.checkers.CallChecker
|
||||
import org.jetbrains.kotlin.resolve.calls.context.BasicCallResolutionContext
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm
|
||||
import org.jetbrains.kotlin.types.JetTypeImpl
|
||||
import org.jetbrains.kotlin.types.KtTypeImpl
|
||||
import org.jetbrains.kotlin.types.TypeProjectionImpl
|
||||
|
||||
public class JavaClassOnCompanionChecker : CallChecker {
|
||||
@@ -42,7 +42,7 @@ public class JavaClassOnCompanionChecker : CallChecker {
|
||||
if (companionObject.isCompanionObject) {
|
||||
val containingClass = companionObject.containingDeclaration as ClassDescriptor
|
||||
val javaLangClass = actualType.constructor.declarationDescriptor as? ClassDescriptor ?: return
|
||||
val expectedType = JetTypeImpl.create(
|
||||
val expectedType = KtTypeImpl.create(
|
||||
Annotations.EMPTY, javaLangClass, actualType.isMarkedNullable,
|
||||
listOf(TypeProjectionImpl(containingClass.defaultType))
|
||||
)
|
||||
|
||||
+20
-20
@@ -19,13 +19,13 @@ package org.jetbrains.kotlin.resolve.jvm.checkers
|
||||
import org.jetbrains.kotlin.cfg.WhenChecker
|
||||
import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.lexer.JetTokens
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.load.java.lazy.types.isMarkedNotNull
|
||||
import org.jetbrains.kotlin.load.java.lazy.types.isMarkedNullable
|
||||
import org.jetbrains.kotlin.psi.JetBinaryExpression
|
||||
import org.jetbrains.kotlin.psi.JetExpression
|
||||
import org.jetbrains.kotlin.psi.JetPostfixExpression
|
||||
import org.jetbrains.kotlin.psi.JetWhenExpression
|
||||
import org.jetbrains.kotlin.psi.KtBinaryExpression
|
||||
import org.jetbrains.kotlin.psi.KtExpression
|
||||
import org.jetbrains.kotlin.psi.KtPostfixExpression
|
||||
import org.jetbrains.kotlin.psi.KtWhenExpression
|
||||
import org.jetbrains.kotlin.resolve.calls.checkers.AdditionalTypeChecker
|
||||
import org.jetbrains.kotlin.resolve.calls.context.CallResolutionContext
|
||||
import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext
|
||||
@@ -36,14 +36,14 @@ import org.jetbrains.kotlin.resolve.calls.smartcasts.Nullability
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
||||
import org.jetbrains.kotlin.types.JetType
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
import org.jetbrains.kotlin.types.expressions.SenselessComparisonChecker
|
||||
import org.jetbrains.kotlin.types.flexibility
|
||||
import org.jetbrains.kotlin.types.isFlexible
|
||||
|
||||
public class JavaNullabilityWarningsChecker : AdditionalTypeChecker {
|
||||
private fun JetType.mayBeNull(): ErrorsJvm.NullabilityInformationSource? {
|
||||
private fun KtType.mayBeNull(): ErrorsJvm.NullabilityInformationSource? {
|
||||
if (!isError() && !isFlexible() && TypeUtils.isNullableType(this)) return ErrorsJvm.NullabilityInformationSource.KOTLIN
|
||||
|
||||
if (isFlexible() && TypeUtils.isNullableType(flexibility().lowerBound)) return ErrorsJvm.NullabilityInformationSource.KOTLIN
|
||||
@@ -52,7 +52,7 @@ public class JavaNullabilityWarningsChecker : AdditionalTypeChecker {
|
||||
return null
|
||||
}
|
||||
|
||||
private fun JetType.mustNotBeNull(): ErrorsJvm.NullabilityInformationSource? {
|
||||
private fun KtType.mustNotBeNull(): ErrorsJvm.NullabilityInformationSource? {
|
||||
if (!isError() && !isFlexible() && !TypeUtils.isNullableType(this)) return ErrorsJvm.NullabilityInformationSource.KOTLIN
|
||||
|
||||
if (isFlexible() && !TypeUtils.isNullableType(flexibility().upperBound)) return ErrorsJvm.NullabilityInformationSource.KOTLIN
|
||||
@@ -62,8 +62,8 @@ public class JavaNullabilityWarningsChecker : AdditionalTypeChecker {
|
||||
}
|
||||
|
||||
private fun doCheckType(
|
||||
expressionType: JetType,
|
||||
expectedType: JetType,
|
||||
expressionType: KtType,
|
||||
expectedType: KtType,
|
||||
dataFlowValue: DataFlowValue,
|
||||
dataFlowInfo: DataFlowInfo,
|
||||
reportWarning: (expectedMustNotBeNull: ErrorsJvm.NullabilityInformationSource, actualMayBeNull: ErrorsJvm.NullabilityInformationSource) -> Unit
|
||||
@@ -85,7 +85,7 @@ public class JavaNullabilityWarningsChecker : AdditionalTypeChecker {
|
||||
}
|
||||
}
|
||||
|
||||
override fun checkType(expression: JetExpression, expressionType: JetType, expressionTypeWithSmartCast: JetType, c: ResolutionContext<*>) {
|
||||
override fun checkType(expression: KtExpression, expressionType: KtType, expressionTypeWithSmartCast: KtType, c: ResolutionContext<*>) {
|
||||
doCheckType(
|
||||
expressionType,
|
||||
c.expectedType,
|
||||
@@ -98,7 +98,7 @@ public class JavaNullabilityWarningsChecker : AdditionalTypeChecker {
|
||||
}
|
||||
|
||||
when (expression) {
|
||||
is JetWhenExpression ->
|
||||
is KtWhenExpression ->
|
||||
if (expression.getElseExpression() == null) {
|
||||
// Check for conditionally-exhaustive when on platform enums, see KT-6399
|
||||
val type = expression.getSubjectExpression()?.let { c.trace.getType(it) } ?: return
|
||||
@@ -112,8 +112,8 @@ public class JavaNullabilityWarningsChecker : AdditionalTypeChecker {
|
||||
}
|
||||
}
|
||||
}
|
||||
is JetPostfixExpression ->
|
||||
if (expression.getOperationToken() == JetTokens.EXCLEXCL) {
|
||||
is KtPostfixExpression ->
|
||||
if (expression.getOperationToken() == KtTokens.EXCLEXCL) {
|
||||
val baseExpression = expression.getBaseExpression() ?: return
|
||||
val baseExpressionType = c.trace.getType(baseExpression) ?: return
|
||||
doIfNotNull(
|
||||
@@ -123,9 +123,9 @@ public class JavaNullabilityWarningsChecker : AdditionalTypeChecker {
|
||||
c.trace.report(Errors.UNNECESSARY_NOT_NULL_ASSERTION.on(expression.getOperationReference(), baseExpressionType))
|
||||
}
|
||||
}
|
||||
is JetBinaryExpression ->
|
||||
is KtBinaryExpression ->
|
||||
when (expression.getOperationToken()) {
|
||||
JetTokens.ELVIS -> {
|
||||
KtTokens.ELVIS -> {
|
||||
val baseExpression = expression.getLeft()
|
||||
val baseExpressionType = baseExpression?.let{ c.trace.getType(it) } ?: return
|
||||
doIfNotNull(
|
||||
@@ -135,10 +135,10 @@ public class JavaNullabilityWarningsChecker : AdditionalTypeChecker {
|
||||
c.trace.report(Errors.USELESS_ELVIS.on(expression, baseExpressionType))
|
||||
}
|
||||
}
|
||||
JetTokens.EQEQ,
|
||||
JetTokens.EXCLEQ,
|
||||
JetTokens.EQEQEQ,
|
||||
JetTokens.EXCLEQEQEQ -> {
|
||||
KtTokens.EQEQ,
|
||||
KtTokens.EXCLEQ,
|
||||
KtTokens.EQEQEQ,
|
||||
KtTokens.EXCLEQEQEQ -> {
|
||||
if (expression.getLeft() != null && expression.getRight() != null) {
|
||||
SenselessComparisonChecker.checkSenselessComparisonWithNull(
|
||||
expression, expression.getLeft()!!, expression.getRight()!!, c,
|
||||
|
||||
+2
-2
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticSink
|
||||
import org.jetbrains.kotlin.fileClasses.JvmFileClassUtil
|
||||
import org.jetbrains.kotlin.fileClasses.isInsideJvmMultifileClassFile
|
||||
import org.jetbrains.kotlin.psi.JetDeclaration
|
||||
import org.jetbrains.kotlin.psi.KtDeclaration
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.DeclarationChecker
|
||||
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
|
||||
@@ -49,7 +49,7 @@ class JvmFieldApplicabilityChecker : DeclarationChecker {
|
||||
}
|
||||
|
||||
override fun check(
|
||||
declaration: JetDeclaration,
|
||||
declaration: KtDeclaration,
|
||||
descriptor: DeclarationDescriptor,
|
||||
diagnosticHolder: DiagnosticSink,
|
||||
bindingContext: BindingContext
|
||||
|
||||
+7
-7
@@ -32,22 +32,22 @@ object JvmSimpleNameBacktickChecker : IdentifierChecker {
|
||||
reportIfNeeded(identifier.text, identifier, diagnosticHolder)
|
||||
}
|
||||
|
||||
override fun checkDeclaration(declaration: JetDeclaration, diagnosticHolder: DiagnosticSink) {
|
||||
if (declaration is JetMultiDeclaration) {
|
||||
override fun checkDeclaration(declaration: KtDeclaration, diagnosticHolder: DiagnosticSink) {
|
||||
if (declaration is KtMultiDeclaration) {
|
||||
declaration.entries.forEach { checkNamed(it, diagnosticHolder) }
|
||||
}
|
||||
if (declaration is JetCallableDeclaration) {
|
||||
if (declaration is KtCallableDeclaration) {
|
||||
declaration.valueParameters.forEach { checkNamed(it, diagnosticHolder) }
|
||||
}
|
||||
if (declaration is JetTypeParameterListOwner) {
|
||||
if (declaration is KtTypeParameterListOwner) {
|
||||
declaration.typeParameters.forEach { checkNamed(it, diagnosticHolder) }
|
||||
}
|
||||
if (declaration is JetNamedDeclaration) {
|
||||
if (declaration is KtNamedDeclaration) {
|
||||
checkNamed(declaration, diagnosticHolder)
|
||||
}
|
||||
}
|
||||
|
||||
fun checkNamed(declaration: JetNamedDeclaration, diagnosticHolder: DiagnosticSink) {
|
||||
fun checkNamed(declaration: KtNamedDeclaration, diagnosticHolder: DiagnosticSink) {
|
||||
val name = declaration.name ?: return
|
||||
|
||||
val element = declaration.nameIdentifier ?: declaration
|
||||
@@ -55,7 +55,7 @@ object JvmSimpleNameBacktickChecker : IdentifierChecker {
|
||||
}
|
||||
|
||||
private fun reportIfNeeded(name: String, element: PsiElement, diagnosticHolder: DiagnosticSink) {
|
||||
val text = JetPsiUtil.unquoteIdentifier(name)
|
||||
val text = KtPsiUtil.unquoteIdentifier(name)
|
||||
if (text.isEmpty()) {
|
||||
diagnosticHolder.report(Errors.INVALID_CHARACTERS.on(element, "should not be empty"))
|
||||
}
|
||||
|
||||
-1
@@ -23,7 +23,6 @@ import org.jetbrains.kotlin.descriptors.Visibilities;
|
||||
import org.jetbrains.kotlin.resolve.calls.checkers.CallChecker;
|
||||
import org.jetbrains.kotlin.resolve.calls.context.BasicCallResolutionContext;
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope;
|
||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope;
|
||||
|
||||
import static org.jetbrains.kotlin.resolve.BindingContext.NEED_SYNTHETIC_ACCESSOR;
|
||||
|
||||
+2
-2
@@ -20,7 +20,7 @@ import com.intellij.psi.util.PsiTreeUtil
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ClassifierDescriptor
|
||||
import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor
|
||||
import org.jetbrains.kotlin.psi.JetExpression
|
||||
import org.jetbrains.kotlin.psi.KtExpression
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.calls.callResolverUtil.getSuperCallExpression
|
||||
import org.jetbrains.kotlin.resolve.calls.checkers.CallChecker
|
||||
@@ -43,7 +43,7 @@ public class TraitDefaultMethodCallChecker : CallChecker {
|
||||
if (classifier != null && DescriptorUtils.isInterface(classifier)) {
|
||||
context.trace.report(
|
||||
ErrorsJvm.INTERFACE_CANT_CALL_DEFAULT_METHOD_VIA_SUPER.on(
|
||||
PsiTreeUtil.getParentOfType(resolvedCall.getCall().getCallElement(), javaClass<JetExpression>())
|
||||
PsiTreeUtil.getParentOfType(resolvedCall.getCall().getCallElement(), javaClass<KtExpression>())
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
+6
-6
@@ -21,7 +21,7 @@ import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget
|
||||
import org.jetbrains.kotlin.descriptors.annotations.KotlinRetention
|
||||
import org.jetbrains.kotlin.descriptors.annotations.KotlinTarget
|
||||
import org.jetbrains.kotlin.fileClasses.JvmFileClassUtil
|
||||
import org.jetbrains.kotlin.psi.JetAnnotationEntry
|
||||
import org.jetbrains.kotlin.psi.KtAnnotationEntry
|
||||
import org.jetbrains.kotlin.resolve.AdditionalAnnotationChecker
|
||||
import org.jetbrains.kotlin.resolve.AnnotationChecker
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
@@ -30,12 +30,12 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.classId
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.getAnnotationRetention
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.isRepeatableAnnotation
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm
|
||||
import org.jetbrains.kotlin.types.JetType
|
||||
import org.jetbrains.kotlin.types.KtType
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
|
||||
public object RepeatableAnnotationChecker: AdditionalAnnotationChecker {
|
||||
override fun checkEntries(entries: List<JetAnnotationEntry>, actualTargets: List<KotlinTarget>, trace: BindingTrace) {
|
||||
val entryTypesWithAnnotations = hashMapOf<JetType, MutableList<AnnotationUseSiteTarget?>>()
|
||||
override fun checkEntries(entries: List<KtAnnotationEntry>, actualTargets: List<KotlinTarget>, trace: BindingTrace) {
|
||||
val entryTypesWithAnnotations = hashMapOf<KtType, MutableList<AnnotationUseSiteTarget?>>()
|
||||
|
||||
for (entry in entries) {
|
||||
val descriptor = trace.get(BindingContext.ANNOTATION, entry) ?: continue
|
||||
@@ -61,8 +61,8 @@ public object FileClassAnnotationsChecker: AdditionalAnnotationChecker {
|
||||
// JvmName & JvmMultifileClass annotations are applicable to multi-file class parts regardless of their retention.
|
||||
private val ALWAYS_APPLICABLE = hashSetOf(JvmFileClassUtil.JVM_NAME, JvmFileClassUtil.JVM_MULTIFILE_CLASS)
|
||||
|
||||
override fun checkEntries(entries: List<JetAnnotationEntry>, actualTargets: List<KotlinTarget>, trace: BindingTrace) {
|
||||
val fileAnnotationsToCheck = arrayListOf<Pair<JetAnnotationEntry, ClassDescriptor>>()
|
||||
override fun checkEntries(entries: List<KtAnnotationEntry>, actualTargets: List<KotlinTarget>, trace: BindingTrace) {
|
||||
val fileAnnotationsToCheck = arrayListOf<Pair<KtAnnotationEntry, ClassDescriptor>>()
|
||||
for (entry in entries) {
|
||||
if (entry.useSiteTarget?.getAnnotationUseSiteTarget() != AnnotationUseSiteTarget.FILE) continue
|
||||
val descriptor = trace.get(BindingContext.ANNOTATION, entry) ?: continue
|
||||
|
||||
+17
-17
@@ -21,7 +21,7 @@ import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticSink
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.lexer.JetTokens
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
@@ -37,12 +37,12 @@ import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm
|
||||
public class LocalFunInlineChecker : DeclarationChecker {
|
||||
|
||||
override fun check(
|
||||
declaration: JetDeclaration,
|
||||
declaration: KtDeclaration,
|
||||
descriptor: DeclarationDescriptor,
|
||||
diagnosticHolder: DiagnosticSink,
|
||||
bindingContext: BindingContext) {
|
||||
if (InlineUtil.isInline(descriptor) &&
|
||||
declaration is JetNamedFunction &&
|
||||
declaration is KtNamedFunction &&
|
||||
descriptor is FunctionDescriptor &&
|
||||
descriptor.getVisibility() == Visibilities.LOCAL) {
|
||||
diagnosticHolder.report(Errors.NOT_YET_SUPPORTED_IN_INLINE.on(declaration, declaration, descriptor))
|
||||
@@ -53,20 +53,20 @@ public class LocalFunInlineChecker : DeclarationChecker {
|
||||
public class PlatformStaticAnnotationChecker : DeclarationChecker {
|
||||
|
||||
override fun check(
|
||||
declaration: JetDeclaration,
|
||||
declaration: KtDeclaration,
|
||||
descriptor: DeclarationDescriptor,
|
||||
diagnosticHolder: DiagnosticSink,
|
||||
bindingContext: BindingContext
|
||||
) {
|
||||
if (descriptor.hasPlatformStaticAnnotation()) {
|
||||
if (declaration is JetNamedFunction || declaration is JetProperty || declaration is JetPropertyAccessor) {
|
||||
if (declaration is KtNamedFunction || declaration is KtProperty || declaration is KtPropertyAccessor) {
|
||||
checkDeclaration(declaration, descriptor, diagnosticHolder)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkDeclaration(
|
||||
declaration: JetDeclaration,
|
||||
declaration: KtDeclaration,
|
||||
descriptor: DeclarationDescriptor,
|
||||
diagnosticHolder: DiagnosticSink
|
||||
) {
|
||||
@@ -81,18 +81,18 @@ public class PlatformStaticAnnotationChecker : DeclarationChecker {
|
||||
}
|
||||
|
||||
val checkDeclaration = when(declaration) {
|
||||
is JetPropertyAccessor -> declaration.getParent() as JetProperty
|
||||
is KtPropertyAccessor -> declaration.getParent() as KtProperty
|
||||
else -> declaration
|
||||
}
|
||||
|
||||
if (insideObject && checkDeclaration.getModifierList()?.hasModifier(JetTokens.OVERRIDE_KEYWORD) == true) {
|
||||
if (insideObject && checkDeclaration.getModifierList()?.hasModifier(KtTokens.OVERRIDE_KEYWORD) == true) {
|
||||
diagnosticHolder.report(ErrorsJvm.OVERRIDE_CANNOT_BE_STATIC.on(declaration))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class JvmNameAnnotationChecker : DeclarationChecker {
|
||||
override fun check(declaration: JetDeclaration, descriptor: DeclarationDescriptor, diagnosticHolder: DiagnosticSink, bindingContext: BindingContext) {
|
||||
override fun check(declaration: KtDeclaration, descriptor: DeclarationDescriptor, diagnosticHolder: DiagnosticSink, bindingContext: BindingContext) {
|
||||
val platformNameAnnotation = DescriptorUtils.getJvmNameAnnotation(descriptor)
|
||||
if (platformNameAnnotation != null) {
|
||||
checkDeclaration(descriptor, platformNameAnnotation, diagnosticHolder)
|
||||
@@ -130,7 +130,7 @@ public class JvmNameAnnotationChecker : DeclarationChecker {
|
||||
|
||||
public class VolatileAnnotationChecker : DeclarationChecker {
|
||||
|
||||
override fun check(declaration: JetDeclaration,
|
||||
override fun check(declaration: KtDeclaration,
|
||||
descriptor: DeclarationDescriptor,
|
||||
diagnosticHolder: DiagnosticSink,
|
||||
bindingContext: BindingContext
|
||||
@@ -145,7 +145,7 @@ public class VolatileAnnotationChecker : DeclarationChecker {
|
||||
|
||||
public class SynchronizedAnnotationChecker : DeclarationChecker {
|
||||
|
||||
override fun check(declaration: JetDeclaration,
|
||||
override fun check(declaration: KtDeclaration,
|
||||
descriptor: DeclarationDescriptor,
|
||||
diagnosticHolder: DiagnosticSink,
|
||||
bindingContext: BindingContext
|
||||
@@ -160,7 +160,7 @@ public class SynchronizedAnnotationChecker : DeclarationChecker {
|
||||
|
||||
public class OverloadsAnnotationChecker: DeclarationChecker {
|
||||
override fun check(
|
||||
declaration: JetDeclaration,
|
||||
declaration: KtDeclaration,
|
||||
descriptor: DeclarationDescriptor,
|
||||
diagnosticHolder: DiagnosticSink,
|
||||
bindingContext: BindingContext
|
||||
@@ -170,7 +170,7 @@ public class OverloadsAnnotationChecker: DeclarationChecker {
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkDeclaration(declaration: JetDeclaration, descriptor: DeclarationDescriptor, diagnosticHolder: DiagnosticSink) {
|
||||
private fun checkDeclaration(declaration: KtDeclaration, descriptor: DeclarationDescriptor, diagnosticHolder: DiagnosticSink) {
|
||||
if (descriptor !is CallableDescriptor) {
|
||||
return
|
||||
}
|
||||
@@ -189,7 +189,7 @@ public class OverloadsAnnotationChecker: DeclarationChecker {
|
||||
|
||||
public class TypeParameterBoundIsNotArrayChecker : DeclarationChecker {
|
||||
override fun check(
|
||||
declaration: JetDeclaration,
|
||||
declaration: KtDeclaration,
|
||||
descriptor: DeclarationDescriptor,
|
||||
diagnosticHolder: DiagnosticSink,
|
||||
bindingContext: BindingContext
|
||||
@@ -210,7 +210,7 @@ public class TypeParameterBoundIsNotArrayChecker : DeclarationChecker {
|
||||
public class ReifiedTypeParameterAnnotationChecker : DeclarationChecker {
|
||||
|
||||
override fun check(
|
||||
declaration: JetDeclaration,
|
||||
declaration: KtDeclaration,
|
||||
descriptor: DeclarationDescriptor,
|
||||
diagnosticHolder: DiagnosticSink,
|
||||
bindingContext: BindingContext
|
||||
@@ -233,11 +233,11 @@ public class ReifiedTypeParameterAnnotationChecker : DeclarationChecker {
|
||||
) {
|
||||
for (reifiedTypeParameterDescriptor in typeParameterDescriptors.filter { it.isReified() }) {
|
||||
val typeParameterDeclaration = DescriptorToSourceUtils.descriptorToDeclaration(reifiedTypeParameterDescriptor)
|
||||
if (typeParameterDeclaration !is JetTypeParameter) throw AssertionError("JetTypeParameter expected")
|
||||
if (typeParameterDeclaration !is KtTypeParameter) throw AssertionError("JetTypeParameter expected")
|
||||
|
||||
diagnosticHolder.report(
|
||||
Errors.REIFIED_TYPE_PARAMETER_NO_INLINE.on(
|
||||
typeParameterDeclaration.getModifierList()!!.getModifier(JetTokens.REIFIED_KEYWORD)!!
|
||||
typeParameterDeclaration.getModifierList()!!.getModifier(KtTokens.REIFIED_KEYWORD)!!
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
+30
-30
@@ -23,11 +23,11 @@ import org.jetbrains.kotlin.diagnostics.DiagnosticFactory1;
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticFactory2;
|
||||
import org.jetbrains.kotlin.diagnostics.Errors;
|
||||
import org.jetbrains.kotlin.name.FqName;
|
||||
import org.jetbrains.kotlin.psi.JetAnnotationEntry;
|
||||
import org.jetbrains.kotlin.psi.JetDeclaration;
|
||||
import org.jetbrains.kotlin.psi.JetElement;
|
||||
import org.jetbrains.kotlin.psi.JetExpression;
|
||||
import org.jetbrains.kotlin.types.JetType;
|
||||
import org.jetbrains.kotlin.psi.KtAnnotationEntry;
|
||||
import org.jetbrains.kotlin.psi.KtDeclaration;
|
||||
import org.jetbrains.kotlin.psi.KtElement;
|
||||
import org.jetbrains.kotlin.psi.KtExpression;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
|
||||
import static org.jetbrains.kotlin.diagnostics.PositioningStrategies.*;
|
||||
import static org.jetbrains.kotlin.diagnostics.Severity.ERROR;
|
||||
@@ -42,40 +42,40 @@ public interface ErrorsJvm {
|
||||
DiagnosticFactory1<PsiElement, ConflictingJvmDeclarationsData> CONFLICTING_INHERITED_JVM_DECLARATIONS =
|
||||
DiagnosticFactory1.create(ERROR, DECLARATION_SIGNATURE_OR_DEFAULT);
|
||||
|
||||
DiagnosticFactory0<JetDeclaration> OVERRIDE_CANNOT_BE_STATIC = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE);
|
||||
DiagnosticFactory0<JetDeclaration> JVM_STATIC_NOT_IN_OBJECT = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE);
|
||||
DiagnosticFactory0<KtDeclaration> OVERRIDE_CANNOT_BE_STATIC = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE);
|
||||
DiagnosticFactory0<KtDeclaration> JVM_STATIC_NOT_IN_OBJECT = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE);
|
||||
|
||||
DiagnosticFactory0<PsiElement> INAPPLICABLE_JVM_NAME = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetAnnotationEntry> ILLEGAL_JVM_NAME = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtAnnotationEntry> ILLEGAL_JVM_NAME = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory1<JetAnnotationEntry, String> INAPPLICABLE_JVM_FIELD = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<KtAnnotationEntry, String> INAPPLICABLE_JVM_FIELD = DiagnosticFactory1.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<JetAnnotationEntry> VOLATILE_ON_VALUE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetAnnotationEntry> SYNCHRONIZED_ON_ABSTRACT = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtAnnotationEntry> VOLATILE_ON_VALUE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtAnnotationEntry> SYNCHRONIZED_ON_ABSTRACT = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<JetDeclaration> OVERLOADS_WITHOUT_DEFAULT_ARGUMENTS = DiagnosticFactory0.create(WARNING, DECLARATION_SIGNATURE);
|
||||
DiagnosticFactory0<JetDeclaration> OVERLOADS_ABSTRACT = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE);
|
||||
DiagnosticFactory0<JetDeclaration> OVERLOADS_PRIVATE = DiagnosticFactory0.create(WARNING, DECLARATION_SIGNATURE);
|
||||
DiagnosticFactory0<KtDeclaration> OVERLOADS_WITHOUT_DEFAULT_ARGUMENTS = DiagnosticFactory0.create(WARNING, DECLARATION_SIGNATURE);
|
||||
DiagnosticFactory0<KtDeclaration> OVERLOADS_ABSTRACT = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE);
|
||||
DiagnosticFactory0<KtDeclaration> OVERLOADS_PRIVATE = DiagnosticFactory0.create(WARNING, DECLARATION_SIGNATURE);
|
||||
|
||||
DiagnosticFactory0<JetDeclaration> EXTERNAL_DECLARATION_CANNOT_BE_ABSTRACT = DiagnosticFactory0.create(ERROR, ABSTRACT_MODIFIER);
|
||||
DiagnosticFactory0<JetDeclaration> EXTERNAL_DECLARATION_CANNOT_HAVE_BODY = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE);
|
||||
DiagnosticFactory0<JetDeclaration> EXTERNAL_DECLARATION_IN_INTERFACE = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE);
|
||||
DiagnosticFactory0<JetDeclaration> EXTERNAL_DECLARATION_CANNOT_BE_INLINED = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE);
|
||||
DiagnosticFactory0<KtDeclaration> EXTERNAL_DECLARATION_CANNOT_BE_ABSTRACT = DiagnosticFactory0.create(ERROR, ABSTRACT_MODIFIER);
|
||||
DiagnosticFactory0<KtDeclaration> EXTERNAL_DECLARATION_CANNOT_HAVE_BODY = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE);
|
||||
DiagnosticFactory0<KtDeclaration> EXTERNAL_DECLARATION_IN_INTERFACE = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE);
|
||||
DiagnosticFactory0<KtDeclaration> EXTERNAL_DECLARATION_CANNOT_BE_INLINED = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE);
|
||||
|
||||
DiagnosticFactory0<JetExpression> POSITIONED_VALUE_ARGUMENT_FOR_JAVA_ANNOTATION = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetElement> DEPRECATED_ANNOTATION_METHOD_CALL = DiagnosticFactory0.create(WARNING);
|
||||
DiagnosticFactory1<JetAnnotationEntry, FqName> DEPRECATED_JAVA_ANNOTATION = DiagnosticFactory1.create(WARNING);
|
||||
DiagnosticFactory0<JetAnnotationEntry> NON_SOURCE_REPEATED_ANNOTATION = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory1<JetAnnotationEntry, FqName> ANNOTATION_IS_NOT_APPLICABLE_TO_MULTIFILE_CLASSES = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory0<KtExpression> POSITIONED_VALUE_ARGUMENT_FOR_JAVA_ANNOTATION = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtElement> DEPRECATED_ANNOTATION_METHOD_CALL = DiagnosticFactory0.create(WARNING);
|
||||
DiagnosticFactory1<KtAnnotationEntry, FqName> DEPRECATED_JAVA_ANNOTATION = DiagnosticFactory1.create(WARNING);
|
||||
DiagnosticFactory0<KtAnnotationEntry> NON_SOURCE_REPEATED_ANNOTATION = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory1<KtAnnotationEntry, FqName> ANNOTATION_IS_NOT_APPLICABLE_TO_MULTIFILE_CLASSES = DiagnosticFactory1.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<JetElement> INTERFACE_CANT_CALL_DEFAULT_METHOD_VIA_SUPER = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtElement> INTERFACE_CANT_CALL_DEFAULT_METHOD_VIA_SUPER = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<JetElement> INAPPLICABLE_PUBLIC_FIELD = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtElement> INAPPLICABLE_PUBLIC_FIELD = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<JetElement> NO_REFLECTION_IN_CLASS_PATH = DiagnosticFactory0.create(WARNING);
|
||||
DiagnosticFactory0<KtElement> NO_REFLECTION_IN_CLASS_PATH = DiagnosticFactory0.create(WARNING);
|
||||
|
||||
DiagnosticFactory2<JetElement, JetType, JetType> JAVA_CLASS_ON_COMPANION = DiagnosticFactory2.create(WARNING);
|
||||
DiagnosticFactory2<JetExpression, JetType, JetType> JAVA_TYPE_MISMATCH = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory2<KtElement, KtType, KtType> JAVA_CLASS_ON_COMPANION = DiagnosticFactory2.create(WARNING);
|
||||
DiagnosticFactory2<KtExpression, KtType, KtType> JAVA_TYPE_MISMATCH = DiagnosticFactory2.create(ERROR);
|
||||
|
||||
DiagnosticFactory2<PsiElement, String, String> DUPLICATE_CLASS_NAMES = DiagnosticFactory2.create(ERROR);
|
||||
|
||||
@@ -98,9 +98,9 @@ public interface ErrorsJvm {
|
||||
};
|
||||
}
|
||||
|
||||
DiagnosticFactory2<JetElement, NullabilityInformationSource, NullabilityInformationSource> NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS = DiagnosticFactory2.create(WARNING);
|
||||
DiagnosticFactory2<KtElement, NullabilityInformationSource, NullabilityInformationSource> NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS = DiagnosticFactory2.create(WARNING);
|
||||
|
||||
DiagnosticFactory0<JetExpression> WHEN_ENUM_CAN_BE_NULL_IN_JAVA = DiagnosticFactory0.create(WARNING);
|
||||
DiagnosticFactory0<KtExpression> WHEN_ENUM_CAN_BE_NULL_IN_JAVA = DiagnosticFactory0.create(WARNING);
|
||||
|
||||
@SuppressWarnings("UnusedDeclaration")
|
||||
Object _initializer = new Object() {
|
||||
|
||||
+6
-6
@@ -19,9 +19,9 @@ package org.jetbrains.kotlin.resolve.jvm.diagnostics
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor
|
||||
import org.jetbrains.kotlin.psi.JetFile
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.psi.JetClassOrObject
|
||||
import org.jetbrains.kotlin.psi.KtClassOrObject
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOriginKind.*
|
||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
|
||||
@@ -68,17 +68,17 @@ public fun Bridge(descriptor: DeclarationDescriptor, element: PsiElement? = Desc
|
||||
JvmDeclarationOrigin(BRIDGE, element, descriptor)
|
||||
|
||||
public fun PackageFacade(descriptor: PackageFragmentDescriptor): JvmDeclarationOrigin = JvmDeclarationOrigin(PACKAGE_FACADE, null, descriptor)
|
||||
public fun PackagePart(file: JetFile, descriptor: PackageFragmentDescriptor): JvmDeclarationOrigin = JvmDeclarationOrigin(PACKAGE_PART, file, descriptor)
|
||||
public fun PackagePart(file: KtFile, descriptor: PackageFragmentDescriptor): JvmDeclarationOrigin = JvmDeclarationOrigin(PACKAGE_PART, file, descriptor)
|
||||
|
||||
/**
|
||||
* @param representativeFile one of the files representing this multifile class (will be used for diagnostics)
|
||||
*/
|
||||
public fun MultifileClass(representativeFile: JetFile?, descriptor: PackageFragmentDescriptor, multifileClassFqName: FqName): JvmDeclarationOrigin =
|
||||
public fun MultifileClass(representativeFile: KtFile?, descriptor: PackageFragmentDescriptor, multifileClassFqName: FqName): JvmDeclarationOrigin =
|
||||
JvmDeclarationOrigin(MULTIFILE_CLASS, representativeFile, descriptor)
|
||||
public fun MultifileClassPart(file: JetFile, descriptor: PackageFragmentDescriptor, multifileClassFqName: FqName): JvmDeclarationOrigin =
|
||||
public fun MultifileClassPart(file: KtFile, descriptor: PackageFragmentDescriptor, multifileClassFqName: FqName): JvmDeclarationOrigin =
|
||||
JvmDeclarationOrigin(MULTIFILE_CLASS_PART, file, descriptor)
|
||||
|
||||
public fun TraitImpl(element: JetClassOrObject, descriptor: ClassDescriptor): JvmDeclarationOrigin = JvmDeclarationOrigin(INTERFACE_DEFAULT_IMPL, element, descriptor)
|
||||
public fun TraitImpl(element: KtClassOrObject, descriptor: ClassDescriptor): JvmDeclarationOrigin = JvmDeclarationOrigin(INTERFACE_DEFAULT_IMPL, element, descriptor)
|
||||
public fun DelegationToTraitImpl(element: PsiElement?, descriptor: FunctionDescriptor): JvmDeclarationOrigin =
|
||||
JvmDeclarationOrigin(DELEGATION_TO_DEFAULT_IMPLS, element, descriptor)
|
||||
|
||||
|
||||
+2
-2
@@ -21,7 +21,7 @@ import org.jetbrains.kotlin.analyzer.AnalysisResult
|
||||
import org.jetbrains.kotlin.analyzer.ModuleInfo
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.kotlin.extensions.ProjectExtensionDescriptor
|
||||
import org.jetbrains.kotlin.psi.JetFile
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
|
||||
public interface AnalysisCompletedHandlerExtension {
|
||||
@@ -34,5 +34,5 @@ public interface AnalysisCompletedHandlerExtension {
|
||||
project: Project,
|
||||
module: ModuleDescriptor,
|
||||
bindingContext: BindingContext,
|
||||
files: Collection<JetFile>): AnalysisResult?
|
||||
files: Collection<KtFile>): AnalysisResult?
|
||||
}
|
||||
+8
-8
@@ -22,18 +22,18 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.impl.TypeParameterDescriptorImpl;
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaField;
|
||||
import org.jetbrains.kotlin.psi.JetProperty;
|
||||
import org.jetbrains.kotlin.psi.JetPsiFactoryKt;
|
||||
import org.jetbrains.kotlin.types.JetType;
|
||||
import org.jetbrains.kotlin.psi.KtProperty;
|
||||
import org.jetbrains.kotlin.psi.KtPsiFactoryKt;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class AlternativeFieldSignatureData extends ElementAlternativeSignatureData {
|
||||
private JetType altReturnType;
|
||||
private KtType altReturnType;
|
||||
|
||||
public AlternativeFieldSignatureData(
|
||||
@NotNull JavaField field,
|
||||
@NotNull JetType originalReturnType,
|
||||
@NotNull KtType originalReturnType,
|
||||
@NotNull Project project,
|
||||
boolean isVar
|
||||
) {
|
||||
@@ -45,7 +45,7 @@ public class AlternativeFieldSignatureData extends ElementAlternativeSignatureDa
|
||||
}
|
||||
|
||||
setAnnotated(true);
|
||||
JetProperty altPropertyDeclaration = JetPsiFactoryKt.JetPsiFactory(project).createProperty(signature);
|
||||
KtProperty altPropertyDeclaration = KtPsiFactoryKt.KtPsiFactory(project).createProperty(signature);
|
||||
|
||||
try {
|
||||
checkForSyntaxErrors(altPropertyDeclaration);
|
||||
@@ -59,12 +59,12 @@ public class AlternativeFieldSignatureData extends ElementAlternativeSignatureDa
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JetType getReturnType() {
|
||||
public KtType getReturnType() {
|
||||
checkForErrors();
|
||||
return altReturnType;
|
||||
}
|
||||
|
||||
private static void checkFieldAnnotation(@NotNull JetProperty altProperty, @NotNull JavaField field, boolean isVar) {
|
||||
private static void checkFieldAnnotation(@NotNull KtProperty altProperty, @NotNull JavaField field, boolean isVar) {
|
||||
if (!ComparatorUtil.equalsNullable(field.getName().asString(), altProperty.getName())) {
|
||||
throw new AlternativeSignatureMismatchException("Field name mismatch, original: %s, alternative: %s",
|
||||
field.getName().asString(), altProperty.getName());
|
||||
|
||||
+27
-27
@@ -32,11 +32,11 @@ import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.psi.*;
|
||||
import org.jetbrains.kotlin.resolve.jvm.JavaDescriptorResolverKt;
|
||||
import org.jetbrains.kotlin.resolve.jvm.JavaResolverUtils;
|
||||
import org.jetbrains.kotlin.types.JetType;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.TypeSubstitutor;
|
||||
import org.jetbrains.kotlin.types.TypeUtils;
|
||||
import org.jetbrains.kotlin.types.Variance;
|
||||
import org.jetbrains.kotlin.types.checker.JetTypeChecker;
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
|
||||
import org.jetbrains.kotlin.types.typeUtil.TypeUtilsKt;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -49,20 +49,20 @@ import static org.jetbrains.kotlin.load.java.components.TypeUsage.UPPER_BOUND;
|
||||
import static org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt.getBuiltIns;
|
||||
|
||||
public class AlternativeMethodSignatureData extends ElementAlternativeSignatureData {
|
||||
private final JetNamedFunction altFunDeclaration;
|
||||
private final KtNamedFunction altFunDeclaration;
|
||||
|
||||
private List<ValueParameterDescriptor> altValueParameters;
|
||||
private JetType altReturnType;
|
||||
private KtType altReturnType;
|
||||
private List<TypeParameterDescriptor> altTypeParameters;
|
||||
|
||||
private Map<TypeParameterDescriptor, TypeParameterDescriptorImpl> originalToAltTypeParameters;
|
||||
|
||||
public AlternativeMethodSignatureData(
|
||||
@NotNull JavaMember methodOrConstructor,
|
||||
@Nullable JetType receiverType,
|
||||
@Nullable KtType receiverType,
|
||||
@NotNull Project project,
|
||||
@NotNull List<ValueParameterDescriptor> valueParameters,
|
||||
@Nullable JetType originalReturnType,
|
||||
@Nullable KtType originalReturnType,
|
||||
@NotNull List<TypeParameterDescriptor> methodTypeParameters,
|
||||
boolean hasSuperMethods
|
||||
) {
|
||||
@@ -79,7 +79,7 @@ public class AlternativeMethodSignatureData extends ElementAlternativeSignatureD
|
||||
}
|
||||
|
||||
setAnnotated(true);
|
||||
altFunDeclaration = JetPsiFactoryKt.JetPsiFactory(project).createFunction(signature);
|
||||
altFunDeclaration = KtPsiFactoryKt.KtPsiFactory(project).createFunction(signature);
|
||||
|
||||
originalToAltTypeParameters = JavaResolverUtils.recreateTypeParametersAndReturnMapping(methodTypeParameters, null);
|
||||
|
||||
@@ -119,7 +119,7 @@ public class AlternativeMethodSignatureData extends ElementAlternativeSignatureD
|
||||
private void checkParameterAndReturnTypesForOverridingMethods(
|
||||
@NotNull List<ValueParameterDescriptor> valueParameters,
|
||||
@NotNull List<TypeParameterDescriptor> methodTypeParameters,
|
||||
@Nullable JetType returnType
|
||||
@Nullable KtType returnType
|
||||
) {
|
||||
if (JavaDescriptorResolverKt.getPLATFORM_TYPES()) return;
|
||||
TypeSubstitutor substitutor = JavaResolverUtils.createSubstitutorForTypeParameters(originalToAltTypeParameters);
|
||||
@@ -128,7 +128,7 @@ public class AlternativeMethodSignatureData extends ElementAlternativeSignatureD
|
||||
int index = parameter.getIndex();
|
||||
ValueParameterDescriptor altParameter = altValueParameters.get(index);
|
||||
|
||||
JetType substituted = substitutor.substitute(parameter.getType(), Variance.INVARIANT);
|
||||
KtType substituted = substitutor.substitute(parameter.getType(), Variance.INVARIANT);
|
||||
assert substituted != null;
|
||||
|
||||
if (!TypeUtils.equalTypes(substituted, altParameter.getType())) {
|
||||
@@ -143,7 +143,7 @@ public class AlternativeMethodSignatureData extends ElementAlternativeSignatureD
|
||||
for (TypeParameterDescriptor parameter : methodTypeParameters) {
|
||||
int index = parameter.getIndex();
|
||||
|
||||
JetType substituted = substitutor.substitute(parameter.getUpperBoundsAsType(), Variance.INVARIANT);
|
||||
KtType substituted = substitutor.substitute(parameter.getUpperBoundsAsType(), Variance.INVARIANT);
|
||||
assert substituted != null;
|
||||
|
||||
if (!TypeUtils.equalTypes(substituted, altTypeParameters.get(index).getUpperBoundsAsType())) {
|
||||
@@ -154,10 +154,10 @@ public class AlternativeMethodSignatureData extends ElementAlternativeSignatureD
|
||||
}
|
||||
|
||||
if (returnType != null) {
|
||||
JetType substitutedReturnType = substitutor.substitute(returnType, Variance.INVARIANT);
|
||||
KtType substitutedReturnType = substitutor.substitute(returnType, Variance.INVARIANT);
|
||||
assert substitutedReturnType != null;
|
||||
|
||||
if (!JetTypeChecker.DEFAULT.isSubtypeOf(altReturnType, substitutedReturnType)) {
|
||||
if (!KotlinTypeChecker.DEFAULT.isSubtypeOf(altReturnType, substitutedReturnType)) {
|
||||
throw new AlternativeSignatureMismatchException(
|
||||
"Return type is changed to not subtype for method which overrides another: " + altReturnType + ", was: " + returnType);
|
||||
}
|
||||
@@ -171,7 +171,7 @@ public class AlternativeMethodSignatureData extends ElementAlternativeSignatureD
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public JetType getReturnType() {
|
||||
public KtType getReturnType() {
|
||||
checkForErrors();
|
||||
return altReturnType;
|
||||
}
|
||||
@@ -191,16 +191,16 @@ public class AlternativeMethodSignatureData extends ElementAlternativeSignatureD
|
||||
List<ValueParameterDescriptor> altParamDescriptors = new ArrayList<ValueParameterDescriptor>(parameterDescriptors.size());
|
||||
for (int i = 0; i < parameterDescriptors.size(); i++) {
|
||||
ValueParameterDescriptor originalParameterDescriptor = parameterDescriptors.get(i);
|
||||
JetParameter annotationValueParameter = altFunDeclaration.getValueParameters().get(i);
|
||||
KtParameter annotationValueParameter = altFunDeclaration.getValueParameters().get(i);
|
||||
|
||||
//noinspection ConstantConditions
|
||||
JetTypeElement alternativeTypeElement = annotationValueParameter.getTypeReference().getTypeElement();
|
||||
KtTypeElement alternativeTypeElement = annotationValueParameter.getTypeReference().getTypeElement();
|
||||
assert alternativeTypeElement != null;
|
||||
|
||||
JetType alternativeType;
|
||||
JetType alternativeVarargElementType;
|
||||
KtType alternativeType;
|
||||
KtType alternativeVarargElementType;
|
||||
|
||||
JetType originalParamVarargElementType = originalParameterDescriptor.getVarargElementType();
|
||||
KtType originalParamVarargElementType = originalParameterDescriptor.getVarargElementType();
|
||||
if (originalParamVarargElementType == null) {
|
||||
if (annotationValueParameter.isVarArg()) {
|
||||
throw new AlternativeSignatureMismatchException("Parameter in method signature is not vararg, but in alternative signature it is vararg");
|
||||
@@ -251,10 +251,10 @@ public class AlternativeMethodSignatureData extends ElementAlternativeSignatureD
|
||||
TypeParameterDescriptor originalTypeParamDescriptor = typeParameters.get(i);
|
||||
|
||||
TypeParameterDescriptorImpl altParamDescriptor = originalToAltTypeParameters.get(originalTypeParamDescriptor);
|
||||
JetTypeParameter altTypeParameter = altFunDeclaration.getTypeParameters().get(i);
|
||||
KtTypeParameter altTypeParameter = altFunDeclaration.getTypeParameters().get(i);
|
||||
|
||||
Set<JetType> originalUpperBounds = originalTypeParamDescriptor.getUpperBounds();
|
||||
List<JetTypeReference> altUpperBounds = getUpperBounds(altFunDeclaration, altTypeParameter);
|
||||
Set<KtType> originalUpperBounds = originalTypeParamDescriptor.getUpperBounds();
|
||||
List<KtTypeReference> altUpperBounds = getUpperBounds(altFunDeclaration, altTypeParameter);
|
||||
if (altUpperBounds.size() != originalUpperBounds.size()) {
|
||||
if (altUpperBounds.isEmpty()
|
||||
&& originalUpperBounds.size() == 1
|
||||
@@ -274,9 +274,9 @@ public class AlternativeMethodSignatureData extends ElementAlternativeSignatureD
|
||||
}
|
||||
else {
|
||||
int upperBoundIndex = 0;
|
||||
for (JetType upperBound : originalUpperBounds) {
|
||||
for (KtType upperBound : originalUpperBounds) {
|
||||
|
||||
JetTypeElement altTypeElement = altUpperBounds.get(upperBoundIndex).getTypeElement();
|
||||
KtTypeElement altTypeElement = altUpperBounds.get(upperBoundIndex).getTypeElement();
|
||||
assert altTypeElement != null;
|
||||
|
||||
altParamDescriptor.addUpperBound(TypeTransformingVisitor.computeType(altTypeElement, upperBound,
|
||||
@@ -291,15 +291,15 @@ public class AlternativeMethodSignatureData extends ElementAlternativeSignatureD
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static List<JetTypeReference> getUpperBounds(@NotNull JetFunction function, @NotNull JetTypeParameter jetTypeParameter) {
|
||||
List<JetTypeReference> result = new ArrayList<JetTypeReference>();
|
||||
private static List<KtTypeReference> getUpperBounds(@NotNull KtFunction function, @NotNull KtTypeParameter jetTypeParameter) {
|
||||
List<KtTypeReference> result = new ArrayList<KtTypeReference>();
|
||||
ContainerUtil.addIfNotNull(result, jetTypeParameter.getExtendsBound());
|
||||
|
||||
Name name = jetTypeParameter.getNameAsName();
|
||||
if (name == null) return result;
|
||||
|
||||
for (JetTypeConstraint constraint : function.getTypeConstraints()) {
|
||||
JetSimpleNameExpression parameterName = constraint.getSubjectTypeParameterName();
|
||||
for (KtTypeConstraint constraint : function.getTypeConstraints()) {
|
||||
KtSimpleNameExpression parameterName = constraint.getSubjectTypeParameterName();
|
||||
assert parameterName != null : "No parameter name in constraint " + constraint.getText();
|
||||
if (name.equals(parameterName.getReferencedNameAsName())) {
|
||||
result.add(constraint.getBoundTypeReference());
|
||||
|
||||
+7
-7
@@ -23,11 +23,11 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
|
||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.impl.TypeParameterDescriptorImpl;
|
||||
import org.jetbrains.kotlin.psi.JetTypeElement;
|
||||
import org.jetbrains.kotlin.psi.JetTypeReference;
|
||||
import org.jetbrains.kotlin.psi.KtTypeElement;
|
||||
import org.jetbrains.kotlin.psi.KtTypeReference;
|
||||
import org.jetbrains.kotlin.renderer.DescriptorRenderer;
|
||||
import org.jetbrains.kotlin.resolve.AnalyzingUtils;
|
||||
import org.jetbrains.kotlin.types.JetType;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -86,9 +86,9 @@ public abstract class ElementAlternativeSignatureData {
|
||||
}
|
||||
}
|
||||
|
||||
protected static JetType computeReturnType(
|
||||
@NotNull JetType originalType,
|
||||
@Nullable JetTypeReference altReturnTypeReference,
|
||||
protected static KtType computeReturnType(
|
||||
@NotNull KtType originalType,
|
||||
@Nullable KtTypeReference altReturnTypeReference,
|
||||
@NotNull Map<TypeParameterDescriptor, TypeParameterDescriptorImpl> originalToAltTypeParameters) {
|
||||
if (altReturnTypeReference == null) {
|
||||
if (KotlinBuiltIns.isUnit(originalType)) {
|
||||
@@ -101,7 +101,7 @@ public abstract class ElementAlternativeSignatureData {
|
||||
}
|
||||
}
|
||||
|
||||
JetTypeElement typeElement = altReturnTypeReference.getTypeElement();
|
||||
KtTypeElement typeElement = altReturnTypeReference.getTypeElement();
|
||||
assert (typeElement != null);
|
||||
|
||||
return TypeTransformingVisitor.computeType(typeElement, originalType, originalToAltTypeParameters, MEMBER_SIGNATURE_COVARIANT);
|
||||
|
||||
+12
-13
@@ -21,16 +21,15 @@ import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
|
||||
import org.jetbrains.kotlin.descriptors.ClassifierDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor;
|
||||
import org.jetbrains.kotlin.renderer.DescriptorRenderer;
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope;
|
||||
import org.jetbrains.kotlin.types.JetType;
|
||||
import org.jetbrains.kotlin.types.JetTypeImpl;
|
||||
import org.jetbrains.kotlin.resolve.scopes.KtScope;
|
||||
import org.jetbrains.kotlin.types.KtType;
|
||||
import org.jetbrains.kotlin.types.KtTypeImpl;
|
||||
import org.jetbrains.kotlin.types.TypeProjectionImpl;
|
||||
import org.jetbrains.kotlin.types.Variance;
|
||||
import org.jetbrains.kotlin.types.checker.JetTypeChecker;
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -42,7 +41,7 @@ class PropagationHeuristics {
|
||||
// Checks for case when method returning Super[] is overridden with method returning Sub[]
|
||||
static void checkArrayInReturnType(
|
||||
@NotNull SignaturesPropagationData data,
|
||||
@NotNull JetType type,
|
||||
@NotNull KtType type,
|
||||
@NotNull List<SignaturesPropagationData.TypeAndVariance> typesFromSuper
|
||||
) {
|
||||
List<SignaturesPropagationData.TypeAndVariance> arrayTypesFromSuper = ContainerUtil
|
||||
@@ -56,19 +55,19 @@ class PropagationHeuristics {
|
||||
assert type.getArguments().size() == 1;
|
||||
if (type.getArguments().get(0).getProjectionKind() == Variance.INVARIANT) {
|
||||
for (SignaturesPropagationData.TypeAndVariance typeAndVariance : arrayTypesFromSuper) {
|
||||
JetType arrayTypeFromSuper = typeAndVariance.type;
|
||||
KtType arrayTypeFromSuper = typeAndVariance.type;
|
||||
assert arrayTypeFromSuper.getArguments().size() == 1;
|
||||
JetType elementTypeInSuper = arrayTypeFromSuper.getArguments().get(0).getType();
|
||||
JetType elementType = type.getArguments().get(0).getType();
|
||||
KtType elementTypeInSuper = arrayTypeFromSuper.getArguments().get(0).getType();
|
||||
KtType elementType = type.getArguments().get(0).getType();
|
||||
|
||||
if (JetTypeChecker.DEFAULT.isSubtypeOf(elementType, elementTypeInSuper)
|
||||
&& !JetTypeChecker.DEFAULT.equalTypes(elementType, elementTypeInSuper)) {
|
||||
JetTypeImpl betterTypeInSuper = JetTypeImpl.create(
|
||||
if (KotlinTypeChecker.DEFAULT.isSubtypeOf(elementType, elementTypeInSuper)
|
||||
&& !KotlinTypeChecker.DEFAULT.equalTypes(elementType, elementTypeInSuper)) {
|
||||
KtTypeImpl betterTypeInSuper = KtTypeImpl.create(
|
||||
arrayTypeFromSuper.getAnnotations(),
|
||||
arrayTypeFromSuper.getConstructor(),
|
||||
arrayTypeFromSuper.isMarkedNullable(),
|
||||
Arrays.asList(new TypeProjectionImpl(Variance.OUT_VARIANCE, elementTypeInSuper)),
|
||||
JetScope.Empty.INSTANCE$);
|
||||
KtScope.Empty.INSTANCE$);
|
||||
|
||||
data.reportError("Return type is not a subtype of overridden method. " +
|
||||
"To fix it, add annotation with Kotlin signature to super method with type "
|
||||
|
||||
+45
-45
@@ -45,7 +45,7 @@ import org.jetbrains.kotlin.resolve.jvm.JavaResolverUtils;
|
||||
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature;
|
||||
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.KotlinToJvmSignatureMapper;
|
||||
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.KotlinToJvmSignatureMapperKt;
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope;
|
||||
import org.jetbrains.kotlin.resolve.scopes.KtScope;
|
||||
import org.jetbrains.kotlin.types.*;
|
||||
|
||||
import java.util.*;
|
||||
@@ -66,7 +66,7 @@ public class SignaturesPropagationData {
|
||||
private final List<TypeParameterDescriptor> modifiedTypeParameters;
|
||||
private final ValueParameters modifiedValueParameters;
|
||||
|
||||
private final JetType modifiedReturnType;
|
||||
private final KtType modifiedReturnType;
|
||||
private final List<String> signatureErrors = Lists.newArrayList();
|
||||
private final List<FunctionDescriptor> superFunctions;
|
||||
private final Map<TypeParameterDescriptor, TypeParameterDescriptorImpl> autoTypeParameterToModified;
|
||||
@@ -74,8 +74,8 @@ public class SignaturesPropagationData {
|
||||
|
||||
public SignaturesPropagationData(
|
||||
@NotNull ClassDescriptor containingClass,
|
||||
@NotNull JetType autoReturnType, // type built by JavaTypeTransformer from Java signature and @NotNull annotations
|
||||
@Nullable JetType receiverType,
|
||||
@NotNull KtType autoReturnType, // type built by JavaTypeTransformer from Java signature and @NotNull annotations
|
||||
@Nullable KtType receiverType,
|
||||
@NotNull List<ValueParameterDescriptor> autoValueParameters, // descriptors built by parameters resolver
|
||||
@NotNull List<TypeParameterDescriptor> autoTypeParameters, // descriptors built by signature resolver
|
||||
@NotNull JavaMethod method
|
||||
@@ -97,8 +97,8 @@ public class SignaturesPropagationData {
|
||||
@NotNull
|
||||
private static JavaMethodDescriptor createAutoMethodDescriptor(
|
||||
@NotNull ClassDescriptor containingClass,
|
||||
@NotNull JavaMethod method, JetType autoReturnType,
|
||||
@Nullable JetType receiverType,
|
||||
@NotNull JavaMethod method, KtType autoReturnType,
|
||||
@Nullable KtType receiverType,
|
||||
@NotNull List<ValueParameterDescriptor> autoValueParameters,
|
||||
@NotNull List<TypeParameterDescriptor> autoTypeParameters
|
||||
) {
|
||||
@@ -125,7 +125,7 @@ public class SignaturesPropagationData {
|
||||
return modifiedTypeParameters;
|
||||
}
|
||||
|
||||
public JetType getModifiedReceiverType() {
|
||||
public KtType getModifiedReceiverType() {
|
||||
return modifiedValueParameters.receiverType;
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ public class SignaturesPropagationData {
|
||||
return modifiedValueParameters.hasStableParameterNames;
|
||||
}
|
||||
|
||||
public JetType getModifiedReturnType() {
|
||||
public KtType getModifiedReturnType() {
|
||||
return modifiedReturnType;
|
||||
}
|
||||
|
||||
@@ -153,8 +153,8 @@ public class SignaturesPropagationData {
|
||||
signatureErrors.add(error);
|
||||
}
|
||||
|
||||
private JetType modifyReturnTypeAccordingToSuperMethods(
|
||||
@NotNull JetType autoType // type built by JavaTypeTransformer
|
||||
private KtType modifyReturnTypeAccordingToSuperMethods(
|
||||
@NotNull KtType autoType // type built by JavaTypeTransformer
|
||||
) {
|
||||
if (JavaDescriptorResolverKt.getPLATFORM_TYPES()) return autoType;
|
||||
|
||||
@@ -179,24 +179,24 @@ public class SignaturesPropagationData {
|
||||
int index = autoParameter.getIndex();
|
||||
TypeParameterDescriptorImpl modifiedTypeParameter = autoTypeParameterToModified.get(autoParameter);
|
||||
|
||||
List<Iterator<JetType>> upperBoundFromSuperFunctionsIterators = Lists.newArrayList();
|
||||
List<Iterator<KtType>> upperBoundFromSuperFunctionsIterators = Lists.newArrayList();
|
||||
for (FunctionDescriptor superFunction : superFunctions) {
|
||||
upperBoundFromSuperFunctionsIterators.add(superFunction.getTypeParameters().get(index).getUpperBounds().iterator());
|
||||
}
|
||||
|
||||
for (JetType autoUpperBound : autoParameter.getUpperBounds()) {
|
||||
for (KtType autoUpperBound : autoParameter.getUpperBounds()) {
|
||||
List<TypeAndVariance> upperBoundsFromSuperFunctions = Lists.newArrayList();
|
||||
|
||||
for (Iterator<JetType> iterator : upperBoundFromSuperFunctionsIterators) {
|
||||
for (Iterator<KtType> iterator : upperBoundFromSuperFunctionsIterators) {
|
||||
assert iterator.hasNext();
|
||||
upperBoundsFromSuperFunctions.add(new TypeAndVariance(iterator.next(), INVARIANT));
|
||||
}
|
||||
|
||||
JetType modifiedUpperBound = modifyTypeAccordingToSuperMethods(autoUpperBound, upperBoundsFromSuperFunctions, UPPER_BOUND);
|
||||
KtType modifiedUpperBound = modifyTypeAccordingToSuperMethods(autoUpperBound, upperBoundsFromSuperFunctions, UPPER_BOUND);
|
||||
modifiedTypeParameter.addUpperBound(modifiedUpperBound);
|
||||
}
|
||||
|
||||
for (Iterator<JetType> iterator : upperBoundFromSuperFunctionsIterators) {
|
||||
for (Iterator<KtType> iterator : upperBoundFromSuperFunctionsIterators) {
|
||||
assert !iterator.hasNext();
|
||||
}
|
||||
|
||||
@@ -208,14 +208,14 @@ public class SignaturesPropagationData {
|
||||
}
|
||||
|
||||
private ValueParameters modifyValueParametersAccordingToSuperMethods(
|
||||
@Nullable JetType receiverType,
|
||||
@Nullable KtType receiverType,
|
||||
@NotNull List<ValueParameterDescriptor> parameters // descriptors built by parameters resolver
|
||||
) {
|
||||
assert receiverType == null : "Parameters before propagation have receiver type," +
|
||||
" but propagation should be disabled for functions compiled from Kotlin in class: " +
|
||||
DescriptorUtils.getFqName(containingClass);
|
||||
|
||||
JetType resultReceiverType = null;
|
||||
KtType resultReceiverType = null;
|
||||
List<ValueParameterDescriptor> resultParameters = new ArrayList<ValueParameterDescriptor>(parameters.size());
|
||||
|
||||
boolean shouldBeExtension = checkIfShouldBeExtension();
|
||||
@@ -239,9 +239,9 @@ public class SignaturesPropagationData {
|
||||
|
||||
VarargCheckResult varargCheckResult = checkVarargInSuperFunctions(originalParam);
|
||||
|
||||
JetType altType = modifyTypeAccordingToSuperMethods(varargCheckResult.parameterType,
|
||||
convertToTypeVarianceList(typesFromSuperMethods),
|
||||
MEMBER_SIGNATURE_CONTRAVARIANT);
|
||||
KtType altType = modifyTypeAccordingToSuperMethods(varargCheckResult.parameterType,
|
||||
convertToTypeVarianceList(typesFromSuperMethods),
|
||||
MEMBER_SIGNATURE_CONTRAVARIANT);
|
||||
|
||||
if (shouldBeExtension && originalIndex == 0) {
|
||||
resultReceiverType = altType;
|
||||
@@ -304,7 +304,7 @@ public class SignaturesPropagationData {
|
||||
// TODO: Add propagation for other kotlin descriptors (KT-3621)
|
||||
Name name = method.getName();
|
||||
JvmMethodSignature autoSignature = SIGNATURE_MAPPER.mapToJvmMethodSignature(autoMethodDescriptor);
|
||||
for (JetType supertype : containingClass.getTypeConstructor().getSupertypes()) {
|
||||
for (KtType supertype : containingClass.getTypeConstructor().getSupertypes()) {
|
||||
Collection<FunctionDescriptor> superFunctionCandidates = supertype.getMemberScope().getFunctions(name, NoLookupLocation.WHEN_GET_SUPER_MEMBERS);
|
||||
for (FunctionDescriptor candidate : superFunctionCandidates) {
|
||||
JvmMethodSignature candidateSignature = SIGNATURE_MAPPER.mapToJvmMethodSignature(candidate);
|
||||
@@ -365,8 +365,8 @@ public class SignaturesPropagationData {
|
||||
}
|
||||
}
|
||||
|
||||
JetType originalVarargElementType = originalParam.getVarargElementType();
|
||||
JetType originalType = originalParam.getType();
|
||||
KtType originalVarargElementType = originalParam.getVarargElementType();
|
||||
KtType originalType = originalParam.getType();
|
||||
|
||||
if (someSupersVararg && someSupersNotVararg) {
|
||||
reportError("Incompatible super methods: some have vararg parameter, some have not");
|
||||
@@ -389,8 +389,8 @@ public class SignaturesPropagationData {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private JetType modifyTypeAccordingToSuperMethods(
|
||||
@NotNull JetType autoType,
|
||||
private KtType modifyTypeAccordingToSuperMethods(
|
||||
@NotNull KtType autoType,
|
||||
@NotNull List<TypeAndVariance> typesFromSuper,
|
||||
@NotNull TypeUsage howThisTypeIsUsed
|
||||
) {
|
||||
@@ -401,7 +401,7 @@ public class SignaturesPropagationData {
|
||||
boolean resultNullable = typeMustBeNullable(autoType, typesFromSuper, howThisTypeIsUsed);
|
||||
ClassifierDescriptor resultClassifier = modifyTypeClassifier(autoType, typesFromSuper);
|
||||
List<TypeProjection> resultArguments = getTypeArgsOfType(autoType, resultClassifier, typesFromSuper);
|
||||
JetScope resultScope;
|
||||
KtScope resultScope;
|
||||
if (resultClassifier instanceof ClassDescriptor) {
|
||||
resultScope = ((ClassDescriptor) resultClassifier).getMemberScope(resultArguments);
|
||||
}
|
||||
@@ -409,11 +409,11 @@ public class SignaturesPropagationData {
|
||||
resultScope = autoType.getMemberScope();
|
||||
}
|
||||
|
||||
JetType type = JetTypeImpl.create(autoType.getAnnotations(),
|
||||
resultClassifier.getTypeConstructor(),
|
||||
resultNullable,
|
||||
resultArguments,
|
||||
resultScope);
|
||||
KtType type = KtTypeImpl.create(autoType.getAnnotations(),
|
||||
resultClassifier.getTypeConstructor(),
|
||||
resultNullable,
|
||||
resultArguments,
|
||||
resultScope);
|
||||
|
||||
PropagationHeuristics.checkArrayInReturnType(this, type, typesFromSuper);
|
||||
return type;
|
||||
@@ -421,7 +421,7 @@ public class SignaturesPropagationData {
|
||||
|
||||
@NotNull
|
||||
private List<TypeProjection> getTypeArgsOfType(
|
||||
@NotNull JetType autoType,
|
||||
@NotNull KtType autoType,
|
||||
@NotNull ClassifierDescriptor classifier,
|
||||
@NotNull List<TypeAndVariance> typesFromSuper
|
||||
) {
|
||||
@@ -444,11 +444,11 @@ public class SignaturesPropagationData {
|
||||
for (TypeParameterDescriptor parameter : classifier.getTypeConstructor().getParameters()) {
|
||||
TypeProjection argument = autoArguments.get(parameter.getIndex());
|
||||
|
||||
JetType argumentType = argument.getType();
|
||||
KtType argumentType = argument.getType();
|
||||
List<TypeProjectionAndVariance> projectionsFromSuper = typeArgumentsFromSuper.get(parameter.getIndex());
|
||||
List<TypeAndVariance> argTypesFromSuper = getTypes(projectionsFromSuper);
|
||||
|
||||
JetType type = modifyTypeAccordingToSuperMethods(argumentType, argTypesFromSuper, TYPE_ARGUMENT);
|
||||
KtType type = modifyTypeAccordingToSuperMethods(argumentType, argTypesFromSuper, TYPE_ARGUMENT);
|
||||
Variance projectionKind = calculateArgumentProjectionKindFromSuper(argument, projectionsFromSuper);
|
||||
|
||||
resultArguments.add(new TypeProjectionImpl(projectionKind, type));
|
||||
@@ -567,7 +567,7 @@ public class SignaturesPropagationData {
|
||||
}
|
||||
|
||||
private boolean typeMustBeNullable(
|
||||
@NotNull JetType autoType,
|
||||
@NotNull KtType autoType,
|
||||
@NotNull List<TypeAndVariance> typesFromSuper,
|
||||
@NotNull TypeUsage howThisTypeIsUsed
|
||||
) {
|
||||
@@ -611,7 +611,7 @@ public class SignaturesPropagationData {
|
||||
|
||||
@NotNull
|
||||
private ClassifierDescriptor modifyTypeClassifier(
|
||||
@NotNull JetType autoType,
|
||||
@NotNull KtType autoType,
|
||||
@NotNull List<TypeAndVariance> typesFromSuper
|
||||
) {
|
||||
ClassifierDescriptor classifier = autoType.getConstructor().getDeclarationDescriptor();
|
||||
@@ -666,15 +666,15 @@ public class SignaturesPropagationData {
|
||||
return fixed != null ? fixed : classifier;
|
||||
}
|
||||
|
||||
private static boolean isArrayType(@NotNull JetType type) {
|
||||
private static boolean isArrayType(@NotNull KtType type) {
|
||||
return KotlinBuiltIns.isArray(type) || KotlinBuiltIns.isPrimitiveArray(type);
|
||||
}
|
||||
|
||||
private static class VarargCheckResult {
|
||||
public final JetType parameterType;
|
||||
public final KtType parameterType;
|
||||
public final boolean isVararg;
|
||||
|
||||
public VarargCheckResult(JetType parameterType, boolean isVararg) {
|
||||
public VarargCheckResult(KtType parameterType, boolean isVararg) {
|
||||
this.parameterType = parameterType;
|
||||
this.isVararg = isVararg;
|
||||
}
|
||||
@@ -695,10 +695,10 @@ public class SignaturesPropagationData {
|
||||
}
|
||||
|
||||
static class TypeAndVariance {
|
||||
public final JetType type;
|
||||
public final KtType type;
|
||||
public final Variance varianceOfPosition;
|
||||
|
||||
public TypeAndVariance(JetType type, Variance varianceOfPosition) {
|
||||
public TypeAndVariance(KtType type, Variance varianceOfPosition) {
|
||||
this.type = type;
|
||||
this.varianceOfPosition = varianceOfPosition;
|
||||
}
|
||||
@@ -709,22 +709,22 @@ public class SignaturesPropagationData {
|
||||
}
|
||||
|
||||
private static class TypeAndName {
|
||||
public final JetType type;
|
||||
public final KtType type;
|
||||
public final Name name;
|
||||
|
||||
public TypeAndName(JetType type, Name name) {
|
||||
public TypeAndName(KtType type, Name name) {
|
||||
this.type = type;
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
||||
private static class ValueParameters {
|
||||
private final JetType receiverType;
|
||||
private final KtType receiverType;
|
||||
private final List<ValueParameterDescriptor> descriptors;
|
||||
private final boolean hasStableParameterNames;
|
||||
|
||||
public ValueParameters(
|
||||
@Nullable JetType receiverType,
|
||||
@Nullable KtType receiverType,
|
||||
@NotNull List<ValueParameterDescriptor> descriptors,
|
||||
boolean hasStableParameterNames
|
||||
) {
|
||||
|
||||
+26
-26
@@ -34,7 +34,7 @@ import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
||||
import org.jetbrains.kotlin.resolve.TypeResolver;
|
||||
import org.jetbrains.kotlin.resolve.jvm.JavaDescriptorResolverKt;
|
||||
import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform;
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope;
|
||||
import org.jetbrains.kotlin.resolve.scopes.KtScope;
|
||||
import org.jetbrains.kotlin.types.*;
|
||||
|
||||
import java.util.*;
|
||||
@@ -42,16 +42,16 @@ import java.util.*;
|
||||
import static org.jetbrains.kotlin.load.java.components.TypeUsage.TYPE_ARGUMENT;
|
||||
import static org.jetbrains.kotlin.types.Variance.INVARIANT;
|
||||
|
||||
public class TypeTransformingVisitor extends JetVisitor<JetType, Void> {
|
||||
public class TypeTransformingVisitor extends KtVisitor<KtType, Void> {
|
||||
private static boolean strictMode = false;
|
||||
|
||||
private final JetType originalType;
|
||||
private final KtType originalType;
|
||||
private final Map<TypeParameterDescriptor, TypeParameterDescriptorImpl> originalToAltTypeParameters;
|
||||
|
||||
private final TypeUsage typeUsage;
|
||||
|
||||
private TypeTransformingVisitor(
|
||||
JetType originalType,
|
||||
KtType originalType,
|
||||
Map<TypeParameterDescriptor, TypeParameterDescriptorImpl> originalToAltTypeParameters,
|
||||
TypeUsage typeUsage
|
||||
) {
|
||||
@@ -61,30 +61,30 @@ public class TypeTransformingVisitor extends JetVisitor<JetType, Void> {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static JetType computeType(
|
||||
@NotNull JetTypeElement alternativeTypeElement,
|
||||
@NotNull JetType originalType,
|
||||
public static KtType computeType(
|
||||
@NotNull KtTypeElement alternativeTypeElement,
|
||||
@NotNull KtType originalType,
|
||||
@NotNull Map<TypeParameterDescriptor, TypeParameterDescriptorImpl> originalToAltTypeParameters,
|
||||
@NotNull TypeUsage typeUsage
|
||||
) {
|
||||
JetType computedType = alternativeTypeElement.accept(new TypeTransformingVisitor(originalType, originalToAltTypeParameters, typeUsage), null);
|
||||
KtType computedType = alternativeTypeElement.accept(new TypeTransformingVisitor(originalType, originalToAltTypeParameters, typeUsage), null);
|
||||
assert (computedType != null);
|
||||
return computedType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetType visitNullableType(@NotNull JetNullableType nullableType, Void aVoid) {
|
||||
public KtType visitNullableType(@NotNull KtNullableType nullableType, Void aVoid) {
|
||||
if (!TypeUtils.isNullableType(originalType) && typeUsage != TYPE_ARGUMENT) {
|
||||
throw new AlternativeSignatureMismatchException("Auto type '%s' is not-null, while type in alternative signature is nullable: '%s'",
|
||||
DescriptorRenderer.FQ_NAMES_IN_TYPES.renderType(originalType), nullableType.getText());
|
||||
}
|
||||
JetTypeElement innerType = nullableType.getInnerType();
|
||||
KtTypeElement innerType = nullableType.getInnerType();
|
||||
assert innerType != null : "Syntax error: " + nullableType.getText();
|
||||
return TypeUtils.makeNullable(computeType(innerType, originalType, originalToAltTypeParameters, typeUsage));
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetType visitFunctionType(@NotNull JetFunctionType type, Void data) {
|
||||
public KtType visitFunctionType(@NotNull KtFunctionType type, Void data) {
|
||||
KotlinBuiltIns builtIns = JvmPlatform.INSTANCE$.getBuiltIns();
|
||||
return visitCommonType(type.getReceiverTypeReference() == null
|
||||
? builtIns.getFunction(type.getParameters().size())
|
||||
@@ -92,8 +92,8 @@ public class TypeTransformingVisitor extends JetVisitor<JetType, Void> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetType visitUserType(@NotNull JetUserType type, Void data) {
|
||||
JetUserType qualifier = type.getQualifier();
|
||||
public KtType visitUserType(@NotNull KtUserType type, Void data) {
|
||||
KtUserType qualifier = type.getQualifier();
|
||||
|
||||
//noinspection ConstantConditions
|
||||
String shortName = type.getReferenceExpression().getReferencedName();
|
||||
@@ -102,12 +102,12 @@ public class TypeTransformingVisitor extends JetVisitor<JetType, Void> {
|
||||
return visitCommonType(longName, type);
|
||||
}
|
||||
|
||||
private JetType visitCommonType(@NotNull ClassDescriptor classDescriptor, @NotNull JetTypeElement type) {
|
||||
private KtType visitCommonType(@NotNull ClassDescriptor classDescriptor, @NotNull KtTypeElement type) {
|
||||
return visitCommonType(DescriptorUtils.getFqNameSafe(classDescriptor).asString(), type);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private JetType visitCommonType(@NotNull String qualifiedName, @NotNull JetTypeElement type) {
|
||||
private KtType visitCommonType(@NotNull String qualifiedName, @NotNull KtTypeElement type) {
|
||||
if (originalType.isError()) {
|
||||
return originalType;
|
||||
}
|
||||
@@ -148,7 +148,7 @@ public class TypeTransformingVisitor extends JetVisitor<JetType, Void> {
|
||||
altArguments.add(getAltArgument(type, typeConstructor, i, arguments.get(i)));
|
||||
}
|
||||
|
||||
JetScope memberScope;
|
||||
KtScope memberScope;
|
||||
if (typeConstructorClassifier instanceof TypeParameterDescriptor) {
|
||||
memberScope = ((TypeParameterDescriptor) typeConstructorClassifier).getUpperBoundsAsType().getMemberScope();
|
||||
}
|
||||
@@ -159,35 +159,35 @@ public class TypeTransformingVisitor extends JetVisitor<JetType, Void> {
|
||||
throw new AssertionError("Unexpected class of type constructor classifier "
|
||||
+ (typeConstructorClassifier == null ? "null" : typeConstructorClassifier.getClass().getName()));
|
||||
}
|
||||
return JetTypeImpl.create(originalType.getAnnotations(), typeConstructor, false, altArguments, memberScope);
|
||||
return KtTypeImpl.create(originalType.getAnnotations(), typeConstructor, false, altArguments, memberScope);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private TypeProjection getAltArgument(
|
||||
@NotNull JetTypeElement type,
|
||||
@NotNull KtTypeElement type,
|
||||
@NotNull TypeConstructor typeConstructor,
|
||||
int i,
|
||||
@NotNull TypeProjection originalArgument
|
||||
) {
|
||||
JetTypeReference typeReference = type.getTypeArgumentsAsTypes().get(i); // process both function type and user type
|
||||
KtTypeReference typeReference = type.getTypeArgumentsAsTypes().get(i); // process both function type and user type
|
||||
|
||||
if (typeReference == null) {
|
||||
// star projection
|
||||
assert type instanceof JetUserType
|
||||
&& ((JetUserType) type).getTypeArguments().get(i).getProjectionKind() == JetProjectionKind.STAR;
|
||||
assert type instanceof KtUserType
|
||||
&& ((KtUserType) type).getTypeArguments().get(i).getProjectionKind() == KtProjectionKind.STAR;
|
||||
|
||||
return originalArgument;
|
||||
}
|
||||
|
||||
JetTypeElement argumentAlternativeTypeElement = typeReference.getTypeElement();
|
||||
KtTypeElement argumentAlternativeTypeElement = typeReference.getTypeElement();
|
||||
assert argumentAlternativeTypeElement != null;
|
||||
|
||||
TypeParameterDescriptor parameter = typeConstructor.getParameters().get(i);
|
||||
JetType alternativeArgumentType = computeType(argumentAlternativeTypeElement, originalArgument.getType(), originalToAltTypeParameters, TYPE_ARGUMENT);
|
||||
KtType alternativeArgumentType = computeType(argumentAlternativeTypeElement, originalArgument.getType(), originalToAltTypeParameters, TYPE_ARGUMENT);
|
||||
Variance projectionKind = originalArgument.getProjectionKind();
|
||||
Variance altProjectionKind;
|
||||
if (type instanceof JetUserType) {
|
||||
JetTypeProjection typeProjection = ((JetUserType) type).getTypeArguments().get(i);
|
||||
if (type instanceof KtUserType) {
|
||||
KtTypeProjection typeProjection = ((KtUserType) type).getTypeArguments().get(i);
|
||||
altProjectionKind = TypeResolver.resolveProjectionKind(typeProjection.getProjectionKind());
|
||||
if (altProjectionKind != projectionKind && projectionKind != Variance.INVARIANT && !JavaDescriptorResolverKt.getPLATFORM_TYPES()) {
|
||||
throw new AlternativeSignatureMismatchException("Projection kind mismatch, actual: %s, in alternative signature: %s",
|
||||
@@ -234,7 +234,7 @@ public class TypeTransformingVisitor extends JetVisitor<JetType, Void> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public JetType visitSelfType(@NotNull JetSelfType type, Void data) {
|
||||
public KtType visitSelfType(@NotNull KtSelfType type, Void data) {
|
||||
throw new UnsupportedOperationException("Self-types are not supported yet");
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -18,14 +18,14 @@ package org.jetbrains.kotlin.resolve.jvm.platform
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor
|
||||
import org.jetbrains.kotlin.load.java.lazy.types.RawTypeTag
|
||||
import org.jetbrains.kotlin.psi.JetExpression
|
||||
import org.jetbrains.kotlin.psi.KtExpression
|
||||
import org.jetbrains.kotlin.resolve.calls.checkers.AdditionalTypeChecker
|
||||
import org.jetbrains.kotlin.resolve.calls.context.CallResolutionContext
|
||||
import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.checker.JetTypeChecker
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
|
||||
import org.jetbrains.kotlin.types.checker.TypeCheckingProcedure
|
||||
|
||||
public object JavaGenericVarianceViolationTypeChecker : AdditionalTypeChecker {
|
||||
@@ -38,9 +38,9 @@ public object JavaGenericVarianceViolationTypeChecker : AdditionalTypeChecker {
|
||||
// val x: MutableList<String>
|
||||
// JavaClass.fillWithDefaultObjects(x) // using `x` after this call may lead to CCE
|
||||
override fun checkType(
|
||||
expression: JetExpression,
|
||||
expressionType: JetType,
|
||||
expressionTypeWithSmartCast: JetType,
|
||||
expression: KtExpression,
|
||||
expressionType: KtType,
|
||||
expressionTypeWithSmartCast: KtType,
|
||||
c: ResolutionContext<*>
|
||||
) {
|
||||
val expectedType = c.expectedType
|
||||
@@ -82,7 +82,7 @@ public object JavaGenericVarianceViolationTypeChecker : AdditionalTypeChecker {
|
||||
if (lowerParameters[index].variance == Variance.INVARIANT
|
||||
&& upperParameters[index].variance == Variance.OUT_VARIANCE
|
||||
&& lowerArgument.projectionKind != Variance.OUT_VARIANCE
|
||||
&& !JetTypeChecker.DEFAULT.equalTypes(correspondingSubType.arguments[index].type, lowerArgument.type)
|
||||
&& !KotlinTypeChecker.DEFAULT.equalTypes(correspondingSubType.arguments[index].type, lowerArgument.type)
|
||||
) {
|
||||
c.trace.report(ErrorsJvm.JAVA_TYPE_MISMATCH.on(expression, expressionTypeWithSmartCast, expectedType))
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.jetbrains.kotlin.resolve.ImportPath
|
||||
import org.jetbrains.kotlin.resolve.PlatformConfigurator
|
||||
import org.jetbrains.kotlin.resolve.TargetPlatform
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.KtScope
|
||||
import java.util.*
|
||||
|
||||
public object JvmPlatform : TargetPlatform("JVM") {
|
||||
@@ -50,8 +50,8 @@ private val DEFAULT_IMPORTS_FOR_JVM = ArrayList<ImportPath>().apply {
|
||||
add(ImportPath("kotlin.jvm.*"))
|
||||
add(ImportPath("kotlin.io.*"))
|
||||
|
||||
fun addAllClassifiersFromScope(scope: JetScope) {
|
||||
for (descriptor in scope.getDescriptors(DescriptorKindFilter.CLASSIFIERS, JetScope.ALL_NAME_FILTER)) {
|
||||
fun addAllClassifiersFromScope(scope: KtScope) {
|
||||
for (descriptor in scope.getDescriptors(DescriptorKindFilter.CLASSIFIERS, KtScope.ALL_NAME_FILTER)) {
|
||||
add(ImportPath(DescriptorUtils.getFqNameSafe(descriptor), false))
|
||||
}
|
||||
}
|
||||
|
||||
+7
-7
@@ -28,8 +28,8 @@ import org.jetbrains.kotlin.load.java.JvmAbi
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScopeImpl
|
||||
import org.jetbrains.kotlin.resolve.scopes.KtScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.KtScopeImpl
|
||||
import org.jetbrains.kotlin.storage.StorageManager
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.typeUtil.isSubtypeOf
|
||||
@@ -47,7 +47,7 @@ interface SyntheticJavaPropertyDescriptor : PropertyDescriptor {
|
||||
val setMethod: FunctionDescriptor?
|
||||
|
||||
companion object {
|
||||
fun findByGetterOrSetter(getterOrSetter: FunctionDescriptor, resolutionScope: JetScope): SyntheticJavaPropertyDescriptor? {
|
||||
fun findByGetterOrSetter(getterOrSetter: FunctionDescriptor, resolutionScope: KtScope): SyntheticJavaPropertyDescriptor? {
|
||||
val name = getterOrSetter.getName()
|
||||
if (name.isSpecial()) return null
|
||||
val identifier = name.getIdentifier()
|
||||
@@ -69,7 +69,7 @@ interface SyntheticJavaPropertyDescriptor : PropertyDescriptor {
|
||||
}
|
||||
}
|
||||
|
||||
class JavaSyntheticPropertiesScope(storageManager: StorageManager) : JetScopeImpl() {
|
||||
class JavaSyntheticPropertiesScope(storageManager: StorageManager) : KtScopeImpl() {
|
||||
private val syntheticPropertyInClass = storageManager.createMemoizedFunctionWithNullableValues<Pair<ClassDescriptor, Name>, PropertyDescriptor> { pair ->
|
||||
syntheticPropertyInClassNotCached(pair.first, pair.second)
|
||||
}
|
||||
@@ -130,7 +130,7 @@ class JavaSyntheticPropertiesScope(storageManager: StorageManager) : JetScopeImp
|
||||
return null
|
||||
}
|
||||
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name, location: LookupLocation): Collection<PropertyDescriptor> {
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KtType>, name: Name, location: LookupLocation): Collection<PropertyDescriptor> {
|
||||
//TODO: use location parameter!
|
||||
|
||||
var result: SmartList<PropertyDescriptor>? = null
|
||||
@@ -162,7 +162,7 @@ class JavaSyntheticPropertiesScope(storageManager: StorageManager) : JetScopeImp
|
||||
return result
|
||||
}
|
||||
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>): Collection<PropertyDescriptor> {
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<KtType>): Collection<PropertyDescriptor> {
|
||||
val result = ArrayList<PropertyDescriptor>()
|
||||
val processedTypes = HashSet<TypeConstructor>()
|
||||
receiverTypes.forEach { result.collectSyntheticProperties(it.constructor, processedTypes) }
|
||||
@@ -253,7 +253,7 @@ class JavaSyntheticPropertiesScope(storageManager: StorageManager) : JetScopeImp
|
||||
private set
|
||||
|
||||
companion object {
|
||||
fun create(ownerClass: ClassDescriptor, getMethod: FunctionDescriptor, setMethod: FunctionDescriptor?, name: Name, type: JetType): MyPropertyDescriptor {
|
||||
fun create(ownerClass: ClassDescriptor, getMethod: FunctionDescriptor, setMethod: FunctionDescriptor?, name: Name, type: KtType): MyPropertyDescriptor {
|
||||
val visibility = syntheticExtensionVisibility(getMethod)
|
||||
val descriptor = MyPropertyDescriptor(DescriptorUtils.getContainingModule(ownerClass),
|
||||
null,
|
||||
|
||||
+6
-6
@@ -27,7 +27,7 @@ import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.parentsWithSelf
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.KtScope
|
||||
import org.jetbrains.kotlin.storage.StorageManager
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import java.util.*
|
||||
@@ -37,7 +37,7 @@ interface SamAdapterExtensionFunctionDescriptor : FunctionDescriptor {
|
||||
val sourceFunction: FunctionDescriptor
|
||||
}
|
||||
|
||||
class SamAdapterFunctionsScope(storageManager: StorageManager) : JetScope by JetScope.Empty {
|
||||
class SamAdapterFunctionsScope(storageManager: StorageManager) : KtScope by KtScope.Empty {
|
||||
private val extensionForFunction = storageManager.createMemoizedFunctionWithNullableValues<FunctionDescriptor, FunctionDescriptor> { function ->
|
||||
extensionForFunctionNotCached(function)
|
||||
}
|
||||
@@ -52,7 +52,7 @@ class SamAdapterFunctionsScope(storageManager: StorageManager) : JetScope by Jet
|
||||
return MyFunctionDescriptor.create(enhancedFunction)
|
||||
}
|
||||
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>, name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<KtType>, name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
|
||||
var result: SmartList<FunctionDescriptor>? = null
|
||||
for (type in receiverTypes) {
|
||||
for (function in type.memberScope.getFunctions(name, location)) {
|
||||
@@ -72,7 +72,7 @@ class SamAdapterFunctionsScope(storageManager: StorageManager) : JetScope by Jet
|
||||
}
|
||||
}
|
||||
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>): Collection<FunctionDescriptor> {
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<KtType>): Collection<FunctionDescriptor> {
|
||||
return receiverTypes.flatMapTo(LinkedHashSet<FunctionDescriptor>()) { type ->
|
||||
type.memberScope.getDescriptors(DescriptorKindFilter.FUNCTIONS)
|
||||
.filterIsInstance<FunctionDescriptor>()
|
||||
@@ -156,8 +156,8 @@ class SamAdapterFunctionsScope(storageManager: StorageManager) : JetScope by Jet
|
||||
copyOverrides: Boolean,
|
||||
kind: CallableMemberDescriptor.Kind,
|
||||
newValueParameterDescriptors: MutableList<ValueParameterDescriptor>,
|
||||
newExtensionReceiverParameterType: JetType?,
|
||||
newReturnType: JetType
|
||||
newExtensionReceiverParameterType: KtType?,
|
||||
newReturnType: KtType
|
||||
): FunctionDescriptor? {
|
||||
val descriptor = super<SimpleFunctionDescriptorImpl>.doSubstitute(
|
||||
originalSubstitutor, newOwner, newModality, newVisibility,
|
||||
|
||||
Reference in New Issue
Block a user