File tree Expand file tree Collapse file tree 1 file changed +25
-3
lines changed
java/kotlin-extractor/src/main/kotlin/utils Expand file tree Collapse file tree 1 file changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -7,9 +7,31 @@ import org.jetbrains.kotlin.ir.util.isFileClass
7
7
import org.jetbrains.kotlin.ir.util.parentClassOrNull
8
8
9
9
fun isExternalDeclaration (d : IrDeclaration ): Boolean {
10
- return d.origin == IrDeclarationOrigin .IR_EXTERNAL_DECLARATION_STUB ||
11
- d.origin == IrDeclarationOrigin .IR_EXTERNAL_JAVA_DECLARATION_STUB ||
12
- d.origin.toString() == " FUNCTION_INTERFACE_CLASS" // Treat kotlin.coroutines.* like ordinary library classes
10
+ /*
11
+ With Kotlin 1 we get things like (from .dump()):
12
+ PROPERTY IR_EXTERNAL_JAVA_DECLARATION_STUB name:MIN_VALUE visibility:public modality:FINAL [const,val]
13
+ FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:MIN_VALUE type:kotlin.Int visibility:public [final,static]
14
+ EXPRESSION_BODY
15
+ CONST Int type=kotlin.Int value=-2147483648
16
+ */
17
+ if (d.origin == IrDeclarationOrigin .IR_EXTERNAL_DECLARATION_STUB ||
18
+ d.origin == IrDeclarationOrigin .IR_EXTERNAL_JAVA_DECLARATION_STUB ||
19
+ d.origin.toString() == " FUNCTION_INTERFACE_CLASS" ) { // Treat kotlin.coroutines.* like ordinary library classes
20
+ return true
21
+ }
22
+ /*
23
+ With Kotlin 2, the property itself is not marked as an external stub, but it parent is:
24
+ CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Companion modality:OPEN visibility:public [companion] superTypes:[]
25
+ PROPERTY name:MIN_VALUE visibility:public modality:FINAL [const,val]
26
+ FIELD PROPERTY_BACKING_FIELD name:MIN_VALUE type:kotlin.Int visibility:public [final]
27
+ EXPRESSION_BODY
28
+ CONST Int type=kotlin.Int value=-2147483648
29
+ */
30
+ val p = d.parent
31
+ if (p is IrDeclaration ) {
32
+ return isExternalDeclaration(p)
33
+ }
34
+ return false
13
35
}
14
36
15
37
/* *
You can’t perform that action at this time.
0 commit comments