Eliminated some warnings.

This commit is contained in:
Alexander Gorshenev
2017-08-04 14:28:07 +03:00
committed by alexander-gorshenev
parent 9eb2bb7fbc
commit a0e15a7776
9 changed files with 28 additions and 41 deletions
@@ -69,7 +69,7 @@ class KonanConfig(val project: Project, val configuration: CompilerConfiguration
return fromCommandLine + "stdlib"
}
private val repositories = configuration.getList(KonanConfigKeys.REPOSITORIES) ?: emptyList()
private val repositories = configuration.getList(KonanConfigKeys.REPOSITORIES)
private val resolver = KonanLibrarySearchPathResolver(repositories, distribution.klib, distribution.localKonanDir)
private val librariesFound: List<File> by lazy {
val resolvedLibraries = libraryNames.map{it -> resolver.resolve(it)}
@@ -118,7 +118,7 @@ internal open class LinuxBasedPlatform(distribution: Distribution)
: PlatformFlags(distribution.targetProperties) {
private val llvmLib = distribution.llvmLib
private val libGcc = "$targetSysRoot/${propertyTargetString("libGcc")!!}"
private val libGcc = "$targetSysRoot/${propertyTargetString("libGcc")}"
private val linker = "$targetToolchain/bin/ld.gold"
private val pluginOptimizationFlags = propertyTargetList("pluginOptimizationFlags")
private val specificLibs
@@ -201,8 +201,6 @@ internal class LinkStage(val context: Context) {
MingwPlatform(distribution)
KonanTarget.WASM32 ->
WasmPlatform(distribution)
else ->
error("Unexpected target platform: ${target}")
}
private val optimize = config.get(KonanConfigKeys.OPTIMIZATION) ?: false
@@ -294,9 +292,6 @@ internal class LinkStage(val context: Context) {
private val entryPointSelector: List<String>
get() = if (nomain) emptyList() else platform.entrySelector
private val libffi
get() = platform.targetLibffi ?.let { listOf(it) } ?: emptyList()
private fun link(objectFiles: List<ObjectFile>, libraryProvidedLinkerFlags: List<String>): ExecutableFile {
val executable = context.config.outputFile
@@ -23,10 +23,7 @@ import org.jetbrains.kotlin.konan.file.File
internal class MetadataWriterImpl(library: KonanLibrary): KonanLibrary by library {
fun addLinkData(linkData: LinkData) {
val linkdataDir = File(libDir, "linkdata")
moduleHeaderFile.writeBytes(linkData.module)
linkData.fragments.forEachIndexed { index, it ->
val name = linkData.fragmentNames[index]
packageFile(name).writeBytes(it)
@@ -53,7 +53,7 @@ internal class LocalDeclarationSerializer(val context: Context, val rootFunction
contextStack.push(newSerializer)
}
fun popContext(descriptor: DeclarationDescriptor) {
fun popContext() {
contextStack.pop()
}
@@ -68,9 +68,6 @@ internal class LocalDeclarationSerializer(val context: Context, val rootFunction
context.log{"### serializeLocalDeclaration: $descriptor"}
val parent = descriptor.classOrPackage
when (descriptor) {
is ClassConstructorDescriptor ->
proto.setConstructor(localSerializer.constructorProto(descriptor))
@@ -533,10 +533,10 @@ internal class IrSerializer(val context: Context,
fun serializeIrField(field: IrField): KonanIr.IrProperty.IrField {
val proto = KonanIr.IrProperty.IrField.newBuilder()
val field = field.initializer?.expression
if (field != null) {
val initializer = field.initializer?.expression
if (initializer != null) {
proto.setInitializer(
serializeExpression(field))
serializeExpression(initializer))
}
return proto.build()
}
@@ -550,7 +550,7 @@ internal class IrSerializer(val context: Context,
return proto.build()
}
fun serializeIrClass(clazz: IrClass): KonanIr.IrClass {
fun serializeIrClass(@Suppress("UNUSED_PARAMETER") clazz: IrClass): KonanIr.IrClass {
val proto = KonanIr.IrClass.newBuilder()
// TODO: As of now we get here only for anonymous local objects.
@@ -615,7 +615,7 @@ internal class IrSerializer(val context: Context,
}
if (!(declaration is IrVariable)) {
localDeclarationSerializer.popContext(descriptor)
localDeclarationSerializer.popContext()
}
if (descriptor != rootFunction) {
@@ -804,7 +804,7 @@ internal class IrDeserializer(val context: Context,
return callable
}
fun deserializeDelegatingConstructorCall(proto: KonanIr.IrDelegatingConstructorCall, start: Int, end: Int, type: KotlinType): IrDelegatingConstructorCall {
fun deserializeDelegatingConstructorCall(proto: KonanIr.IrDelegatingConstructorCall, start: Int, end: Int): IrDelegatingConstructorCall {
val descriptor = deserializeDescriptor(proto.getDescriptor()) as ClassConstructorDescriptor
val typeArgs = deserializeTypeMap(descriptor, proto.memberAccess.getTypeMap())
@@ -814,14 +814,14 @@ internal class IrDeserializer(val context: Context,
return call
}
fun deserializeEnumConstructorCall(proto: KonanIr.IrEnumConstructorCall, start: Int, end: Int, type: KotlinType): IrEnumConstructorCall {
fun deserializeEnumConstructorCall(proto: KonanIr.IrEnumConstructorCall, start: Int, end: Int): IrEnumConstructorCall {
val descriptor = deserializeDescriptor(proto.getDescriptor()) as ClassConstructorDescriptor
val call = IrEnumConstructorCallImpl(start, end, descriptor)
deserializeMemberAccessCommon(call, proto.memberAccess)
return call
}
fun deserializeGetField(proto: KonanIr.IrGetField, start: Int, end: Int, type: KotlinType): IrGetField {
fun deserializeGetField(proto: KonanIr.IrGetField, start: Int, end: Int): IrGetField {
val access = proto.fieldAccess
val descriptor = deserializeDescriptor(access.getDescriptor()) as PropertyDescriptor
val superQualifier = if (access.hasSuper()) {
@@ -834,14 +834,14 @@ internal class IrDeserializer(val context: Context,
return IrGetFieldImpl(start, end, descriptor, receiver, null, superQualifier)
}
fun deserializeGetValue(proto: KonanIr.IrGetValue, start: Int, end: Int, type: KotlinType): IrGetValue {
fun deserializeGetValue(proto: KonanIr.IrGetValue, start: Int, end: Int): IrGetValue {
val descriptor = deserializeDescriptor(proto.descriptor) as ValueDescriptor
// TODO: origin!
return IrGetValueImpl(start, end, descriptor, null)
}
fun deserializeGetEnumValue(proto: KonanIr.IrGetEnumValue, start: Int, end: Int, type: KotlinType): IrGetEnumValue {
fun deserializeGetEnumValue(proto: KonanIr.IrGetEnumValue, start: Int, end: Int): IrGetEnumValue {
val type = deserializeKotlinType(proto.type)
val descriptor = deserializeDescriptor(proto.descriptor) as ClassDescriptor
@@ -853,7 +853,7 @@ internal class IrDeserializer(val context: Context,
return IrGetObjectValueImpl(start, end, type, descriptor)
}
fun deserializeInstanceInitializerCall(proto: KonanIr.IrInstanceInitializerCall, start: Int, end: Int, type: KotlinType): IrInstanceInitializerCall {
fun deserializeInstanceInitializerCall(proto: KonanIr.IrInstanceInitializerCall, start: Int, end: Int): IrInstanceInitializerCall {
val descriptor = deserializeDescriptor(proto.getDescriptor()) as ClassDescriptor
return IrInstanceInitializerCallImpl(start, end, descriptor)
@@ -866,7 +866,7 @@ internal class IrDeserializer(val context: Context,
return IrReturnImpl(start, end, type, descriptor, value)
}
fun deserializeSetField(proto: KonanIr.IrSetField, start: Int, end: Int, type: KotlinType): IrSetField {
fun deserializeSetField(proto: KonanIr.IrSetField, start: Int, end: Int): IrSetField {
val access = proto.fieldAccess
val descriptor = deserializeDescriptor(access.getDescriptor()) as PropertyDescriptor
val superQualifier = if (access.hasSuper()) {
@@ -880,7 +880,7 @@ internal class IrDeserializer(val context: Context,
return IrSetFieldImpl(start, end, descriptor, receiver, value, null, superQualifier)
}
fun deserializeSetVariable(proto: KonanIr.IrSetVariable, start: Int, end: Int, type: KotlinType): IrSetVariable {
fun deserializeSetVariable(proto: KonanIr.IrSetVariable, start: Int, end: Int): IrSetVariable {
val descriptor = deserializeDescriptor(proto.getDescriptor()) as VariableDescriptor
val value = deserializeExpression(proto.getValue())
return IrSetVariableImpl(start, end, descriptor, value, null)
@@ -1033,23 +1033,23 @@ internal class IrDeserializer(val context: Context,
CONTINUE
-> deserializeContinue(proto.getContinue(), start, end, type)
DELEGATING_CONSTRUCTOR_CALL
-> deserializeDelegatingConstructorCall(proto.delegatingConstructorCall, start, end, type)
-> deserializeDelegatingConstructorCall(proto.delegatingConstructorCall, start, end)
GET_ENUM_VALUE
-> deserializeGetEnumValue(proto.getEnumValue, start, end, type)
-> deserializeGetEnumValue(proto.getEnumValue, start, end)
GET_FIELD
-> deserializeGetField(proto.getField, start, end, type)
-> deserializeGetField(proto.getField, start, end)
GET_OBJECT
-> deserializeGetObject(proto.getObject, start, end, type)
GET_VALUE
-> deserializeGetValue(proto.getValue, start, end, type)
-> deserializeGetValue(proto.getValue, start, end)
INSTANCE_INITIALIZER_CALL
-> deserializeInstanceInitializerCall(proto.instanceInitializerCall, start, end, type)
-> deserializeInstanceInitializerCall(proto.instanceInitializerCall, start, end)
RETURN
-> deserializeReturn(proto.getReturn(), start, end, type)
SET_FIELD
-> deserializeSetField(proto.setField, start, end, type)
-> deserializeSetField(proto.setField, start, end)
SET_VARIABLE
-> deserializeSetVariable(proto.setVariable, start, end, type)
-> deserializeSetVariable(proto.setVariable, start, end)
STRING_CONCAT
-> deserializeStringConcat(proto.stringConcat, start, end, type)
THROW
@@ -34,7 +34,7 @@ internal fun NameResolverImpl.getDescriptorByFqNameIndex(
// TODO: Here we are using internals of NameresolverImpl.
// Consider extending NameResolver.
val proto = nameTable.getQualifiedName(fqNameIndex)
when (proto.kind) {
when (proto.kind!!) {
QualifiedName.Kind.CLASS,
QualifiedName.Kind.LOCAL ->
return module.findClassAcrossModuleDependencies(this.getClassId(fqNameIndex))!!
@@ -68,7 +68,7 @@ class PackageFragmentPrinter(val packageFragment: KonanLinkData.PackageFragment,
val protoClasses = packageFragment.classes.classesList // ProtoBuf classes
protoClasses.forEach { protoClass ->
val classKind = Flags.CLASS_KIND.get(protoClass.flags)
val classKind = Flags.CLASS_KIND.get(protoClass.flags)!!
when (classKind) {
ProtoBuf.Class.Kind.CLASS -> printClass(protoClass)
ProtoBuf.Class.Kind.ENUM_CLASS -> printEnum(protoClass)
@@ -566,7 +566,7 @@ class PackageFragmentPrinter(val packageFragment: KonanLinkData.PackageFragment,
fun classOrInterface(protoClass: ProtoBuf.Class): String {
val flags = protoClass.flags
val classKind = Flags.CLASS_KIND.get(flags)
val classKind = Flags.CLASS_KIND.get(flags)!!
val modality = modalityToString(Flags.MODALITY.get(flags))
val visibility = visibilityToString(Flags.VISIBILITY.get(flags))
@@ -84,7 +84,6 @@ class Library(val name: String, val requestedRepository: String?, val target: St
fun info() {
val library = libraryInRepoOrCurrentDir(repository, name)
val reader = LibraryReaderImpl(library, currentAbiVersion)
val header = reader.manifestProperties
val headerAbiVersion = reader.abiVersion
val moduleName = ModuleDeserializer(reader.moduleHeaderData).moduleName
@@ -58,7 +58,7 @@ class File constructor(internal val javaPath: Path) {
return result
}
fun copyTo(destination: File, vararg options: StandardCopyOption) {
fun copyTo(destination: File) {
Files.copy(javaPath, destination.javaPath, StandardCopyOption.REPLACE_EXISTING)
}
@@ -147,8 +147,7 @@ private val File.zipUri: URI
fun File.zipFileSystem(mutable: Boolean = false): FileSystem {
val zipUri = this.zipUri
val allowCreation = if (mutable) "true" else "false"
val attributes = hashMapOf("create" to if (mutable) "true" else "false")
val attributes = hashMapOf("create" to mutable.toString())
return FileSystems.newFileSystem(zipUri, attributes, null)
}