Add MutableMap.remove(K, V) as built-in declaration
Use PlatformDependent annotation to guarantee it's only be available for JDK8 Also adjust type-safe bridges and mutable collection stubs generation
This commit is contained in:
+37
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.serialization.deserialization
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedClassDescriptor
|
||||
|
||||
interface PlatformDependentDeclarationFilter {
|
||||
|
||||
fun isFunctionAvailable(classDescriptor: DeserializedClassDescriptor, functionDescriptor: SimpleFunctionDescriptor): Boolean
|
||||
|
||||
object All : PlatformDependentDeclarationFilter {
|
||||
override fun isFunctionAvailable(classDescriptor: DeserializedClassDescriptor, functionDescriptor: SimpleFunctionDescriptor) = true
|
||||
}
|
||||
|
||||
object NoPlatformDependent : PlatformDependentDeclarationFilter {
|
||||
override fun isFunctionAvailable(classDescriptor: DeserializedClassDescriptor, functionDescriptor: SimpleFunctionDescriptor) =
|
||||
!functionDescriptor.annotations.hasAnnotation(PLATFORM_DEPENDENT_ANNOTATION_FQ_NAME)
|
||||
}
|
||||
}
|
||||
|
||||
val PLATFORM_DEPENDENT_ANNOTATION_FQ_NAME = FqName("kotlin.internal.PlatformDependent")
|
||||
+2
-1
@@ -39,7 +39,8 @@ class DeserializationComponents(
|
||||
val fictitiousClassDescriptorFactory: ClassDescriptorFactory,
|
||||
val notFoundClasses: NotFoundClasses,
|
||||
val typeCapabilitiesLoader: TypeCapabilitiesLoader = TypeCapabilitiesLoader.NONE,
|
||||
val additionalClassPartsProvider: AdditionalClassPartsProvider = AdditionalClassPartsProvider.None
|
||||
val additionalClassPartsProvider: AdditionalClassPartsProvider = AdditionalClassPartsProvider.None,
|
||||
val platformDependentDeclarationFilter: PlatformDependentDeclarationFilter = PlatformDependentDeclarationFilter.All
|
||||
) {
|
||||
val classDeserializer: ClassDeserializer = ClassDeserializer(this)
|
||||
|
||||
|
||||
+4
@@ -201,6 +201,10 @@ class DeserializedClassDescriptor(
|
||||
fromSupertypes.addAll(supertype.memberScope.getContributedFunctions(name, NoLookupLocation.FOR_ALREADY_TRACKED))
|
||||
}
|
||||
|
||||
functions.retainAll {
|
||||
c.components.platformDependentDeclarationFilter.isFunctionAvailable(this@DeserializedClassDescriptor, it)
|
||||
}
|
||||
|
||||
functions.addAll(c.components.additionalClassPartsProvider.getFunctions(name, this@DeserializedClassDescriptor))
|
||||
generateFakeOverrides(name, fromSupertypes, functions)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user