[kotlin compiler][update] 1.2.0-rc-39
This commit is contained in:
committed by
Vasily Levchenko
parent
e2fc1ddb53
commit
5d514e3ede
+6
-8
@@ -22,10 +22,7 @@ import org.jetbrains.kotlin.container.StorageComponentContainer
|
||||
import org.jetbrains.kotlin.container.useImpl
|
||||
import org.jetbrains.kotlin.container.useInstance
|
||||
import org.jetbrains.kotlin.platform.PlatformToKotlinClassMap
|
||||
import org.jetbrains.kotlin.resolve.IdentifierChecker
|
||||
import org.jetbrains.kotlin.resolve.OverloadFilter
|
||||
import org.jetbrains.kotlin.resolve.OverridesBackwardCompatibilityHelper
|
||||
import org.jetbrains.kotlin.resolve.PlatformConfigurator
|
||||
import org.jetbrains.kotlin.resolve.*
|
||||
import org.jetbrains.kotlin.resolve.calls.results.TypeSpecificityComparator
|
||||
import org.jetbrains.kotlin.resolve.lazy.DelegationFilter
|
||||
import org.jetbrains.kotlin.resolve.scopes.SyntheticScopes
|
||||
@@ -39,11 +36,12 @@ object KonanPlatformConfigurator : PlatformConfigurator(
|
||||
additionalTypeCheckers = listOf(),
|
||||
additionalClassifierUsageCheckers = listOf(),
|
||||
additionalAnnotationCheckers = listOf(),
|
||||
identifierChecker = IdentifierChecker.DEFAULT,
|
||||
overloadFilter = OverloadFilter.DEFAULT,
|
||||
identifierChecker = IdentifierChecker.Default,
|
||||
overloadFilter = OverloadFilter.Default,
|
||||
platformToKotlinClassMap = PlatformToKotlinClassMap.EMPTY,
|
||||
delegationFilter = DelegationFilter.DEFAULT,
|
||||
overridesBackwardCompatibilityHelper = OverridesBackwardCompatibilityHelper.DEFAULT
|
||||
delegationFilter = DelegationFilter.Default,
|
||||
overridesBackwardCompatibilityHelper = OverridesBackwardCompatibilityHelper.Default,
|
||||
declarationReturnTypeSanitizer = DeclarationReturnTypeSanitizer.Default
|
||||
) {
|
||||
override fun configureModuleComponents(container: StorageComponentContainer) {
|
||||
container.useInstance(SyntheticScopes.Empty)
|
||||
|
||||
+91
-23
@@ -31,8 +31,13 @@ import org.jetbrains.kotlin.protobuf.MessageLite
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils.isEnumEntry
|
||||
import org.jetbrains.kotlin.resolve.MemberComparator
|
||||
import org.jetbrains.kotlin.resolve.RequireKotlinNames
|
||||
import org.jetbrains.kotlin.resolve.checkers.KotlinVersionStringAnnotationValueChecker
|
||||
import org.jetbrains.kotlin.resolve.constants.EnumValue
|
||||
import org.jetbrains.kotlin.resolve.constants.IntValue
|
||||
import org.jetbrains.kotlin.resolve.constants.NullValue
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.SinceKotlinInfo
|
||||
import org.jetbrains.kotlin.resolve.constants.StringValue
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.VersionRequirement
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.typeUtil.contains
|
||||
import org.jetbrains.kotlin.utils.Interner
|
||||
@@ -44,7 +49,7 @@ class KonanDescriptorSerializer private constructor(
|
||||
private val typeParameters: Interner<TypeParameterDescriptor>,
|
||||
private val extension: SerializerExtension,
|
||||
private val typeTable: MutableTypeTable,
|
||||
private val sinceKotlinInfoTable: MutableSinceKotlinInfoTable,
|
||||
private val versionRequirementTable: MutableVersionRequirementTable,
|
||||
private val serializeTypeTableToFunction: Boolean
|
||||
) {
|
||||
fun serialize(message: MessageLite): ByteArray {
|
||||
@@ -55,7 +60,7 @@ class KonanDescriptorSerializer private constructor(
|
||||
}
|
||||
|
||||
fun createChildSerializer(descriptor: DeclarationDescriptor): KonanDescriptorSerializer =
|
||||
KonanDescriptorSerializer(descriptor, Interner(typeParameters), extension, typeTable, sinceKotlinInfoTable,
|
||||
KonanDescriptorSerializer(descriptor, Interner(typeParameters), extension, typeTable, versionRequirementTable,
|
||||
serializeTypeTableToFunction = false)
|
||||
|
||||
val stringTable: StringTable
|
||||
@@ -137,9 +142,14 @@ class KonanDescriptorSerializer private constructor(
|
||||
builder.typeTable = typeTableProto
|
||||
}
|
||||
|
||||
val sinceKotlinInfoProto = sinceKotlinInfoTable.serialize()
|
||||
if (sinceKotlinInfoProto != null) {
|
||||
builder.sinceKotlinInfoTable = sinceKotlinInfoProto
|
||||
val requirement = serializeVersionRequirement(classDescriptor)
|
||||
if (requirement != null) {
|
||||
builder.versionRequirement = requirement
|
||||
}
|
||||
|
||||
val versionRequirementTableProto = versionRequirementTable.serialize()
|
||||
if (versionRequirementTableProto != null) {
|
||||
builder.versionRequirementTable = versionRequirementTableProto
|
||||
}
|
||||
|
||||
extension.serializeClass(classDescriptor, builder)
|
||||
@@ -221,10 +231,13 @@ class KonanDescriptorSerializer private constructor(
|
||||
}
|
||||
}
|
||||
|
||||
if (descriptor.isSuspendOrHasSuspendTypesInSignature()) {
|
||||
builder.sinceKotlinInfo = writeSinceKotlinInfo(LanguageFeature.Coroutines)
|
||||
val requirement = serializeVersionRequirement(descriptor)
|
||||
if (requirement != null) {
|
||||
builder.versionRequirement = requirement
|
||||
}
|
||||
else if (descriptor.isSuspendOrHasSuspendTypesInSignature()) {
|
||||
builder.versionRequirement = writeVersionRequirement(LanguageFeature.Coroutines)
|
||||
}
|
||||
|
||||
extension.serializeProperty(descriptor, builder)
|
||||
|
||||
if (extension is IrAwareExtension) {
|
||||
@@ -289,8 +302,12 @@ class KonanDescriptorSerializer private constructor(
|
||||
}
|
||||
}
|
||||
|
||||
if (descriptor.isSuspendOrHasSuspendTypesInSignature()) {
|
||||
builder.sinceKotlinInfo = writeSinceKotlinInfo(LanguageFeature.Coroutines)
|
||||
val requirement = serializeVersionRequirement(descriptor)
|
||||
if (requirement != null) {
|
||||
builder.versionRequirement = requirement
|
||||
}
|
||||
else if (descriptor.isSuspendOrHasSuspendTypesInSignature()) {
|
||||
builder.versionRequirement = writeVersionRequirement(LanguageFeature.Coroutines)
|
||||
}
|
||||
|
||||
extension.serializeFunction(descriptor, builder)
|
||||
@@ -317,8 +334,12 @@ class KonanDescriptorSerializer private constructor(
|
||||
builder.addValueParameter(local.valueParameter(valueParameterDescriptor))
|
||||
}
|
||||
|
||||
if (descriptor.isSuspendOrHasSuspendTypesInSignature()) {
|
||||
builder.sinceKotlinInfo = writeSinceKotlinInfo(LanguageFeature.Coroutines)
|
||||
val requirement = serializeVersionRequirement(descriptor)
|
||||
if (requirement != null) {
|
||||
builder.versionRequirement = requirement
|
||||
}
|
||||
else if (descriptor.isSuspendOrHasSuspendTypesInSignature()) {
|
||||
builder.versionRequirement = writeVersionRequirement(LanguageFeature.Coroutines)
|
||||
}
|
||||
|
||||
extension.serializeConstructor(descriptor, builder)
|
||||
@@ -583,9 +604,9 @@ class KonanDescriptorSerializer private constructor(
|
||||
builder.typeTable = typeTableProto
|
||||
}
|
||||
|
||||
val sinceKotlinInfoProto = sinceKotlinInfoTable.serialize()
|
||||
if (sinceKotlinInfoProto != null) {
|
||||
builder.sinceKotlinInfoTable = sinceKotlinInfoProto
|
||||
val versionRequirementTableProto = versionRequirementTable.serialize()
|
||||
if (versionRequirementTableProto != null) {
|
||||
builder.versionRequirementTable = versionRequirementTableProto
|
||||
}
|
||||
|
||||
extension.serializePackage(packageFqName, builder)
|
||||
@@ -593,15 +614,62 @@ class KonanDescriptorSerializer private constructor(
|
||||
return builder
|
||||
}
|
||||
|
||||
private fun writeSinceKotlinInfo(languageFeature: LanguageFeature): Int {
|
||||
private fun writeVersionRequirement(languageFeature: LanguageFeature): Int {
|
||||
val languageVersion = languageFeature.sinceVersion!!
|
||||
val sinceKotlinInfo = ProtoBuf.SinceKotlinInfo.newBuilder().apply {
|
||||
SinceKotlinInfo.Version(languageVersion.major, languageVersion.minor).encode(
|
||||
val requirement = ProtoBuf.VersionRequirement.newBuilder().apply {
|
||||
VersionRequirement.Version(languageVersion.major, languageVersion.minor).encode(
|
||||
writeVersion = { version = it },
|
||||
writeVersionFull = { versionFull = it }
|
||||
)
|
||||
}
|
||||
return sinceKotlinInfoTable[sinceKotlinInfo]
|
||||
return versionRequirementTable[requirement]
|
||||
}
|
||||
|
||||
// Returns index into versionRequirementTable, or null if there's no @RequireKotlin on the descriptor
|
||||
private fun serializeVersionRequirement(descriptor: DeclarationDescriptor): Int? {
|
||||
val annotation = descriptor.annotations.findAnnotation(RequireKotlinNames.FQ_NAME) ?: return null
|
||||
val args = annotation.allValueArguments
|
||||
|
||||
val versionString = (args[RequireKotlinNames.VERSION] as? StringValue)?.value ?: return null
|
||||
val matchResult = KotlinVersionStringAnnotationValueChecker.VERSION_REGEX.matchEntire(versionString) ?: return null
|
||||
|
||||
val major = matchResult.groupValues.getOrNull(1)?.toIntOrNull() ?: return null
|
||||
val minor = matchResult.groupValues.getOrNull(2)?.toIntOrNull() ?: 0
|
||||
val patch = matchResult.groupValues.getOrNull(4)?.toIntOrNull() ?: 0
|
||||
|
||||
val proto = ProtoBuf.VersionRequirement.newBuilder()
|
||||
VersionRequirement.Version(major, minor, patch).encode(
|
||||
writeVersion = { proto.version = it },
|
||||
writeVersionFull = { proto.versionFull = it }
|
||||
)
|
||||
|
||||
val message = (args[RequireKotlinNames.MESSAGE] as? StringValue)?.value
|
||||
if (message != null) {
|
||||
proto.message = stringTable.getStringIndex(message)
|
||||
}
|
||||
|
||||
val level = (args[RequireKotlinNames.LEVEL] as? EnumValue)?.value?.name?.asString()
|
||||
when (level) {
|
||||
DeprecationLevel.ERROR.toString() -> { /* ERROR is the default level */ }
|
||||
DeprecationLevel.WARNING.toString() -> proto.level = ProtoBuf.VersionRequirement.Level.WARNING
|
||||
DeprecationLevel.HIDDEN.toString() -> proto.level = ProtoBuf.VersionRequirement.Level.HIDDEN
|
||||
}
|
||||
|
||||
val versionKind = (args[RequireKotlinNames.VERSION_KIND] as? EnumValue)?.value?.name?.asString()
|
||||
when (versionKind) {
|
||||
ProtoBuf.VersionRequirement.VersionKind.LANGUAGE_VERSION.toString() -> { /* LANGUAGE_VERSION is the default kind */ }
|
||||
ProtoBuf.VersionRequirement.VersionKind.COMPILER_VERSION.toString() ->
|
||||
proto.versionKind = ProtoBuf.VersionRequirement.VersionKind.COMPILER_VERSION
|
||||
ProtoBuf.VersionRequirement.VersionKind.API_VERSION.toString() ->
|
||||
proto.versionKind = ProtoBuf.VersionRequirement.VersionKind.API_VERSION
|
||||
}
|
||||
|
||||
val errorCode = (args[RequireKotlinNames.ERROR_CODE] as? IntValue)?.value
|
||||
if (errorCode != null && errorCode != -1) {
|
||||
proto.errorCode = errorCode
|
||||
}
|
||||
|
||||
return versionRequirementTable[proto]
|
||||
}
|
||||
|
||||
private fun getClassifierId(descriptor: ClassifierDescriptorWithTypeParameters): Int =
|
||||
@@ -616,13 +684,13 @@ class KonanDescriptorSerializer private constructor(
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun createTopLevel(extension: SerializerExtension): KonanDescriptorSerializer {
|
||||
return KonanDescriptorSerializer(null, Interner(), extension, MutableTypeTable(), MutableSinceKotlinInfoTable(),
|
||||
return KonanDescriptorSerializer(null, Interner(), extension, MutableTypeTable(), MutableVersionRequirementTable(),
|
||||
serializeTypeTableToFunction = false)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun createForLambda(extension: SerializerExtension): KonanDescriptorSerializer {
|
||||
return KonanDescriptorSerializer(null, Interner(), extension, MutableTypeTable(), MutableSinceKotlinInfoTable(),
|
||||
return KonanDescriptorSerializer(null, Interner(), extension, MutableTypeTable(), MutableVersionRequirementTable(),
|
||||
serializeTypeTableToFunction = true)
|
||||
}
|
||||
|
||||
@@ -642,7 +710,7 @@ class KonanDescriptorSerializer private constructor(
|
||||
Interner(parentSerializer.typeParameters),
|
||||
parentSerializer.extension,
|
||||
MutableTypeTable(),
|
||||
MutableSinceKotlinInfoTable(),
|
||||
MutableVersionRequirementTable(),
|
||||
serializeTypeTableToFunction = false
|
||||
)
|
||||
for (typeParameter in descriptor.declaredTypeParameters) {
|
||||
|
||||
+1
-1
@@ -105,7 +105,7 @@ fun createKonanPackageFragmentProvider(
|
||||
LocalClassifierTypeSettings.Default,
|
||||
ErrorReporter.DO_NOTHING,
|
||||
LookupTracker.DO_NOTHING, NullFlexibleTypeDeserializer,
|
||||
emptyList(), notFoundClasses)
|
||||
emptyList(), notFoundClasses, ContractDeserializer.DEFAULT)
|
||||
|
||||
for (packageFragment in packageFragments) {
|
||||
packageFragment.components = components
|
||||
|
||||
+6
-7
@@ -16,6 +16,9 @@
|
||||
|
||||
package org.jetbrains.kotlin.backend.konan.serialization
|
||||
|
||||
import org.jetbrains.kotlin.backend.common.peek
|
||||
import org.jetbrains.kotlin.backend.common.pop
|
||||
import org.jetbrains.kotlin.backend.common.push
|
||||
import org.jetbrains.kotlin.backend.konan.descriptors.allContainingDeclarations
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.impl.LocalVariableDescriptor
|
||||
@@ -23,14 +26,10 @@ import org.jetbrains.kotlin.serialization.Flags
|
||||
import org.jetbrains.kotlin.serialization.KonanIr
|
||||
import org.jetbrains.kotlin.serialization.KonanLinkData
|
||||
import org.jetbrains.kotlin.serialization.ProtoBuf
|
||||
import org.jetbrains.kotlin.serialization.ProtoBuf.QualifiedNameTable.QualifiedName
|
||||
import org.jetbrains.kotlin.serialization.deserialization.*
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.*
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.SinceKotlinInfoTable
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedClassDescriptor
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.VersionRequirementTable
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.backend.common.peek
|
||||
import org.jetbrains.kotlin.backend.common.push
|
||||
import org.jetbrains.kotlin.backend.common.pop
|
||||
|
||||
// This class knows how to construct contexts for
|
||||
// MemberDeserializer to deserialize descriptors declared in IR.
|
||||
@@ -75,7 +74,7 @@ class LocalDeclarationDeserializer(val rootDescriptor: DeclarationDescriptor) {
|
||||
if (descriptor is KonanPackageFragment) {
|
||||
val packageTypeTable = TypeTable(pkg.proto.getPackage().typeTable)
|
||||
return components.createContext(
|
||||
pkg, nameResolver, packageTypeTable, SinceKotlinInfoTable.EMPTY, null)
|
||||
pkg, nameResolver, packageTypeTable, VersionRequirementTable.EMPTY, null)
|
||||
}
|
||||
|
||||
// Only packages and classes have their type tables.
|
||||
|
||||
Vendored
+1
-1
@@ -65,7 +65,7 @@ bintray {
|
||||
def (groupId, artifactId, version) = gradle.startParameter.projectProperties.module.tokenize(':')
|
||||
def groupPath = groupId.replace('.', '/')
|
||||
def artifactPath = artifactId
|
||||
def versionPath = "${version.tokenize('-')[0]}-SNAPSHOT"
|
||||
def versionPath = "$version" //TODO: snapshots?
|
||||
from project.files(gradle.startParameter.projectProperties.jar)
|
||||
from project.files(gradle.startParameter.projectProperties.src)
|
||||
from project.files(gradle.startParameter.projectProperties.doc)
|
||||
|
||||
+6
-6
@@ -23,14 +23,14 @@ testDataVersion=1067176:id
|
||||
kotlinCompilerRepo=https://dl.bintray.com/jetbrains/kotlin-native-dependencies
|
||||
#kotlinCompilerRepo=http://oss.sonatype.org/content/repositories/snapshots
|
||||
#kotlinCompilerRepo=http://dl.bintray.com/kotlin/kotlin-dev
|
||||
kotlinVersion=1.1-20171004.235336-906
|
||||
kotlinScriptRuntimeVersion=1.1-20171004.235353-597
|
||||
kotlinStdLibVersion=1.1-20171004.235357-905
|
||||
kotlinReflectVersion=1.1-20171004.235348-905
|
||||
kotlinVersion=1.2.0-rc-39
|
||||
kotlinScriptRuntimeVersion=1.2.0-rc-39
|
||||
kotlinStdLibVersion=1.2.0-rc-39
|
||||
kotlinReflectVersion=1.2.0-rc-39
|
||||
konanVersion=0.4
|
||||
org.gradle.jvmargs='-Dfile.encoding=UTF-8'
|
||||
|
||||
##
|
||||
# required for performance mesuarement tasks
|
||||
kotlinStdLibJdk8Version=1.1-20171004.235402-815
|
||||
kotlinGradlePluginVersion=1.1-20171004.235345-884
|
||||
kotlinStdLibJdk8Version=1.2.0-rc-39
|
||||
kotlinGradlePluginVersion=1.2.0-rc-39
|
||||
|
||||
@@ -39,25 +39,6 @@ apply plugin: 'com.jfrog.bintray'
|
||||
group = 'org.jetbrains.kotlin'
|
||||
version = konanVersion
|
||||
|
||||
// TODO: move this code to top level (the same for backend.native)
|
||||
// Copied from backend.native
|
||||
allprojects {
|
||||
repositories {
|
||||
maven { url kotlinCompilerRepo }
|
||||
}
|
||||
|
||||
configurations.all {
|
||||
// kotlin-compiler module includes Kotlin runtime bundled;
|
||||
// make Gradle aware of this to avoid multiple Kotlin runtimes in classpath:
|
||||
resolutionStrategy.dependencySubstitution {
|
||||
substitute module('org.jetbrains.kotlin:kotlin-runtime') with module(kotlinCompilerModule)
|
||||
substitute module('org.jetbrains.kotlin:kotlin-stdlib') with module(kotlinStdLibModule)
|
||||
substitute module('org.jetbrains.kotlin:kotlin-reflect') with module(kotlinReflectModule)
|
||||
}
|
||||
// TODO: probably we should use kotlin-compiler without bundled runtime
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user