Skip to content

Commit

Permalink
Workaround to be compatible with old behaviour in some cases
Browse files Browse the repository at this point in the history
  • Loading branch information
oxisto committed Apr 11, 2024
1 parent df15b8f commit b6087c6
Showing 1 changed file with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import de.fraunhofer.aisec.cpg.graph.*
import de.fraunhofer.aisec.cpg.graph.declarations.*
import de.fraunhofer.aisec.cpg.graph.scopes.NameScope
import de.fraunhofer.aisec.cpg.graph.scopes.Scope
import de.fraunhofer.aisec.cpg.graph.scopes.RecordScope
import de.fraunhofer.aisec.cpg.graph.scopes.StructureDeclarationScope
import de.fraunhofer.aisec.cpg.graph.statements.expressions.*
import de.fraunhofer.aisec.cpg.graph.types.*
Expand Down Expand Up @@ -459,15 +460,27 @@ open class SymbolResolver(ctx: TranslationContext) : ComponentPass(ctx) {
// This is a little bit of a workaround, but at least this makes sure we are not inferring a
// record, where a namespace already exist
val (scope, _) = scopeManager.extractScope(reference)
if (scope == null) {
return if (scope == null) {
handleUnknownField(containingClass, reference)
} else {
log.warn(
"We should infer a namespace variable ${reference.name} at this point, but this is not yet implemented."
)
// Workaround needed for Java. If we already have a record scope, use the "old"
// inference function
when (scope) {
is RecordScope -> handleUnknownField(containingClass, reference)
is NameScope -> {
log.warn(
"We should infer a namespace variable ${reference.name} at this point, but this is not yet implemented."
)
null
}
else -> {
log.warn(
"We should infer a variable ${reference.name} in ${scope}, but this is not yet implemented."
)
null
}
}
}

return null
}

// TODO(oxisto): Move to inference class
Expand Down

0 comments on commit b6087c6

Please sign in to comment.