Skip to content

Commit

Permalink
Fix bug in pattern resolving
Browse files Browse the repository at this point in the history
  • Loading branch information
sxhya committed Sep 8, 2023
1 parent 099a95f commit 052cdb0
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.jetbrains.annotations.Nullable;

import java.util.*;
import java.util.function.Supplier;

public class ExpressionResolveNameVisitor extends BaseConcreteExpressionVisitor<Void> implements ExpressionResolver, ConcreteLevelExpressionVisitor<LevelVariable, Concrete.LevelExpression> {
private final ReferableConverter myReferableConverter;
Expand Down Expand Up @@ -643,7 +644,17 @@ private Concrete.Pattern visitPattern(Concrete.Pattern pattern, Map<String, Refe

if (namePattern.type == null || referable instanceof LongUnresolvedReference) {
List<Referable> resolvedRefs = new ArrayList<>();
Referable resolved = referable instanceof LongUnresolvedReference ? ((LongUnresolvedReference) referable).resolve(myParentScope, resolvedRefs) : referable instanceof UnresolvedReference ? ((UnresolvedReference) referable).tryResolve(myParentScope, resolvedRefs) : myParentScope.resolveName(referable.getRefName());

Supplier<Referable> c = () -> {
Referable r = myParentScope.resolveName(referable.getRefName());
resolvedRefs.add(r);
return r;
};

Referable resolved = referable instanceof LongUnresolvedReference ? ((LongUnresolvedReference) referable).resolve(myParentScope, resolvedRefs) :
referable instanceof UnresolvedReference ? ((UnresolvedReference) referable).tryResolve(myParentScope, resolvedRefs) :
c.get();

Referable ref = resolved == null || resolved instanceof ErrorReference ? resolved : myReferableConverter.convert(RedirectingReferable.getOriginalReferable(resolved));
if (ref instanceof GlobalReferable && ((GlobalReferable) ref).getKind().isConstructor()) {
if (pattern.getAsReferable() != null) {
Expand Down

0 comments on commit 052cdb0

Please sign in to comment.