Fix compiler warnings in compiler code

This commit is contained in:
Alexander Udalov
2020-08-14 12:55:43 +02:00
parent 9b94e073af
commit a21f273570
84 changed files with 149 additions and 141 deletions
@@ -14,6 +14,8 @@
* limitations under the License.
*/
@file:Suppress("UNUSED_PARAMETER")
package org.jetbrains.kotlin.incremental
import org.jetbrains.kotlin.library.metadata.KlibMetadataProtoBuf
@@ -173,7 +173,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
return null;
}
static class BlockStackElement {
public static class BlockStackElement {
}
static class LoopBlockStackElement extends BlockStackElement {
@@ -2224,8 +2224,9 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
if (!skipPropertyAccessors) {
if (isBackingFieldMovedFromCompanion && context.getContextDescriptor() instanceof AccessorForPropertyBackingField) {
propertyDescriptor = (PropertyDescriptor) backingFieldContext.getParentContext()
.getAccessor(propertyDescriptor, AccessorKind.IN_CLASS_COMPANION, delegateType, superCallTarget);
CodegenContext<?> parentContext = backingFieldContext.getParentContext();
propertyDescriptor =
parentContext.getAccessor(propertyDescriptor, AccessorKind.IN_CLASS_COMPANION, delegateType, superCallTarget);
}
else {
propertyDescriptor =
@@ -1543,7 +1543,7 @@ public abstract class StackValue {
//TODO: try to don't generate defaults at all in CollectionElementReceiver
List<ResolvedValueArgument> getterArguments = new ArrayList(collectionElementReceiver.valueArguments);
List<ResolvedValueArgument> getterArguments = new ArrayList<>(collectionElementReceiver.valueArguments);
List<ResolvedValueArgument> getterDefaults = CollectionsKt.takeLastWhile(getterArguments,
argument -> argument instanceof DefaultValueArgument);
@@ -171,7 +171,7 @@ public class InternalFinallyBlockInliner extends CoveringTryCatchNodeProcessor {
checkClusterInvariant(clustersFromInnermost);
int originalDepthIndex = 0;
List<TryCatchBlockNodeInfo> nestedUnsplitBlocksWithoutFinally = new ArrayList();
List<TryCatchBlockNodeInfo> nestedUnsplitBlocksWithoutFinally = new ArrayList<>();
while (tryCatchBlockIterator.hasNext()) {
TryBlockCluster<TryCatchBlockNodeInfo> clusterToFindFinally = tryCatchBlockIterator.next();
List<TryCatchBlockNodeInfo> clusterBlocks = clusterToFindFinally.getBlocks();
@@ -35,7 +35,7 @@ private class State<T>(val path: MutableList<String>) {
path.add(step)
}
fun removeStep(step: String) {
fun removeStep() {
path.removeAt(path.lastIndex)
}
@@ -93,7 +93,7 @@ abstract class TypeAnnotationCollector<T>(val context: TypeSystemCommonBackendCo
fun KotlinTypeMarker.process(step: String) {
state.addStep(step)
this.gatherTypeAnnotations()
state.removeStep(step)
state.removeStep()
}
@@ -34,12 +34,12 @@ fun String.replUnescapeLineBreaks() = StringUtil.replace(this, XML_REPLACEMENTS,
fun String.replEscapeLineBreaks() = StringUtil.replace(this, SOURCE_CHARS, XML_REPLACEMENTS)
fun String.replOutputAsXml(escapeType: ReplEscapeType): String {
val escapedXml = StringUtil.escapeXml(replEscapeLineBreaks())
val escapedXml = StringUtil.escapeXmlEntities(replEscapeLineBreaks())
return "$XML_PREAMBLE<output type=\"$escapeType\">$escapedXml</output>"
}
fun String.replInputAsXml(): String {
val escapedXml = StringUtil.escapeXml(replEscapeLineBreaks())
val escapedXml = StringUtil.escapeXmlEntities(replEscapeLineBreaks())
return "$XML_PREAMBLE<input>$escapedXml</input>"
}
@@ -86,4 +86,4 @@ internal fun URLClassLoader.listLocalUrlsAsFiles(): List<File> {
internal fun <T : Any> List<T>.ensureNotEmpty(error: String): List<T> {
if (this.isEmpty()) throw IllegalStateException(error)
return this
}
}
@@ -102,6 +102,6 @@ public class Usage {
private static void appendln(@NotNull StringBuilder sb, @NotNull String string) {
sb.append(string);
StringsKt.appendln(sb);
sb.append('\n');
}
}
@@ -38,7 +38,7 @@ class CliKotlinAsJavaSupport(
override fun getFacadeClassesInPackage(packageFqName: FqName, scope: GlobalSearchScope): Collection<PsiClass> {
return findFacadeFilesInPackage(packageFqName, scope)
.groupBy { it.javaFileFacadeFqName }
.mapNotNull { (facadeClassFqName, files) ->
.mapNotNull { (facadeClassFqName, _) ->
KtLightClassForFacade.createForFacade(psiManager, facadeClassFqName, scope)
}
}
@@ -608,7 +608,10 @@ class KotlinCoreEnvironment private constructor(
// made public for Upsource
@JvmStatic
@Deprecated("Use registerProjectServices(project) instead.", ReplaceWith("registerProjectServices(projectEnvironment.project)"))
fun registerProjectServices(projectEnvironment: JavaCoreProjectEnvironment, messageCollector: MessageCollector?) {
fun registerProjectServices(
projectEnvironment: JavaCoreProjectEnvironment,
@Suppress("UNUSED_PARAMETER") messageCollector: MessageCollector?
) {
registerProjectServices(projectEnvironment.project)
}
@@ -471,7 +471,6 @@ object KotlinToJVMBytecodeCompiler {
psiSource.psi, this.a, this.b, this.c, factory.psiDiagnosticFactory, severity
)
}
throw IllegalArgumentException("Unknown diagnostics: $this")
}
private fun getBuildFilePaths(buildFile: File?, sourceFilePaths: List<String>): List<String> =
@@ -79,6 +79,7 @@ internal class ComponentRegistry {
By mimicking the usual descriptors we get lazy evaluation and consistency checks for free.
*/
for (resolver in clashResolvers) {
@Suppress("UNCHECKED_CAST")
val clashedComponents = registrationMap[resolver.applicableTo] as? Collection<ComponentDescriptor> ?: continue
if (clashedComponents.size <= 1) continue
@@ -86,4 +87,4 @@ internal class ComponentRegistry {
registrationMap[resolver.applicableTo] = substituteDescriptor
}
}
}
}
@@ -153,6 +153,7 @@ internal class ClashResolutionDescriptor<E : PlatformSpecificExtension<E>>(
override fun createInstance(context: ValueResolveContext): Any {
state = ComponentState.Initializing
@Suppress("UNCHECKED_CAST")
val extensions = computeArguments(clashedComponents) as List<E>
val resolution = resolver.resolveExtensionsClash(extensions)
state = ComponentState.Initialized
@@ -7,9 +7,8 @@ package org.jetbrains.kotlin.analyzer
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.PlatformDependentAnalyzerServices
import org.jetbrains.kotlin.platform.TargetPlatform
import org.jetbrains.kotlin.resolve.PlatformDependentAnalyzerServices
interface ModuleInfo {
val name: Name
@@ -30,7 +29,7 @@ interface ModuleInfo {
// but if they are present, they should come after JVM built-ins in the dependencies list, because JVM built-ins contain
// additional members dependent on the JDK
fun dependencyOnBuiltIns(): ModuleInfo.DependencyOnBuiltIns =
analyzerServices?.dependencyOnBuiltIns() ?: ModuleInfo.DependencyOnBuiltIns.LAST
analyzerServices.dependencyOnBuiltIns()
//TODO: (module refactoring) provide dependency on builtins after runtime in IDEA
enum class DependencyOnBuiltIns { NONE, AFTER_SDK, LAST }
@@ -41,4 +40,4 @@ interface ModuleInfo {
}
val ModuleDescriptor.moduleInfo: ModuleInfo?
get() = getCapability(ModuleInfo.Capability)
get() = getCapability(ModuleInfo.Capability)
@@ -83,7 +83,7 @@ class JvmResolverForModuleFactory(
}
val resolverForModule = resolverForReferencedModule?.takeIf {
referencedClassModule.platform.isJvm() || referencedClassModule.platform == null
referencedClassModule.platform.isJvm()
} ?: run {
// in case referenced class lies outside of our resolver, resolve the class as if it is inside our module
// this leads to java class being resolved several times
@@ -95,7 +95,7 @@ class JvmResolverForModuleFactory(
val trace = CodeAnalyzerInitializer.getInstance(project).createTrace()
val lookupTracker = LookupTracker.DO_NOTHING
val packagePartProvider = (platformParameters as JvmPlatformParameters).packagePartProviderFactory(moduleContent)
val packagePartProvider = platformParameters.packagePartProviderFactory(moduleContent)
val container = createContainerForLazyResolveWithJava(
moduleDescriptor.platform!!,
moduleContext,
@@ -86,6 +86,7 @@ public class KotlinJavaPsiFacade {
private long lastTimeSeen = -1L;
@Override
@SuppressWarnings("deprecation")
public void modificationCountChanged() {
long now = modificationTracker.getJavaStructureModificationCount();
if (lastTimeSeen != now) {
@@ -75,8 +75,8 @@ class EmptyResolverForProject<M : ModuleInfo> : ResolverForProject<M>() {
override val allModules: Collection<M> = listOf()
override fun diagnoseUnknownModuleInfo(infos: List<ModuleInfo>) = throw IllegalStateException("Should not be called for $infos")
override fun moduleInfoForModuleDescriptor(descriptor: ModuleDescriptor): M {
throw IllegalStateException("$descriptor is not contained in this resolver")
override fun moduleInfoForModuleDescriptor(moduleDescriptor: ModuleDescriptor): M {
throw IllegalStateException("$moduleDescriptor is not contained in this resolver")
}
}
@@ -6,12 +6,10 @@
package org.jetbrains.kotlin.checkers.diagnostics
import com.intellij.openapi.util.text.StringUtil
import com.intellij.psi.PsiElement
import com.intellij.util.containers.ContainerUtil
import org.jetbrains.kotlin.checkers.diagnostics.factories.DebugInfoDiagnosticFactory1
import org.jetbrains.kotlin.checkers.utils.CheckerTestUtil
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.diagnostics.DiagnosticWithParameters1
import org.jetbrains.kotlin.diagnostics.rendering.AbstractDiagnosticWithParametersRenderer
import org.jetbrains.kotlin.diagnostics.rendering.DefaultErrorMessages
import org.jetbrains.kotlin.diagnostics.rendering.DiagnosticRenderer
@@ -143,7 +141,10 @@ class TextDiagnostic(
private fun asTextDiagnostic(actualDiagnostic: ActualDiagnostic): TextDiagnostic {
val diagnostic = actualDiagnostic.diagnostic
val renderer = when (diagnostic.factory) {
is DebugInfoDiagnosticFactory1 -> DiagnosticWithParameters1Renderer("{0}", TO_STRING) as DiagnosticRenderer<Diagnostic>
is DebugInfoDiagnosticFactory1 -> {
@Suppress("UNCHECKED_CAST")
DiagnosticWithParameters1Renderer("{0}", TO_STRING) as DiagnosticRenderer<Diagnostic>
}
else -> DefaultErrorMessages.getRendererForDiagnostic(diagnostic)
}
val diagnosticName = actualDiagnostic.name
@@ -1180,6 +1180,7 @@ public interface Errors {
initializeFactoryNamesAndDefaultErrorMessages(aClass, DiagnosticFactoryToRendererMap::new);
}
@SuppressWarnings({"unchecked", "rawtypes"})
public static void initializeFactoryNamesAndDefaultErrorMessages(
@NotNull Class<?> aClass,
@NotNull DefaultErrorMessages.Extension defaultErrorMessages
@@ -1193,7 +1194,6 @@ public interface Errors {
DiagnosticFactory<?> factory = (DiagnosticFactory<?>)value;
factory.setName(field.getName());
//noinspection rawtypes, unchecked
factory.setDefaultRenderer((DiagnosticRenderer) diagnosticToRendererMap.get(factory));
}
}
@@ -148,7 +148,7 @@ fun getEnclosingDescriptor(context: BindingContext, element: KtElement): Declara
getEnclosingDescriptor(context, declaration)
} else {
context.get(DECLARATION_TO_DESCRIPTOR, declaration)
?: throw KotlinExceptionWithAttachments("No descriptor for named declaration of type ${declaration?.javaClass}")
?: throw KotlinExceptionWithAttachments("No descriptor for named declaration of type ${declaration.javaClass}")
.withAttachment("declaration.kt", declaration.text)
}
}
@@ -76,7 +76,7 @@ internal class InlineChecker(private val descriptor: FunctionDescriptor) : CallC
if (inlinableParameters.contains(targetDescriptor)) {
when {
!checkNotInDefaultParameter(context, targetDescriptor, expression) -> { /*error*/
!checkNotInDefaultParameter(context, expression) -> { /*error*/
}
!isInsideCall(expression) -> context.trace.report(USAGE_IS_NOT_INLINABLE.on(expression, expression, descriptor))
}
@@ -94,7 +94,7 @@ internal class InlineChecker(private val descriptor: FunctionDescriptor) : CallC
checkRecursion(context, targetDescriptor, expression)
}
private fun checkNotInDefaultParameter(context: CallCheckerContext, targetDescriptor: CallableDescriptor, expression: KtExpression) =
private fun checkNotInDefaultParameter(context: CallCheckerContext, expression: KtExpression) =
!supportDefaultValueInline || expression.getParentOfType<KtParameter>(true)?.let {
val allow = it !in inlinableKtParameters
if (!allow) {
@@ -145,7 +145,7 @@ internal class InlineChecker(private val descriptor: FunctionDescriptor) : CallC
if (argumentCallee != null && inlinableParameters.contains(argumentCallee)) {
when {
!checkNotInDefaultParameter(context, argumentCallee, argumentExpression) -> { /*error*/
!checkNotInDefaultParameter(context, argumentExpression) -> { /*error*/
}
InlineUtil.isInline(targetDescriptor) && InlineUtil.isInlineParameter(targetParameterDescriptor) ->
@@ -24,10 +24,8 @@ import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils
import org.jetbrains.kotlin.types.isError
class DataFlowValueFactoryImpl
@Deprecated("Please, avoid to use that implementation explicitly. If you need DataFlowValueFactory, use injection")
constructor(private val languageVersionSettings: LanguageVersionSettings) : DataFlowValueFactory {
// Please, avoid using this implementation explicitly. If you need DataFlowValueFactory, use injection.
class DataFlowValueFactoryImpl constructor(private val languageVersionSettings: LanguageVersionSettings) : DataFlowValueFactory {
// Receivers
override fun createDataFlowValue(
receiverValue: ReceiverValue,
@@ -312,10 +312,10 @@ class KotlinResolutionCallbacksImpl(
return convertSignedConstantToUnsigned(argumentExpression)
}
override fun recordInlinabilityOfLambda(lambdas: Set<Map.Entry<KotlinResolutionCandidate, ResolvedLambdaAtom>>) {
val call = lambdas.first().value.atom.psiCallArgument.valueArgument as? KtLambdaArgument ?: return
override fun recordInlinabilityOfLambda(atom: Set<Map.Entry<KotlinResolutionCandidate, ResolvedLambdaAtom>>) {
val call = atom.first().value.atom.psiCallArgument.valueArgument as? KtLambdaArgument ?: return
val literal = call.getLambdaExpression()?.functionLiteral ?: return
val isLambdaInline = lambdas.all { (candidate, atom) ->
val isLambdaInline = atom.all { (candidate, atom) ->
if (!InlineUtil.isInline(candidate.resolvedCall.candidateDescriptor)) return
val valueParameterDescriptor = candidate.resolvedCall.argumentToCandidateParameter[atom.atom] ?: return
InlineUtil.isInlineParameter(valueParameterDescriptor)
@@ -155,6 +155,7 @@ class KotlinToResolvedCallTransformer(
}
}
@Suppress("UNCHECKED_CAST")
val resolvedCall = ktPrimitiveCompleter.completeResolvedCall(
candidate, baseResolvedCall.completedDiagnostic(resultSubstitutor),
) as ResolvedCall<D>
@@ -68,7 +68,6 @@ val KotlinCallArgument.psiExpression: KtExpression?
class ParseErrorKotlinCallArgument(
override val valueArgument: ValueArgument,
override val dataFlowInfoAfterThisArgument: DataFlowInfo,
builtIns: KotlinBuiltIns
) : ExpressionKotlinCallArgument, SimplePSIKotlinCallArgument() {
override val receiver = ReceiverValueWithSmartCastInfo(
TransientReceiver(ErrorUtils.createErrorType("Error type for ParseError-argument $valueArgument")),
@@ -606,10 +606,8 @@ fun transformToReceiverWithSmartCastInfo(
)
}
@Deprecated("Temporary error")
internal class PreviousResolutionError(candidateLevel: ResolutionCandidateApplicability) : ResolutionDiagnostic(candidateLevel)
@Deprecated("Temporary error")
internal fun createPreviousResolveError(status: ResolutionStatus): PreviousResolutionError? {
val level = when (status) {
ResolutionStatus.SUCCESS, ResolutionStatus.INCOMPLETE_TYPE_INFERENCE -> return null
@@ -721,7 +721,7 @@ class PSICallResolver(
): PSIKotlinCallArgument {
val builtIns = outerCallContext.scope.ownerDescriptor.builtIns
fun createParseErrorElement() = ParseErrorKotlinCallArgument(valueArgument, startDataFlowInfo, builtIns)
fun createParseErrorElement() = ParseErrorKotlinCallArgument(valueArgument, startDataFlowInfo)
val argumentExpression = valueArgument.getArgumentExpression() ?: return createParseErrorElement()
val ktExpression = KtPsiUtil.deparenthesize(argumentExpression) ?: createParseErrorElement()
@@ -202,6 +202,7 @@ class ResolvedAtomCompleter(
}
private fun completeLambda(lambda: ResolvedLambdaAtom) {
@Suppress("NAME_SHADOWING")
val lambda = lambda.unwrap()
val resultArgumentsInfo = lambda.resultArgumentsInfo!!
val returnType = if (lambda.isCoercedToUnit) {
@@ -849,7 +849,7 @@ private class ConstantExpressionEvaluatorVisitor(
val compileTimeConstant = evaluate(argumentExpression, underlyingType)
val evaluatedArgument = compileTimeConstant?.toConstantValue(underlyingType) ?: return null
val unsignedValue = ConstantValueFactory.createUnsignedValue(evaluatedArgument, classDescriptor.defaultType) ?: return null
val unsignedValue = ConstantValueFactory.createUnsignedValue(evaluatedArgument) ?: return null
return unsignedValue.wrap(compileTimeConstant.parameters)
}
@@ -1168,7 +1168,7 @@ private fun typeStrToCompileTimeType(str: String) = when (str) {
else -> throw IllegalArgumentException("Unsupported type: $str")
}
fun evaluateUnary(name: String, typeStr: String, value: Any, tracer: () -> Unit = {}): Any? {
fun evaluateUnary(name: String, typeStr: String, value: Any): Any? {
return evaluateUnaryAndCheck(name, typeStrToCompileTimeType(typeStr), value)
}
@@ -23,8 +23,8 @@ import java.util.HashMap
/** This file is generated by org.jetbrains.kotlin.generators.evaluate:generate(). DO NOT MODIFY MANUALLY */
internal val emptyBinaryFun: Function2<BigInteger, BigInteger, BigInteger> = { a, b -> BigInteger("0") }
internal val emptyUnaryFun: Function1<Long, Long> = { a -> 1.toLong() }
internal val emptyBinaryFun: Function2<BigInteger, BigInteger, BigInteger> = { _, _ -> BigInteger("0") }
internal val emptyUnaryFun: Function1<Long, Long> = { _ -> 1.toLong() }
internal val unaryOperations: HashMap<UnaryOperationKey<*>, Pair<Function1<Any?, Any>, Function1<Long, Long>>>
= hashMapOf<UnaryOperationKey<*>, Pair<Function1<Any?, Any>, Function1<Long, Long>>>(
@@ -37,7 +37,7 @@ class InlineAnalyzerExtension(
override fun process(descriptor: CallableMemberDescriptor, functionOrProperty: KtCallableDeclaration, trace: BindingTrace) {
checkModalityAndOverrides(descriptor, functionOrProperty, trace)
notSupportedInInlineCheck(descriptor, functionOrProperty, trace)
notSupportedInInlineCheck(functionOrProperty, trace)
if (descriptor is FunctionDescriptor) {
assert(functionOrProperty is KtNamedFunction) {
@@ -61,7 +61,6 @@ class InlineAnalyzerExtension(
}
private fun notSupportedInInlineCheck(
descriptor: CallableMemberDescriptor,
functionOrProperty: KtCallableDeclaration,
trace: BindingTrace
) {
@@ -81,21 +81,6 @@ private fun KotlinTypeRefiner.refineBareType(type: PossiblyBareType): PossiblyBa
return PossiblyBareType.type(newType)
}
@OptIn(TypeRefinement::class)
private fun <T : DoubleColonLHS> KotlinTypeRefiner.refineLHS(lhs: T): T = when (lhs) {
is DoubleColonLHS.Expression -> {
val newType = lhs.typeInfo.type?.let { refineType(it) }
DoubleColonLHS.Expression(
lhs.typeInfo.replaceType(newType),
lhs.isObjectQualifier
) as T
}
is DoubleColonLHS.Type -> {
DoubleColonLHS.Type(refineType(lhs.type), refineBareType(lhs.possiblyBareType)) as T
}
else -> throw IllegalStateException()
}
// Returns true if this expression has the form "A<B>" which means it's a type on the LHS of a double colon expression
internal val KtCallExpression.isWithoutValueArguments: Boolean
get() = valueArgumentList == null && lambdaArguments.isEmpty()
@@ -99,6 +99,7 @@ public class ExpressionTypingUtils {
return fakeExpression;
}
@SuppressWarnings("deprecation")
public static void checkVariableShadowing(
@NotNull LexicalScope scope,
@NotNull BindingTrace trace,
@@ -21,6 +21,7 @@ import org.jetbrains.kotlin.ir.interpreter.state.*
/** This file is generated by org.jetbrains.kotlin.backend.common.interpreter.builtins.GenerateBuiltInsMap.generateMap(). DO NOT MODIFY MANUALLY */
@Suppress("DEPRECATION")
val unaryFunctions = mapOf<CompileTimeFunction, Function1<Any?, Any?>>(
unaryOperation<Boolean>("hashCode", "Boolean") { a -> a.hashCode() },
unaryOperation<Boolean>("not", "Boolean") { a -> a.not() },
@@ -18,7 +18,6 @@ package org.jetbrains.kotlin.asJava.builder
import com.intellij.openapi.diagnostic.Logger
import com.intellij.openapi.progress.ProcessCanceledException
import com.intellij.openapi.project.Project
import com.intellij.openapi.util.SystemInfo
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.psi.impl.compiled.ClsFileImpl
@@ -44,7 +43,7 @@ fun buildLightClass(
val project = files.first().project
try {
val classBuilderFactory = KotlinLightClassBuilderFactory(createJavaFileStub(project, packageFqName, files))
val classBuilderFactory = KotlinLightClassBuilderFactory(createJavaFileStub(packageFqName, files))
val state = GenerationState.Builder(
project,
classBuilderFactory,
@@ -77,7 +76,7 @@ fun buildLightClass(
}
}
private fun createJavaFileStub(project: Project, packageFqName: FqName, files: Collection<KtFile>): PsiJavaFileStub {
private fun createJavaFileStub(packageFqName: FqName, files: Collection<KtFile>): PsiJavaFileStub {
val javaFileStub = PsiJavaFileStubImpl(packageFqName.asString(), /*compiled = */true)
javaFileStub.psiFactory = ClsWrapperStubPsiFactory.INSTANCE
@@ -14,7 +14,6 @@ import com.intellij.openapi.util.TextRange
import com.intellij.openapi.util.registry.Registry
import com.intellij.psi.*
import com.intellij.psi.impl.InheritanceImplUtil
import com.intellij.psi.impl.PsiSubstitutorImpl
import com.intellij.psi.impl.java.stubs.PsiJavaFileStub
import com.intellij.psi.impl.source.PsiImmediateClassType
import com.intellij.psi.impl.source.tree.TreeUtil
@@ -22,7 +21,10 @@ import com.intellij.psi.scope.PsiScopeProcessor
import com.intellij.psi.search.SearchScope
import com.intellij.psi.stubs.IStubElementType
import com.intellij.psi.stubs.StubElement
import com.intellij.psi.util.*
import com.intellij.psi.util.CachedValue
import com.intellij.psi.util.CachedValueProvider
import com.intellij.psi.util.CachedValuesManager
import com.intellij.psi.util.PsiUtilCore
import com.intellij.util.IncorrectOperationException
import org.jetbrains.annotations.NonNls
import org.jetbrains.kotlin.analyzer.KotlinModificationTrackerService
@@ -489,7 +491,7 @@ abstract class KtLightClassForSourceDeclaration(
return PsiSubstitutor.EMPTY
}
val javaLangEnumsTypeParameter = ancestor.typeParameters.firstOrNull() ?: return PsiSubstitutor.EMPTY
return PsiSubstitutorImpl.createSubstitutor(
return PsiSubstitutor.createSubstitutor(
mapOf(
javaLangEnumsTypeParameter to PsiImmediateClassType(this, PsiSubstitutor.EMPTY)
)
@@ -470,8 +470,11 @@ inline fun <T> runReadAction(crossinline runnable: () -> T): T {
return ApplicationManager.getApplication().runReadAction(Computable { runnable() })
}
@Suppress("NOTHING_TO_INLINE")
inline fun KtClassOrObject.safeIsLocal(): Boolean = runReadAction { this.isLocal }
@Suppress("NOTHING_TO_INLINE")
inline fun KtFile.safeIsScript() = runReadAction { this.isScript() }
inline fun KtFile.safeScript() = runReadAction { this.script }
@Suppress("NOTHING_TO_INLINE")
inline fun KtFile.safeScript() = runReadAction { this.script }
@@ -253,6 +253,7 @@ open class KtLightMethodImpl protected constructor(
override fun getBody() = null
@Suppress("DEPRECATION")
override fun findDeepestSuperMethod() = clsDelegate.findDeepestSuperMethod()
override fun findDeepestSuperMethods() = clsDelegate.findDeepestSuperMethods()
@@ -24,7 +24,7 @@ internal class KtLightParameterImpl(
private val clsDelegateProvider: () -> PsiParameter?,
private val index: Int,
method: KtLightMethod
) : LightParameter(dummyDelegate.name ?: "p$index", dummyDelegate.type, method, KotlinLanguage.INSTANCE),
) : LightParameter(dummyDelegate.name, dummyDelegate.type, method, KotlinLanguage.INSTANCE),
KtLightDeclaration<KtParameter, PsiParameter>, KtLightParameter {
private val lazyDelegate by lazyPub { clsDelegateProvider() ?: dummyDelegate }
@@ -33,7 +33,7 @@ internal class KtLightParameterImpl(
override fun getType(): PsiType = lazyDelegate.type
override fun getName(): String = dummyDelegate.name ?: lazyDelegate.name ?: super.getName()
override fun getName(): String = dummyDelegate.name
private val lightModifierList by lazyPub { KtLightSimpleModifierList(this, emptySet()) }
@@ -105,7 +105,6 @@ internal fun PsiAnnotation.tryConvertAsRetention(support: KtUltraLightSupport):
val convertedValue = extractAnnotationFqName("value")
?.let { retentionMapping[it] }
?: null
convertedValue ?: return null
@@ -69,6 +69,7 @@ abstract class KtLightAbstractAnnotation(parent: PsiElement, computeDelegate: La
override fun getOwner() = parent as? PsiAnnotationOwner
@Suppress("DEPRECATION")
override fun getMetaData() = clsDelegate.metaData
override fun getParameterList() = clsDelegate.parameterList
@@ -91,6 +92,7 @@ class KtLightAnnotationForSourceEntry(
override fun getOwner() = parent as? PsiAnnotationOwner
@Suppress("DEPRECATION")
override fun getMetaData() = lazyClsDelegate?.value?.metaData
override fun getQualifiedName() = qualifiedName
@@ -39,6 +39,7 @@ import java.util.List;
import static org.jetbrains.kotlin.KtNodeTypes.BLOCK;
@SuppressWarnings("deprecation")
public class KtBlockExpression extends LazyParseablePsiElement implements KtElement, KtExpression, KtStatementExpression, PsiModifiableCodeBlock {
public KtBlockExpression(@Nullable CharSequence text) {
@@ -34,6 +34,7 @@ import java.util.List;
import static org.jetbrains.kotlin.lexer.KtTokens.VAL_KEYWORD;
import static org.jetbrains.kotlin.lexer.KtTokens.VAR_KEYWORD;
@SuppressWarnings("deprecation")
public class KtDestructuringDeclarationEntry extends KtNamedDeclarationNotStubbed implements KtVariableDeclaration {
public KtDestructuringDeclarationEntry(@NotNull ASTNode node) {
super(node);
@@ -25,6 +25,7 @@ import org.jetbrains.kotlin.KtNodeTypes;
import java.util.Collections;
import java.util.List;
@SuppressWarnings("deprecation")
public abstract class KtFunctionNotStubbed extends KtTypeParameterListOwnerNotStubbed implements KtFunction {
public KtFunctionNotStubbed(@NotNull ASTNode node) {
@@ -43,6 +43,7 @@ open class ContractDescription(
ContractInterpretationDispatcher().convertContractDescriptorToFunctor(this)
}
@Suppress("UNUSED_PARAMETER")
fun getFunctor(usageModule: ModuleDescriptor): Functor? = computeFunctor.invoke()
}
@@ -14,7 +14,6 @@ import org.jetbrains.kotlin.resolve.calls.components.CreateFreshVariablesSubstit
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemOperation
import org.jetbrains.kotlin.resolve.calls.inference.components.FreshVariableNewTypeSubstitutor
import org.jetbrains.kotlin.resolve.calls.inference.model.ArgumentConstraintPosition
import org.jetbrains.kotlin.resolve.calls.inference.model.LowerPriorityToPreserveCompatibility
import org.jetbrains.kotlin.resolve.calls.model.*
import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind
import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind.DISPATCH_RECEIVER
@@ -351,10 +350,11 @@ class CallableReferencesCandidateFactory(
// If we've already mapped an argument to this value parameter, it'll always be a type mismatch.
mappedArguments[valueParameter] = ResolvedCallArgument.SimpleArgument(fakeArgument)
}
VarargMappingState.MAPPED_WITH_PLAIN_ARGS -> {
mappedVarargElements.getOrPut(valueParameter) { ArrayList() }.add(fakeArgument)
}
VarargMappingState.UNMAPPED -> {
}
}
} else {
mappedArgument = substitutedParameter.type
@@ -390,13 +390,13 @@ class CallableReferencesCandidateFactory(
CoercionStrategy.NO_COERCION
val adaptedArguments =
if (expectedType != null && ReflectionTypes.isBaseTypeForNumberedReferenceTypes(expectedType))
if (ReflectionTypes.isBaseTypeForNumberedReferenceTypes(expectedType))
emptyMap()
else
mappedArguments
val suspendConversionStrategy =
if (!descriptor.isSuspend && expectedType?.isSuspendFunctionType == true) {
if (!descriptor.isSuspend && expectedType.isSuspendFunctionType) {
SuspendConversionStrategy.SUSPEND_CONVERSION
} else {
SuspendConversionStrategy.NO_CONVERSION
@@ -21,6 +21,7 @@ import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
import org.jetbrains.kotlin.resolve.calls.components.ClassicTypeSystemContextForCS
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemBuilder
import org.jetbrains.kotlin.resolve.calls.inference.model.NewConstraintSystemImpl
import org.jetbrains.kotlin.resolve.calls.inference.model.SimpleConstraintSystemConstraintPosition
import org.jetbrains.kotlin.resolve.calls.inference.model.TypeVariableFromCallableDescriptor
import org.jetbrains.kotlin.resolve.calls.inference.substitute
import org.jetbrains.kotlin.resolve.calls.results.SimpleConstraintSystem
@@ -60,8 +61,7 @@ class SimpleConstraintSystemImpl(constraintInjector: ConstraintInjector, builtIn
csBuilder.addSubtypeConstraint(
subType,
superType,
@Suppress("DEPRECATION")
org.jetbrains.kotlin.resolve.calls.inference.model.SimpleConstraintSystemConstraintPosition
SimpleConstraintSystemConstraintPosition
)
}
@@ -94,7 +94,7 @@ class CoroutinePosition() : ConstraintPosition() {
override fun toString(): String = "for coroutine call"
}
@Deprecated("Should be used only in SimpleConstraintSystemImpl")
// TODO: should be used only in SimpleConstraintSystemImpl
object SimpleConstraintSystemConstraintPosition : ConstraintPosition()
abstract class ConstraintSystemCallDiagnostic(applicability: ResolutionCandidateApplicability) : KotlinCallDiagnostic(applicability) {
@@ -58,7 +58,7 @@ interface LambdaKotlinCallArgument : PostponableKotlinCallArgument {
*/
var hasBuilderInferenceAnnotation: Boolean
get() = false
set(value) {}
set(@Suppress("UNUSED_PARAMETER") value) {}
/**
* parametersTypes == null means, that there is no declared arguments
@@ -150,7 +150,7 @@ sealed class UnstableSmartCast(
operator fun invoke(
argument: ExpressionKotlinCallArgument,
targetType: UnwrappedType,
isReceiver: Boolean = false, // for reproducing OI behaviour
@Suppress("UNUSED_PARAMETER") isReceiver: Boolean = false, // for reproducing OI behaviour
): UnstableSmartCast {
return UnstableSmartCastResolutionError(argument, targetType)
}
@@ -55,8 +55,7 @@ class TestProxy(val serverPort: Int, val testClass: String, val classPath: List<
}
fun runTestNoOutput(): String {
return Socket("localhost", serverPort).use { clientSocket ->
Socket("localhost", serverPort).use { clientSocket ->
val output = ObjectOutputStream(clientSocket.getOutputStream())
try {
output.writeObject(MessageHeader.NEW_TEST)
+6
View File
@@ -99,6 +99,12 @@ dependencies {
}
}
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinCompile<*>> {
kotlinOptions {
freeCompilerArgs += "-Xinline-classes"
}
}
sourceSets {
"main" { }
"test" { projectDefault() }
@@ -31,14 +31,14 @@ abstract class AbstractCompilerLightClassTest : KotlinMultiFileTestWithJava<Kotl
override fun isKotlinSourceRootNeeded(): Boolean = true
override fun doMultiFileTest(file: File, files: List<TestFile>) {
val environment = createEnvironment(file, files)
val expectedFile = KotlinTestUtils.replaceExtension(file, "java")
val allowFrontendExceptions = InTextDirectivesUtils.isDirectiveDefined(file.readText(), "// ALLOW_FRONTEND_EXCEPTION")
override fun doMultiFileTest(wholeFile: File, files: List<TestFile>) {
val environment = createEnvironment(wholeFile, files)
val expectedFile = KotlinTestUtils.replaceExtension(wholeFile, "java")
val allowFrontendExceptions = InTextDirectivesUtils.isDirectiveDefined(wholeFile.readText(), "// ALLOW_FRONTEND_EXCEPTION")
LightClassTestCommon.testLightClass(
expectedFile,
file,
wholeFile,
{ fqname -> findLightClass(allowFrontendExceptions, environment, fqname) },
LightClassTestCommon::removeEmptyDefaultImpls
)
@@ -27,7 +27,7 @@ abstract class AbstractDiagnosticsTestWithStdLibUsingJavac : AbstractDiagnostics
override fun shouldSkipTest(wholeFile: File, files: List<TestFile>): Boolean {
return isJavacSkipTest(wholeFile, files)
return isJavacSkipTest(wholeFile)
}
override fun setupEnvironment(environment: KotlinCoreEnvironment, testDataFile: File, files: List<TestFile>) {
@@ -19,13 +19,12 @@ package org.jetbrains.kotlin.checkers.javac
import org.jetbrains.kotlin.checkers.AbstractForeignJava8AnnotationsTest
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
import org.jetbrains.kotlin.config.JVMConfigurationKeys
import org.jetbrains.kotlin.test.InTextDirectivesUtils
import java.io.File
abstract class AbstractJavacForeignJava8AnnotationsTest : AbstractForeignJava8AnnotationsTest() {
override fun shouldSkipTest(wholeFile: File, files: List<TestFile>): Boolean {
return isSkipJavacTest(wholeFile, files)
return isSkipJavacTest(wholeFile)
}
override fun setupEnvironment(environment: KotlinCoreEnvironment, testDataFile: File, files: List<TestFile>) {
@@ -660,7 +660,7 @@ abstract class AbstractDiagnosticsTest : BaseDiagnosticsTest() {
val dependencies = ArrayList<ModuleDescriptorImpl>()
dependencies.add(module)
for (dependency in testModule.dependencies) {
dependencies.add(modules[dependency]!!)
dependencies.add(modules[dependency as TestModule?]!!)
}
dependencies.add(module.builtIns.builtInsModule)
@@ -490,7 +490,7 @@ abstract class BaseDiagnosticsTest : KotlinMultiFileTestWithJava<TestModule, Tes
)
}
fun isJavacSkipTest(wholeFile: File, files: List<TestFile>): Boolean {
fun isJavacSkipTest(wholeFile: File): Boolean {
val testDataFileText = wholeFile.readText()
if (isDirectiveDefined(testDataFileText, "// JAVAC_SKIP")) {
return true
@@ -499,7 +499,7 @@ abstract class BaseDiagnosticsTest : KotlinMultiFileTestWithJava<TestModule, Tes
}
//TODO: merge with isJavacSkipTest
fun isSkipJavacTest(wholeFile: File, files: List<TestFile>): Boolean {
fun isSkipJavacTest(wholeFile: File): Boolean {
val testDataFileText = wholeFile.readText()
if (isDirectiveDefined(testDataFileText, "// SKIP_JAVAC")) {
return true
@@ -9,7 +9,6 @@ import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment.Companion.createForTests
import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime
import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.config.JVMConfigurationKeys
import org.jetbrains.kotlin.parsing.KotlinParserDefinition
import org.jetbrains.kotlin.resolve.DescriptorUtils
@@ -131,7 +130,7 @@ abstract class KotlinMultiFileTestWithJava<M : KotlinBaseTest.TestModule, F : Ko
directives: Directives
): F? {
if (fileName.endsWith(".java")) {
writeSourceFile(fileName, text, javaFilesDir!!)
writeSourceFile(fileName, text, javaFilesDir)
}
if ((fileName.endsWith(".kt") || fileName.endsWith(".kts")) && kotlinSourceRoot != null) {
writeSourceFile(fileName, text, kotlinSourceRoot!!)
@@ -147,9 +146,9 @@ abstract class KotlinMultiFileTestWithJava<M : KotlinBaseTest.TestModule, F : Ko
}
private fun writeSourceFile(fileName: String, content: String, targetDir: File) {
val file = File(targetDir, fileName)
KotlinTestUtils.mkdirs(file.parentFile)
file.writeText(content, Charsets.UTF_8)
val tmpFile = File(targetDir, fileName)
KotlinTestUtils.mkdirs(tmpFile.parentFile)
tmpFile.writeText(content, Charsets.UTF_8)
}
}, coroutinesPackage)
}
@@ -26,7 +26,7 @@ import java.io.File
abstract class AbstractDiagnosticsUsingJavacTest : AbstractDiagnosticsTest() {
override fun shouldSkipTest(wholeFile: File, files: List<TestFile>): Boolean {
return isJavacSkipTest(wholeFile, files)
return isJavacSkipTest(wholeFile)
}
override fun setupEnvironment(environment: KotlinCoreEnvironment, testDataFile: File, files: List<TestFile>) {
@@ -57,11 +57,12 @@ public abstract class AbstractBlackBoxCodegenTest extends CodegenTestCase {
}
@Override
@SuppressWarnings("unchecked")
protected void doMultiFileTest(
@NotNull File wholeFile,
@NotNull List<? extends TestFile> files
) throws Exception {
doMultiFileTest(wholeFile, (List<TestFile>)files, false);
doMultiFileTest(wholeFile, (List<TestFile>) files, false);
}
private void doBytecodeListingTest(@NotNull File wholeFile) throws Exception {
@@ -434,7 +434,7 @@ abstract class AbstractCheckLocalVariablesTableTest : CodegenTestCase() {
// conflicting types are represented with a CONFLICT type
// which will never match a read instruction or a type in
// a locals table.
if (!areCompatible(index, it, type)) {
if (!areCompatible(it, type)) {
currentLocals[index] = "CONFLICT"
}
}
@@ -450,11 +450,11 @@ abstract class AbstractCheckLocalVariablesTableTest : CodegenTestCase() {
// We only check that there is no confusion between object types and basic types.
// Therefore, we map all arrays types to type Object when comparing.
private fun checkCompatible(index: Int, type0: String, type1: String) {
if (areCompatible(index, type0, type1)) return
if (areCompatible(type0, type1)) return
throw Exception("Incompatible types for local $index: $type0 and $type1")
}
private fun areCompatible(index: Int, type0: String, type1: String): Boolean {
private fun areCompatible(type0: String, type1: String): Boolean {
val t0 = if (type0.startsWith("[")) "Ljava/lang/Object;" else type0
val t1 = if (type1.startsWith("[")) "Ljava/lang/Object;" else type1
if (t0.equals(t1)) return true
@@ -28,7 +28,6 @@ abstract class AbstractCompileKotlinAgainstInlineKotlinTest : AbstractCompileKot
)
try {
val allGeneratedFiles = factory1.asList() + factory2.asList()
val sourceFiles = factory1.inputFiles + factory2.inputFiles
InlineTestUtil.checkNoCallsToInline(allGeneratedFiles.filterClassFiles(), files)
SMAPTestUtil.checkSMAP(files, allGeneratedFiles.filterClassFiles(), true)
} catch (e: Throwable) {
@@ -49,6 +49,7 @@ public abstract class AbstractCompileKotlinAgainstKotlinTest extends CodegenTest
}
@Override
@SuppressWarnings("unchecked")
protected void doMultiFileTest(@NotNull File wholeFile, @NotNull List<? extends TestFile> files) {
boolean isIgnored = InTextDirectivesUtils.isIgnoredTarget(getBackend(), wholeFile);
doTwoFileTest((List<TestFile>) files, !isIgnored);
@@ -594,13 +594,14 @@ public abstract class CodegenTestCase extends KotlinBaseTest<KotlinBaseTest.Test
boolean parseDirectivesPerFiles,
@NotNull TargetBackend backend
) {
List testFiles = TestFiles.createTestFiles(file.getName(), expectedText, new TestFiles.TestFileFactoryNoModules<TestFile>() {
@NotNull
@Override
public TestFile create(@NotNull String fileName, @NotNull String text, @NotNull Directives directives) {
return new TestFile(fileName, text, directives);
}
}, false, coroutinesPackage, parseDirectivesPerFiles);
List<TestFile> testFiles =
TestFiles.createTestFiles(file.getName(), expectedText, new TestFiles.TestFileFactoryNoModules<TestFile>() {
@NotNull
@Override
public TestFile create(@NotNull String fileName, @NotNull String text, @NotNull Directives directives) {
return new TestFile(fileName, text, directives);
}
}, false, coroutinesPackage, parseDirectivesPerFiles);
if (InTextDirectivesUtils.isDirectiveDefined(expectedText, "WITH_HELPERS")) {
testFiles.add(new TestFile("CodegenTestHelpers.kt", TestHelperGeneratorKt.createTextForCodegenTestHelpers(backend)));
}
@@ -56,7 +56,9 @@ public abstract class AbstractWriteFlagsTest extends CodegenTestCase {
@Override
protected void doMultiFileTest(@NotNull File wholeFile, @NotNull List<? extends TestFile> files) throws Exception {
compile((List<TestFile>)files);
@SuppressWarnings("unchecked")
List<TestFile> testFiles = (List<TestFile>) files;
compile(testFiles);
String fileText = FileUtil.loadFile(wholeFile, true);
@@ -157,7 +157,7 @@ abstract class AbstractFirBaseDiagnosticsTest : BaseDiagnosticsTest() {
val dependencies = ArrayList<ModuleInfo>()
dependencies.add(module)
for (dependency in testModule.dependencies) {
dependencies.add(modules[dependency]!!)
dependencies.add(modules[dependency as TestModule?]!!)
}
@@ -337,9 +337,6 @@ abstract class AbstractFirDiagnosticsTest : AbstractFirBaseDiagnosticsTest() {
for (previousNode in node.previousNodes) {
if (previousNode.owner != graph) continue
if (!node.incomingEdges.getValue(previousNode).isBack) {
if (previousNode !in visited) {
val x = 1
}
assertTrue(previousNode in visited)
}
}
@@ -103,7 +103,7 @@ abstract class AbstractFirDiagnosticsWithLightTreeTest : AbstractFirDiagnosticsT
return groupBy { it }.mapValues { (_, value) -> value.size }
}
private class MissingDiagnostic(val startOffset: Int, val name: String, diff: Int, ktFile: KtFile) {
private class MissingDiagnostic(val startOffset: Int, val name: String, diff: Int, @Suppress("UNUSED_PARAMETER") ktFile: KtFile) {
val kind: Kind = if (diff > 0) Kind.WasExpected else Kind.IsActual
val count: Int = abs(diff)
@@ -221,7 +221,7 @@ class FirResolveBench(val withProgress: Boolean) {
) {
fileCount += firFiles.size
try {
for ((stage, processor) in processors.withIndex()) {
for ((_, processor) in processors.withIndex()) {
//println("Starting stage #$stage. $transformer")
val firFileSequence = if (withProgress) firFiles.progress(" ~ ") else firFiles.asSequence()
runStage(processor, firFileSequence)
@@ -140,6 +140,7 @@ inline class TableTimeUnitConversion(val value: Double) {
infix fun Long.from(from: TableTimeUnit) = TableTimeUnitConversion(this / from.nsMultiplier)
@Suppress("NOTHING_TO_INLINE")
inline fun RTableContext.RTableRowContext.timeCell(
time: Long,
outputUnit: TableTimeUnit = TableTimeUnit.MS,
@@ -185,6 +185,7 @@ abstract class KotlinBaseTest<F : KotlinBaseTest.TestFile> : KtUsefulTestCase()
}
assert(configurationKeyField != null) { "Expected [+|-][namespace.]configurationKey, got: $flag" }
try {
@Suppress("UNCHECKED_CAST")
val configurationKey = configurationKeyField!![null] as CompilerConfigurationKey<Boolean>
configuration.put(configurationKey, flagEnabled)
} catch (e: java.lang.Exception) {
@@ -716,8 +716,7 @@ public class KotlinTestUtils {
runTestImpl(testWithCustomIgnoreDirective(test, TargetBackend.ANY, IGNORE_BACKEND_DIRECTIVE_PREFIX), testCase, testDataFile);
}
public static void runTest(@NotNull TestCase testCase, @NotNull Function0 test) {
//noinspection unchecked
public static void runTest(@NotNull TestCase testCase, @NotNull Function0<Unit> test) {
MuteWithDatabaseKt.runTest(testCase, test);
}
@@ -564,10 +564,10 @@ public abstract class KtUsefulTestCase extends TestCase {
assertOrderedEquals("", actual, expected);
}
@SuppressWarnings("unchecked")
public static <T> void assertOrderedEquals(@NotNull String errorMsg,
@NotNull Iterable<? extends T> actual,
@NotNull Iterable<? extends T> expected) {
//noinspection unchecked
assertOrderedEquals(errorMsg, actual, expected, Equality.CANONICAL);
}
@@ -1008,8 +1008,8 @@ public abstract class KtUsefulTestCase extends TestCase {
* @param exceptionCase Block annotated with some exception type
* @param expectedErrorMsg expected error message
*/
@SuppressWarnings("unchecked")
protected void assertException(@NotNull AbstractExceptionCase exceptionCase, @Nullable String expectedErrorMsg) {
//noinspection unchecked
assertExceptionOccurred(true, exceptionCase, expectedErrorMsg);
}
@@ -441,10 +441,10 @@ public abstract class KtUsefulTestCase extends TestCase {
assertOrderedEquals("", actual, expected);
}
@SuppressWarnings("unchecked")
public static <T> void assertOrderedEquals(@NotNull String errorMsg,
@NotNull Iterable<? extends T> actual,
@NotNull Iterable<? extends T> expected) {
//noinspection unchecked
assertOrderedEquals(errorMsg, actual, expected, Equality.CANONICAL);
}
@@ -851,8 +851,8 @@ public abstract class KtUsefulTestCase extends TestCase {
* @param exceptionCase Block annotated with some exception type
* @param expectedErrorMsg expected error message
*/
@SuppressWarnings("unchecked")
protected void assertException(@NotNull AbstractExceptionCase exceptionCase, @Nullable String expectedErrorMsg) {
//noinspection unchecked
assertExceptionOccurred(true, exceptionCase, expectedErrorMsg);
}
@@ -567,10 +567,10 @@ public abstract class KtUsefulTestCase extends TestCase {
assertOrderedEquals("", actual, expected);
}
@SuppressWarnings("unchecked")
public static <T> void assertOrderedEquals(@NotNull String errorMsg,
@NotNull Iterable<? extends T> actual,
@NotNull Iterable<? extends T> expected) {
//noinspection unchecked
assertOrderedEquals(errorMsg, actual, expected, Equality.CANONICAL);
}
@@ -1011,8 +1011,8 @@ public abstract class KtUsefulTestCase extends TestCase {
* @param exceptionCase Block annotated with some exception type
* @param expectedErrorMsg expected error message
*/
@SuppressWarnings("unchecked")
protected void assertException(@NotNull AbstractExceptionCase exceptionCase, @Nullable String expectedErrorMsg) {
//noinspection unchecked
assertExceptionOccurred(true, exceptionCase, expectedErrorMsg);
}
@@ -556,10 +556,10 @@ public abstract class KtUsefulTestCase extends TestCase {
assertOrderedEquals("", actual, expected);
}
@SuppressWarnings("unchecked")
public static <T> void assertOrderedEquals(@NotNull String errorMsg,
@NotNull Iterable<? extends T> actual,
@NotNull Iterable<? extends T> expected) {
//noinspection unchecked
assertOrderedEquals(errorMsg, actual, expected, Equality.CANONICAL);
}
@@ -1000,8 +1000,8 @@ public abstract class KtUsefulTestCase extends TestCase {
* @param exceptionCase Block annotated with some exception type
* @param expectedErrorMsg expected error message
*/
@SuppressWarnings("unchecked")
protected void assertException(@NotNull AbstractExceptionCase exceptionCase, @Nullable String expectedErrorMsg) {
//noinspection unchecked
assertExceptionOccurred(true, exceptionCase, expectedErrorMsg);
}
@@ -19,8 +19,7 @@ object Annotator {
val levelToOffset = mutableMapOf(0 to 0)
for (ann in annotations) {
var lastLevel = 0
lastLevel = levelToOffset.values.takeWhile { ann.range.startOffset + ann.text.length >= it }.size
val lastLevel = levelToOffset.values.takeWhile { ann.range.startOffset + ann.text.length >= it }.size
if (annotationLines.size <= lastLevel) {
annotationLines.add(StringBuilder(comment + " ".repeat(lineSize - comment.length)))
@@ -106,7 +106,7 @@ class LazyJavaClassDescriptor(
LazyJavaClassMemberScope(c, this, jClass, skipRefinement = additionalSupertypeClassDescriptor != null)
private val scopeHolder =
ScopesHolderForClass.create(this, c.storageManager, c.components.kotlinTypeChecker.kotlinTypeRefiner) { kotlinTypeRefiner ->
ScopesHolderForClass.create(this, c.storageManager, c.components.kotlinTypeChecker.kotlinTypeRefiner) {
LazyJavaClassMemberScope(
c, this, jClass,
skipRefinement = additionalSupertypeClassDescriptor != null,
@@ -48,7 +48,7 @@ object ConstantValueFactory {
}
}
fun createUnsignedValue(constantValue: ConstantValue<*>, type: KotlinType): UnsignedValueConstant<*>? {
fun createUnsignedValue(constantValue: ConstantValue<*>): UnsignedValueConstant<*>? {
return when (constantValue) {
is ByteValue -> UByteValue(constantValue.value)
is ShortValue -> UShortValue(constantValue.value)
@@ -95,7 +95,7 @@ public class LockBasedStorageManager implements StorageManager {
}
public LockBasedStorageManager(String debugText) {
this(debugText, (Runnable)null, (Function1)null);
this(debugText, (Runnable) null, null);
}
public LockBasedStorageManager(
+2 -2
View File
@@ -62,8 +62,8 @@ fun generate(): String {
}
}
p.println("internal val emptyBinaryFun: Function2<BigInteger, BigInteger, BigInteger> = { a, b -> BigInteger(\"0\") }")
p.println("internal val emptyUnaryFun: Function1<Long, Long> = { a -> 1.toLong() }")
p.println("internal val emptyBinaryFun: Function2<BigInteger, BigInteger, BigInteger> = { _, _ -> BigInteger(\"0\") }")
p.println("internal val emptyUnaryFun: Function1<Long, Long> = { _ -> 1.toLong() }")
p.println()
p.println("internal val unaryOperations: HashMap<UnaryOperationKey<*>, Pair<Function1<Any?, Any>, Function1<Long, Long>>>")
p.println(" = hashMapOf<UnaryOperationKey<*>, Pair<Function1<Any?, Any>, Function1<Long, Long>>>(")
@@ -49,7 +49,7 @@ fun generateMap(): String {
val binaryIrOperationsMap = getBinaryIrOperationMap(irBuiltIns)
//save to file
p.println("@Suppress(\"DEPRECATION\")")
p.println("val unaryFunctions = mapOf<CompileTimeFunction, Function1<Any?, Any?>>(")
p.println(generateUnaryBody(unaryOperationsMap, irBuiltIns))
p.println(")")
@@ -101,6 +101,8 @@ class GenerateProtoBufCompare {
val sb = StringBuilder()
val p = Printer(sb)
p.println(File("license/COPYRIGHT.txt").readText())
p.println("@file:Suppress(\"UNUSED_PARAMETER\")")
p.println("")
p.println("package org.jetbrains.kotlin.incremental")
p.println()
@@ -89,8 +89,9 @@ class PartialBodyResolveFilter(
}
fun updateNameFilter() {
val level = statementMarks.statementMark(statement)
when (level) {
when (statementMarks.statementMark(statement)) {
MarkLevel.NONE, MarkLevel.TAKE -> {
}
MarkLevel.NEED_REFERENCE_RESOLVE -> nameFilter.addUsedNames(statement)
MarkLevel.NEED_COMPLETION -> nameFilter.addAllNames()
}
@@ -119,7 +119,7 @@ class BuildSessionLogger(
}
@Synchronized
fun finishBuildSession(action: String?, failure: Throwable?) {
fun finishBuildSession(@Suppress("UNUSED_PARAMETER") action: String?, failure: Throwable?) {
try {
// nanotime could not be used as build start time in nanotime is unknown. As result, the measured duration
// could be affected by system clock correction