• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pmd / pmd / 318

21 Dec 2025 06:01PM UTC coverage: 78.966% (-0.009%) from 78.975%
318

push

github

adangel
[java] Fix #6237: UnnecessaryCast error with switch expr returning lambdas (#6295)

18514 of 24322 branches covered (76.12%)

Branch coverage included in aggregate %.

72 of 82 new or added lines in 7 files covered. (87.8%)

5 existing lines in 2 files now uncovered.

40308 of 50168 relevant lines covered (80.35%)

0.81 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

57.14
/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/ast/internal/InvocCtx.java
1
/*
2
 * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3
 */
4

5
package net.sourceforge.pmd.lang.java.types.ast.internal;
6

7
import static net.sourceforge.pmd.lang.java.types.ast.ExprContext.ExprContextKind.INVOCATION;
8

9
import org.checkerframework.checker.nullness.qual.Nullable;
10

11
import net.sourceforge.pmd.lang.java.ast.InvocationNode;
12
import net.sourceforge.pmd.lang.java.symbols.JExecutableSymbol;
13
import net.sourceforge.pmd.lang.java.types.JMethodSig;
14
import net.sourceforge.pmd.lang.java.types.JTypeMirror;
15
import net.sourceforge.pmd.lang.java.types.OverloadSelectionResult;
16
import net.sourceforge.pmd.lang.java.types.ast.ExprContext;
17

18
public final class InvocCtx extends ExprContext {
19

20
    private final int arg;
21
    private final InvocationNode node;
22

23
    public InvocCtx(int arg, InvocationNode node) {
24
        super(INVOCATION);
1✔
25
        this.arg = arg;
1✔
26
        this.node = node;
1✔
27
    }
1✔
28

29
    @Override
30
    public @Nullable JTypeMirror getTargetType() {
31
        // this triggers type resolution of the enclosing expr.
32
        OverloadSelectionResult overload = node.getOverloadSelectionInfo();
1✔
33
        if (overload.isFailed()) {
1✔
34
            return null;
1✔
35
        }
36
        return overload.ithFormalParam(arg);
1✔
37
    }
38

39
    @Nullable JTypeMirror getTargetTypeOfSymbol() {
NEW
40
        OverloadSelectionResult overload = node.getOverloadSelectionInfo();
×
NEW
41
        if (overload.isFailed()) {
×
NEW
42
            return null;
×
43
        }
NEW
44
        JExecutableSymbol symbol = overload.getMethodType().getSymbol();
×
NEW
45
        JMethodSig genericMethod = symbol.getGenericSignature();
×
NEW
46
        return genericMethod.ithFormalParam(arg, overload.isVarargsCall());
×
47
    }
48

49
    @Override
50
    public boolean isMissing() {
51
        return false;
1✔
52
    }
53

54
    public InvocationNode getNode() {
55
        return node;
1✔
56
    }
57

58
    @Override
59
    public String toString() {
60
        return "InvocCtx{arg=" + arg + ", node=" + node + '}';
×
61
    }
62
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc