@@ -21,8 +21,6 @@ import org.jetbrains.kotlin.builtins.CloneableClassScope
21
21
import org.jetbrains.kotlin.builtins.JvmBuiltInClassDescriptorFactory
22
22
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
23
23
import org.jetbrains.kotlin.descriptors.*
24
- import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptorImpl
25
- import org.jetbrains.kotlin.descriptors.annotations.Annotations
26
24
import org.jetbrains.kotlin.descriptors.annotations.AnnotationsImpl
27
25
import org.jetbrains.kotlin.descriptors.annotations.createDeprecatedAnnotation
28
26
import org.jetbrains.kotlin.descriptors.impl.ClassDescriptorImpl
@@ -36,7 +34,6 @@ import org.jetbrains.kotlin.name.Name
36
34
import org.jetbrains.kotlin.platform.JavaToKotlinClassMap
37
35
import org.jetbrains.kotlin.platform.createMappedTypeParametersSubstitution
38
36
import org.jetbrains.kotlin.resolve.OverridingUtil
39
- import org.jetbrains.kotlin.resolve.descriptorUtil.LOW_PRIORITY_IN_OVERLOAD_RESOLUTION_FQ_NAME
40
37
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
41
38
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameUnsafe
42
39
import org.jetbrains.kotlin.resolve.jvm.JvmPrimitiveType
@@ -53,7 +50,6 @@ import org.jetbrains.kotlin.types.LazyWrappedType
53
50
import org.jetbrains.kotlin.utils.DFS
54
51
import org.jetbrains.kotlin.utils.SmartSet
55
52
import org.jetbrains.kotlin.utils.addToStdlib.check
56
- import org.jetbrains.kotlin.utils.addToStdlib.singletonList
57
53
import java.io.Serializable
58
54
import java.util.*
59
55
@@ -82,22 +78,6 @@ open class JvmBuiltInsSettings(
82
78
).let { AnnotationsImpl (listOf (it)) }
83
79
}
84
80
85
- private val lowPriorityAnnotation: Annotations by storageManager.createLazyValue {
86
- // We use both LowPriorityInOverloadResolution to achieve the following goal:
87
- // If there is something to resolve to beside an additional built-in member, it's *almost* always will win
88
- val lowPriorityAnnotation =
89
- ClassDescriptorImpl (
90
- moduleDescriptor.getPackage(LOW_PRIORITY_IN_OVERLOAD_RESOLUTION_FQ_NAME .parent()), LOW_PRIORITY_IN_OVERLOAD_RESOLUTION_FQ_NAME .shortName(),
91
- Modality .FINAL , ClassKind .ANNOTATION_CLASS , moduleDescriptor.builtIns.anyType.singletonList(),
92
- SourceElement .NO_SOURCE , /* isExternal = */ false
93
- ).run {
94
- initialize(MemberScope .Empty , emptySet(), null )
95
- AnnotationDescriptorImpl (defaultType, emptyMap(), SourceElement .NO_SOURCE )
96
- }
97
-
98
- AnnotationsImpl (listOf (lowPriorityAnnotation))
99
- }
100
-
101
81
private fun StorageManager.createMockJavaIoSerializableType (): KotlinType {
102
82
val mockJavaIoPackageFragment = object : PackageFragmentDescriptorImpl (moduleDescriptor, FqName (" java.io" )) {
103
83
override fun getMemberScope () = MemberScope .Empty
@@ -131,6 +111,8 @@ open class JvmBuiltInsSettings(
131
111
))
132
112
}
133
113
114
+ if (! isAdditionalBuiltInsFeatureSupported) return emptyList()
115
+
134
116
return getAdditionalFunctions(classDescriptor) {
135
117
it.getContributedFunctions(name, NoLookupLocation .FROM_BUILTINS )
136
118
}.mapNotNull {
@@ -156,31 +138,24 @@ open class JvmBuiltInsSettings(
156
138
}
157
139
158
140
JDKMemberStatus .NOT_CONSIDERED -> {
159
- if (! isAdditionalBuiltInsFeatureSupported) {
160
- setAdditionalAnnotations(lowPriorityAnnotation)
161
- }
162
- else {
163
- setAdditionalAnnotations(notConsideredDeprecation)
164
- }
141
+ setAdditionalAnnotations(notConsideredDeprecation)
165
142
}
166
143
167
144
JDKMemberStatus .DROP -> return @mapNotNull null
168
145
169
- JDKMemberStatus .WHITE_LIST -> {
170
- if (! isAdditionalBuiltInsFeatureSupported) {
171
- setAdditionalAnnotations(lowPriorityAnnotation)
172
- }
173
- }
146
+ JDKMemberStatus .WHITE_LIST -> Unit // Do nothing
174
147
}
175
148
176
149
}.build()!!
177
150
}
178
151
}
179
152
180
- override fun getFunctionsNames (classDescriptor : DeserializedClassDescriptor ): Set <Name > =
181
- // NB: It's just an approximation that could be calculated relatively fast
182
- // More precise computation would look like `getAdditionalFunctions` (and the measurements show that it would be rather slow)
183
- classDescriptor.getJavaAnalogue()?.unsubstitutedMemberScope?.getFunctionNames() ? : emptySet()
153
+ override fun getFunctionsNames (classDescriptor : DeserializedClassDescriptor ): Set <Name > {
154
+ if (! isAdditionalBuiltInsFeatureSupported) return emptySet()
155
+ // NB: It's just an approximation that could be calculated relatively fast
156
+ // More precise computation would look like `getAdditionalFunctions` (and the measurements show that it would be rather slow)
157
+ return classDescriptor.getJavaAnalogue()?.unsubstitutedMemberScope?.getFunctionNames() ? : emptySet()
158
+ }
184
159
185
160
private fun getAdditionalFunctions (
186
161
classDescriptor : DeserializedClassDescriptor ,
@@ -287,7 +262,7 @@ open class JvmBuiltInsSettings(
287
262
}
288
263
289
264
override fun getConstructors (classDescriptor : DeserializedClassDescriptor ): Collection <ClassConstructorDescriptor > {
290
- if (classDescriptor.kind != ClassKind .CLASS ) return emptyList()
265
+ if (classDescriptor.kind != ClassKind .CLASS || ! isAdditionalBuiltInsFeatureSupported ) return emptyList()
291
266
292
267
val javaAnalogueDescriptor = classDescriptor.getJavaAnalogue() ? : return emptyList()
293
268
@@ -314,11 +289,7 @@ open class JvmBuiltInsSettings(
314
289
setReturnType(classDescriptor.defaultType)
315
290
setPreserveSourceElement()
316
291
setSubstitution(substitutor.substitution)
317
-
318
- if (! isAdditionalBuiltInsFeatureSupported) {
319
- setAdditionalAnnotations(lowPriorityAnnotation)
320
- }
321
- else if (SignatureBuildingComponents .signature(javaAnalogueDescriptor, javaConstructor.computeJvmDescriptor()) !in WHITE_LIST_CONSTRUCTOR_SIGNATURES ) {
292
+ if (SignatureBuildingComponents .signature(javaAnalogueDescriptor, javaConstructor.computeJvmDescriptor()) !in WHITE_LIST_CONSTRUCTOR_SIGNATURES ) {
322
293
setAdditionalAnnotations(notConsideredDeprecation)
323
294
}
324
295
0 commit comments