K2: Refine how JDK members are mapped to built-in classes

Previously, the semantic was more-or-less correct for most of the cases
but some corner one, like `sort` in MutableList didn't work properly.

Namely, `sort` should be marked there in a way to forbid to call it
everywhere beside super-calls.
Also, overriding it should be allowed.

Mostly, the logic was re-written to K2 model from K1-related
JvmBuiltInsCustomizer.

^KT-57694 In progress
^KT-57269 Fixed
This commit is contained in:
Denis.Zharkov
2023-04-13 11:50:54 +02:00
committed by Space Team
parent 161fe1d2ca
commit 2e5b783cc6
59 changed files with 1225 additions and 595 deletions
@@ -24,22 +24,22 @@ operator fun set(index: kotlin.Int, element: E): E
fun subList(fromIndex: kotlin.Int, toIndex: kotlin.Int): kotlin.collections.MutableList<E>
val size: kotlin.Int
fun isEmpty(): kotlin.Boolean
operator fun contains(element: E): kotlin.Boolean
operator fun iterator(): kotlin.collections.MutableIterator<E>
fun containsAll(elements: kotlin.collections.Collection<E>): kotlin.Boolean
operator fun get(index: kotlin.Int): E
fun indexOf(element: E): kotlin.Int
fun isEmpty(): kotlin.Boolean
operator fun iterator(): kotlin.collections.MutableIterator<E>
fun lastIndexOf(element: E): kotlin.Int
val size: kotlin.Int
open operator fun equals(other: kotlin.Any?): kotlin.Boolean
open fun hashCode(): kotlin.Int
@@ -855,6 +855,105 @@ KtFunctionSymbol:
getContainingModule: KtBinaryModule "Builtins for JVM (1.8)"
deprecationStatus: null
KtKotlinPropertySymbol:
annotationsList: []
backingFieldSymbol: KtBackingFieldSymbol:
annotationsList: []
callableIdIfNonLocal: null
contextReceivers: []
isExtension: false
name: field
origin: PROPERTY_BACKING_FIELD
owningProperty: KtKotlinPropertySymbol(kotlin/collections/List.size)
receiverParameter: null
returnType: KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: kotlin/Int
symbolKind: LOCAL
typeParameters: []
getContainingModule: KtBinaryModule "Builtins for JVM (1.8)"
deprecationStatus: null
callableIdIfNonLocal: kotlin/collections/List.size
contextReceivers: []
getter: null
hasBackingField: false
hasGetter: false
hasSetter: false
initializer: null
isConst: false
isDelegatedProperty: false
isExtension: false
isFromPrimaryConstructor: false
isLateInit: false
isOverride: false
isStatic: false
isVal: true
modality: ABSTRACT
name: size
origin: LIBRARY
receiverParameter: null
returnType: KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: kotlin/Int
setter: null
symbolKind: CLASS_MEMBER
typeParameters: []
visibility: Public
getDispatchReceiver(): KtUsualClassType:
annotationsList: []
ownTypeArguments: [
KtTypeParameterType:
annotationsList: []
type: E
]
type: kotlin/collections/List<E>
getContainingModule: KtBinaryModule "Builtins for JVM (1.8)"
deprecationStatus: null
getterDeprecationStatus: null
javaGetterName: getSize
javaSetterName: null
setterDeprecationStatus: null
KtFunctionSymbol:
annotationsList: []
callableIdIfNonLocal: kotlin/collections/List.isEmpty
contextReceivers: []
contractEffects: []
hasStableParameterNames: true
isBuiltinFunctionInvoke: false
isExtension: false
isExternal: false
isInfix: false
isInline: false
isOperator: false
isOverride: false
isStatic: false
isSuspend: false
modality: ABSTRACT
name: isEmpty
origin: LIBRARY
receiverParameter: null
returnType: KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: kotlin/Boolean
symbolKind: CLASS_MEMBER
typeParameters: []
valueParameters: []
visibility: Public
getDispatchReceiver(): KtUsualClassType:
annotationsList: []
ownTypeArguments: [
KtTypeParameterType:
annotationsList: []
type: E
]
type: kotlin/collections/List<E>
getContainingModule: KtBinaryModule "Builtins for JVM (1.8)"
deprecationStatus: null
KtFunctionSymbol:
annotationsList: []
callableIdIfNonLocal: kotlin/collections/MutableList.contains
@@ -915,6 +1014,48 @@ KtFunctionSymbol:
getContainingModule: KtBinaryModule "Builtins for JVM (1.8)"
deprecationStatus: null
KtFunctionSymbol:
annotationsList: []
callableIdIfNonLocal: kotlin/collections/MutableList.iterator
contextReceivers: []
contractEffects: []
hasStableParameterNames: true
isBuiltinFunctionInvoke: false
isExtension: false
isExternal: false
isInfix: false
isInline: false
isOperator: true
isOverride: false
isStatic: false
isSuspend: false
modality: ABSTRACT
name: iterator
origin: INTERSECTION_OVERRIDE
receiverParameter: null
returnType: KtUsualClassType:
annotationsList: []
ownTypeArguments: [
KtTypeParameterType:
annotationsList: []
type: E
]
type: kotlin/collections/MutableIterator<E>
symbolKind: CLASS_MEMBER
typeParameters: []
valueParameters: []
visibility: Public
getDispatchReceiver(): KtUsualClassType:
annotationsList: []
ownTypeArguments: [
KtTypeParameterType:
annotationsList: []
type: E
]
type: kotlin/collections/MutableList<E>
getContainingModule: KtBinaryModule "Builtins for JVM (1.8)"
deprecationStatus: null
KtFunctionSymbol:
annotationsList: []
callableIdIfNonLocal: kotlin/collections/MutableList.containsAll
@@ -1100,86 +1241,6 @@ KtFunctionSymbol:
getContainingModule: KtBinaryModule "Builtins for JVM (1.8)"
deprecationStatus: null
KtFunctionSymbol:
annotationsList: []
callableIdIfNonLocal: kotlin/collections/List.isEmpty
contextReceivers: []
contractEffects: []
hasStableParameterNames: true
isBuiltinFunctionInvoke: false
isExtension: false
isExternal: false
isInfix: false
isInline: false
isOperator: false
isOverride: false
isStatic: false
isSuspend: false
modality: ABSTRACT
name: isEmpty
origin: LIBRARY
receiverParameter: null
returnType: KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: kotlin/Boolean
symbolKind: CLASS_MEMBER
typeParameters: []
valueParameters: []
visibility: Public
getDispatchReceiver(): KtUsualClassType:
annotationsList: []
ownTypeArguments: [
KtTypeParameterType:
annotationsList: []
type: E
]
type: kotlin/collections/List<E>
getContainingModule: KtBinaryModule "Builtins for JVM (1.8)"
deprecationStatus: null
KtFunctionSymbol:
annotationsList: []
callableIdIfNonLocal: kotlin/collections/MutableList.iterator
contextReceivers: []
contractEffects: []
hasStableParameterNames: true
isBuiltinFunctionInvoke: false
isExtension: false
isExternal: false
isInfix: false
isInline: false
isOperator: true
isOverride: false
isStatic: false
isSuspend: false
modality: ABSTRACT
name: iterator
origin: INTERSECTION_OVERRIDE
receiverParameter: null
returnType: KtUsualClassType:
annotationsList: []
ownTypeArguments: [
KtTypeParameterType:
annotationsList: []
type: E
]
type: kotlin/collections/MutableIterator<E>
symbolKind: CLASS_MEMBER
typeParameters: []
valueParameters: []
visibility: Public
getDispatchReceiver(): KtUsualClassType:
annotationsList: []
ownTypeArguments: [
KtTypeParameterType:
annotationsList: []
type: E
]
type: kotlin/collections/MutableList<E>
getContainingModule: KtBinaryModule "Builtins for JVM (1.8)"
deprecationStatus: null
KtFunctionSymbol:
annotationsList: []
callableIdIfNonLocal: kotlin/collections/MutableList.lastIndexOf
@@ -1240,67 +1301,6 @@ KtFunctionSymbol:
getContainingModule: KtBinaryModule "Builtins for JVM (1.8)"
deprecationStatus: null
KtKotlinPropertySymbol:
annotationsList: []
backingFieldSymbol: KtBackingFieldSymbol:
annotationsList: []
callableIdIfNonLocal: null
contextReceivers: []
isExtension: false
name: field
origin: PROPERTY_BACKING_FIELD
owningProperty: KtKotlinPropertySymbol(kotlin/collections/List.size)
receiverParameter: null
returnType: KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: kotlin/Int
symbolKind: LOCAL
typeParameters: []
getContainingModule: KtBinaryModule "Builtins for JVM (1.8)"
deprecationStatus: null
callableIdIfNonLocal: kotlin/collections/List.size
contextReceivers: []
getter: null
hasBackingField: false
hasGetter: false
hasSetter: false
initializer: null
isConst: false
isDelegatedProperty: false
isExtension: false
isFromPrimaryConstructor: false
isLateInit: false
isOverride: false
isStatic: false
isVal: true
modality: ABSTRACT
name: size
origin: LIBRARY
receiverParameter: null
returnType: KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: kotlin/Int
setter: null
symbolKind: CLASS_MEMBER
typeParameters: []
visibility: Public
getDispatchReceiver(): KtUsualClassType:
annotationsList: []
ownTypeArguments: [
KtTypeParameterType:
annotationsList: []
type: E
]
type: kotlin/collections/List<E>
getContainingModule: KtBinaryModule "Builtins for JVM (1.8)"
deprecationStatus: null
getterDeprecationStatus: null
javaGetterName: getSize
javaSetterName: null
setterDeprecationStatus: null
KtFunctionSymbol:
annotationsList: []
callableIdIfNonLocal: kotlin/Any.equals
@@ -13,4 +13,8 @@ open fun toString(): kotlin.String
@kotlin.internal.IntrinsicConstEvaluation
val name: kotlin.String
val ordinal: kotlin.Int
val ordinal: kotlin.Int
fun getDeclaringClass(): (java.lang.Class<test.E!>..java.lang.Class<test.E!>?)
fun finalize()
@@ -436,4 +436,75 @@ KtKotlinPropertySymbol:
getterDeprecationStatus: null
javaGetterName: getOrdinal
javaSetterName: null
setterDeprecationStatus: null
setterDeprecationStatus: null
KtFunctionSymbol:
annotationsList: []
callableIdIfNonLocal: test/E.getDeclaringClass
contextReceivers: []
contractEffects: []
hasStableParameterNames: false
isBuiltinFunctionInvoke: false
isExtension: false
isExternal: false
isInfix: false
isInline: false
isOperator: false
isOverride: false
isStatic: false
isSuspend: false
modality: FINAL
name: getDeclaringClass
origin: SUBSTITUTION_OVERRIDE
receiverParameter: null
returnType: KtFlexibleType:
annotationsList: []
type: ft<java/lang/Class<test/E!>, java/lang/Class<test/E!>?>
symbolKind: CLASS_MEMBER
typeParameters: []
valueParameters: []
visibility: Public
getDispatchReceiver(): KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: test/E
getContainingModule: KtSourceModule "Sources of main"
deprecationStatus: null
KtFunctionSymbol:
annotationsList: []
callableIdIfNonLocal: kotlin/Enum.finalize
contextReceivers: []
contractEffects: []
hasStableParameterNames: false
isBuiltinFunctionInvoke: false
isExtension: false
isExternal: false
isInfix: false
isInline: false
isOperator: false
isOverride: false
isStatic: false
isSuspend: false
modality: FINAL
name: finalize
origin: JAVA
receiverParameter: null
returnType: KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: kotlin/Unit
symbolKind: CLASS_MEMBER
typeParameters: []
valueParameters: []
visibility: ProtectedAndPackage
getDispatchReceiver(): KtUsualClassType:
annotationsList: []
ownTypeArguments: [
KtTypeParameterType:
annotationsList: []
type: E
]
type: kotlin/Enum<E>
getContainingModule: KtBinaryModule "Builtins for JVM (1.8)"
deprecationStatus: null
@@ -14,7 +14,7 @@ scopes:
SimpleTypeScope, index = 2
classifiers: 1
companion object
callables: 9
callables: 11
val x: kotlin.String
fun foo()
fun clone(): kotlin.Any
@@ -24,6 +24,8 @@ scopes:
fun toString(): kotlin.String
val name: kotlin.String
val ordinal: kotlin.Int
fun getDeclaringClass(): java.lang.Class<E?>?
fun finalize()
StaticMemberScope, index = 3
classifiers: 0
@@ -42,7 +42,7 @@ scopes:
symbolKind: CLASS_MEMBER
typeParameters: []
visibility: Public
callables: 9
callables: 11
KtKotlinPropertySymbol:
annotationsList: []
backingFieldSymbol: KtBackingFieldSymbol:
@@ -402,6 +402,59 @@ scopes:
symbolKind: CLASS_MEMBER
typeParameters: []
visibility: Public
KtFunctionSymbol:
annotationsList: []
callableIdIfNonLocal: /E.getDeclaringClass
contextReceivers: []
contractEffects: []
hasStableParameterNames: false
isBuiltinFunctionInvoke: false
isExtension: false
isExternal: false
isInfix: false
isInline: false
isOperator: false
isOverride: false
isStatic: false
isSuspend: false
modality: FINAL
name: getDeclaringClass
origin: SUBSTITUTION_OVERRIDE
receiverParameter: null
returnType: KtFlexibleType:
annotationsList: []
type: ft<java/lang/Class<E!>, java/lang/Class<E!>?>
symbolKind: CLASS_MEMBER
typeParameters: []
valueParameters: []
visibility: Public
KtFunctionSymbol:
annotationsList: []
callableIdIfNonLocal: kotlin/Enum.finalize
contextReceivers: []
contractEffects: []
hasStableParameterNames: false
isBuiltinFunctionInvoke: false
isExtension: false
isExternal: false
isInfix: false
isInline: false
isOperator: false
isOverride: false
isStatic: false
isSuspend: false
modality: FINAL
name: finalize
origin: JAVA
receiverParameter: null
returnType: KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: kotlin/Unit
symbolKind: CLASS_MEMBER
typeParameters: []
valueParameters: []
visibility: ProtectedAndPackage
StaticMemberScope, index = 3
classifiers: 0