From 3ec9735350781633dbb79f942630a63b86e6aa97 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 29 Nov 2023 13:58:15 -0500 Subject: [PATCH] fix bugs --- .../specimin/TargetMethodFinderVisitor.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/checkerframework/specimin/TargetMethodFinderVisitor.java b/src/main/java/org/checkerframework/specimin/TargetMethodFinderVisitor.java index 22ee8231..318db888 100644 --- a/src/main/java/org/checkerframework/specimin/TargetMethodFinderVisitor.java +++ b/src/main/java/org/checkerframework/specimin/TargetMethodFinderVisitor.java @@ -269,8 +269,11 @@ public Visitable visit(MethodCallExpr call, Void p) { if (call.getScope().isPresent()) { // the scope of a method will always be a NameExpr, while that NameExpr might be a field, // variable, or a class. - NameExpr expression = call.getScope().get().asNameExpr(); - updateUsedElementWithPotentialFieldNameExpr(expression); + Expression scope = call.getScope().get(); + if (scope instanceof NameExpr) { + NameExpr expression = call.getScope().get().asNameExpr(); + updateUsedElementWithPotentialFieldNameExpr(expression); + } } } return super.visit(call, p); @@ -351,7 +354,13 @@ private void resolveUnionType(UnionType type) { * @param expr a field access expression inside target methods */ public void updateUsedElementWithPotentialFieldNameExpr(NameExpr expr) { - ResolvedValueDeclaration exprDecl = expr.resolve(); + ResolvedValueDeclaration exprDecl; + try { + exprDecl = expr.resolve(); + } catch (UnsolvedSymbolException e) { + // if expr is the name of a class in a static call, we can't resolve its value. + return; + } if (exprDecl instanceof ResolvedFieldDeclaration) { // while the name of the method is declaringType(), it actually returns the class where the // field is declared