Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 482a37c

Browse files
tamasvajkigfoo
authored andcommitted
Fix unbound symbol.owner references and add todos
1 parent 41c3676 commit 482a37c

2 files changed

Lines changed: 41 additions & 2 deletions

File tree

java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,10 @@ open class KotlinFileExtractor(
655655
when(b) {
656656
is IrBlockBody -> extractBlockBody(b, callable)
657657
is IrSyntheticBody -> extractSyntheticBody(b, callable)
658+
is IrExpressionBody -> {
659+
// TODO
660+
logger.warnElement(Severity.ErrorSevere, "Unhandled IrExpressionBody", b)
661+
}
658662
else -> {
659663
logger.warnElement(Severity.ErrorSevere, "Unrecognised IrBody: " + b.javaClass, b)
660664
}
@@ -734,6 +738,10 @@ open class KotlinFileExtractor(
734738
logger.warnElement(Severity.ErrorSevere, "Expected to find local function", s)
735739
}
736740
}
741+
is IrLocalDelegatedProperty -> {
742+
// TODO:
743+
logger.warnElement(Severity.ErrorSevere, "Unhandled IrLocalDelegatedProperty", s)
744+
}
737745
else -> {
738746
logger.warnElement(Severity.ErrorSevere, "Unrecognised IrStatement: " + s.javaClass, s)
739747
}
@@ -1732,6 +1740,9 @@ open class KotlinFileExtractor(
17321740
tw.writeHasLocation(id, locId)
17331741
tw.writeCallableEnclosingExpr(id, callable)
17341742
tw.writeStatementEnclosingExpr(id, exprParent.enclosingStmt)
1743+
if (!e.symbol.isBound) {
1744+
return
1745+
}
17351746
val owner = e.symbol.owner
17361747
val vId = useEnumEntry(owner)
17371748
tw.writeVariableBinding(id, vId)
@@ -1835,10 +1846,14 @@ open class KotlinFileExtractor(
18351846
// automatically-generated `public static final MyObject INSTANCE`
18361847
// field that we are accessing here.
18371848
val exprParent = parent.expr(e, callable)
1849+
if (!e.symbol.isBound) {
1850+
return
1851+
}
1852+
18381853
val c: IrClass = e.symbol.owner
18391854
val instance = if (c.isCompanion) useCompanionObjectClassInstance(c) else useObjectClassInstance(c)
18401855

1841-
if(instance != null) {
1856+
if (instance != null) {
18421857
val id = tw.getFreshIdLabel<DbVaraccess>()
18431858
val type = useType(e.type)
18441859
val locId = tw.getLocation(e)
@@ -1925,6 +1940,10 @@ open class KotlinFileExtractor(
19251940

19261941
extractTypeAccess(e.classType, locId, callable, id, 0, exprParent.enclosingStmt)
19271942
}
1943+
is IrPropertyReference -> {
1944+
// TODO
1945+
logger.warnElement(Severity.ErrorSevere, "Unhandled IrPropertyReference", e)
1946+
}
19281947
else -> {
19291948
logger.warnElement(Severity.ErrorSevere, "Unrecognised IrExpression: " + e.javaClass, e)
19301949
}
@@ -1942,6 +1961,14 @@ open class KotlinFileExtractor(
19421961
return
19431962
}
19441963

1964+
if (declarationStack.size == 0) {
1965+
// TODO: fix this
1966+
logger.warnElement(Severity.ErrorSevere, "Expected to find current declaration", functionReferenceExpr)
1967+
return
1968+
}
1969+
1970+
val currentDeclaration = declarationStack.peek()
1971+
19451972
/*
19461973
* Extract generated class:
19471974
* ```
@@ -2004,7 +2031,6 @@ open class KotlinFileExtractor(
20042031
tw.getFreshIdLabel()
20052032
)
20062033

2007-
val currentDeclaration = declarationStack.peek()
20082034
val id = extractGeneratedClass(ids, listOf(pluginContext.irBuiltIns.anyType, fnInterfaceType), locId, currentDeclaration)
20092035

20102036
fun writeExpressionMetadataToTrapFile(id: Label<out DbExpr>, callable: Label<out DbCallable>, stmt: Label<out DbStmt>) {
@@ -2361,6 +2387,10 @@ open class KotlinFileExtractor(
23612387
is IrExpression -> {
23622388
extractExpressionExpr(e, callable, parent, idx, enclosingStmt)
23632389
}
2390+
is IrSpreadElement -> {
2391+
// TODO:
2392+
logger.warnElement(Severity.ErrorSevere, "Unhandled IrSpreadElement", e)
2393+
}
23642394
else -> {
23652395
logger.warnElement(Severity.ErrorSevere, "Unrecognised IrVarargElement: " + e.javaClass, e)
23662396
}
@@ -2475,6 +2505,10 @@ open class KotlinFileExtractor(
24752505
extractExpressionExpr(e.argument, callable, id, 0, enclosingStmt)
24762506
extractTypeAccess(e.typeOperand, callable, id, 1, e, enclosingStmt)
24772507
}
2508+
IrTypeOperator.SAM_CONVERSION -> {
2509+
// TODO:
2510+
logger.warnElement(Severity.ErrorSevere, "Unhandled IrTypeOperatorCall for SAM_CONVERSION: " + e.render(), e)
2511+
}
24782512
else -> {
24792513
logger.warnElement(Severity.ErrorSevere, "Unrecognised IrTypeOperatorCall for ${e.operator}: " + e.render(), e)
24802514
}

java/kotlin-extractor/src/main/kotlin/KotlinUsesExtractor.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,11 @@ class X {
581581
}
582582
is IrClass -> if (classTypeArguments != null && !dp.isAnonymousObject) useClassInstance(dp, classTypeArguments, inReceiverContext).typeResult.id else useClassSource(dp)
583583
is IrFunction -> useFunction(dp)
584+
is IrExternalPackageFragment -> {
585+
// TODO
586+
logger.warn(Severity.ErrorSevere, "Unhandled IrExternalPackageFragment")
587+
fakeLabel()
588+
}
584589
else -> {
585590
logger.warn(Severity.ErrorSevere, "Unrecognised IrDeclarationParent: " + dp.javaClass)
586591
fakeLabel()

0 commit comments

Comments
 (0)