• 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

47.5
/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/types/UnresolvedMethodSig.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;
6

7
import java.lang.reflect.Modifier;
8
import java.util.Collections;
9
import java.util.List;
10
import java.util.function.Function;
11

12
import org.checkerframework.checker.nullness.qual.NonNull;
13
import org.checkerframework.checker.nullness.qual.Nullable;
14

15
import net.sourceforge.pmd.lang.java.symbols.JClassSymbol;
16
import net.sourceforge.pmd.lang.java.symbols.JExecutableSymbol;
17
import net.sourceforge.pmd.lang.java.symbols.JFormalParamSymbol;
18
import net.sourceforge.pmd.lang.java.symbols.JMethodSymbol;
19
import net.sourceforge.pmd.lang.java.types.internal.InternalMethodTypeItf;
20

21
final class UnresolvedMethodSig implements JMethodSig, InternalMethodTypeItf {
22

23
    private final TypeSystem ts;
24
    private final JExecutableSymbol sym;
25

26
    UnresolvedMethodSig(TypeSystem ts) {
1✔
27
        this.ts = ts;
1✔
28
        sym = new UnresolvedMethodSym(ts);
1✔
29
    }
1✔
30

31
    @Override
32
    public TypeSystem getTypeSystem() {
33
        return ts;
1✔
34
    }
35

36
    @Override
37
    public JExecutableSymbol getSymbol() {
38
        return sym;
1✔
39
    }
40

41
    @Override
42
    public JMethodSig getErasure() {
43
        return this;
×
44
    }
45

46
    @Override
47
    public JTypeMirror getDeclaringType() {
48
        return ts.UNKNOWN;
1✔
49
    }
50

51
    @Override
52
    public JTypeMirror getReturnType() {
53
        return ts.UNKNOWN;
1✔
54
    }
55

56
    @Override
57
    public JTypeMirror getAnnotatedReceiverType() {
58
        return ts.UNKNOWN;
×
59
    }
60

61
    @Override
62
    public List<JTypeMirror> getFormalParameters() {
63
        return Collections.emptyList();
1✔
64
    }
65

66
    @Override
67
    public List<JTypeVar> getTypeParameters() {
68
        return Collections.emptyList();
1✔
69
    }
70

71
    @Override
72
    public List<JTypeMirror> getThrownExceptions() {
73
        return Collections.emptyList();
×
74
    }
75

76
    @Override
77
    public JMethodSig withReturnType(JTypeMirror returnType) {
78
        return this;
×
79
    }
80

81
    @Override
82
    public JMethodSig markAsAdapted() {
83
        return this;
×
84
    }
85

86
    @Override
87
    public JMethodSig adaptedMethod() {
88
        return this;
1✔
89
    }
90

91
    @Override
92
    public JMethodSig withTypeParams(@Nullable List<JTypeVar> tparams) {
93
        return this;
×
94
    }
95

96
    @Override
97
    public JMethodSig subst(Function<? super SubstVar, ? extends @NonNull JTypeMirror> subst) {
98
        return this;
1✔
99
    }
100

101
    @Override
102
    public JMethodSig withOwner(JTypeMirror newOwner) {
103
        return this;
×
104
    }
105

106
    @Override
107
    public JMethodSig originalMethod() {
108
        return this;
×
109
    }
110

111
    @Override
112
    public String toString() {
113
        return getName();
×
114
    }
115

116
    private static class UnresolvedMethodSym implements JMethodSymbol {
117

118
        private final TypeSystem ts;
119

120
        UnresolvedMethodSym(TypeSystem ts) {
1✔
121
            this.ts = ts;
1✔
122
        }
1✔
123

124
        @Override
125
        public boolean isUnresolved() {
126
            return true;
1✔
127
        }
128

129
        @Override
130
        public TypeSystem getTypeSystem() {
131
            return ts;
×
132
        }
133

134
        @Override
135
        public boolean isBridge() {
136
            return false;
×
137
        }
138

139
        @Override
140
        public JTypeMirror getReturnType(Substitution subst) {
141
            return ts.NO_TYPE;
×
142
        }
143

144
        @Override
145
        public List<JFormalParamSymbol> getFormalParameters() {
146
            return Collections.emptyList();
×
147
        }
148

149
        @Override
150
        public boolean isVarargs() {
151
            return false;
1✔
152
        }
153

154
        @Override
155
        public int getArity() {
156
            return 0;
×
157
        }
158

159
        @Override
160
        public @Nullable JTypeMirror getAnnotatedReceiverType(Substitution subst) {
161
            return ts.UNKNOWN;
×
162
        }
163

164
        @Override
165
        public @NonNull JClassSymbol getEnclosingClass() {
UNCOV
166
            return (JClassSymbol) ts.UNKNOWN.getSymbol();
×
167
        }
168

169
        @Override
170
        public List<JTypeMirror> getFormalParameterTypes(Substitution subst) {
171
            return Collections.emptyList();
×
172
        }
173

174
        @Override
175
        public List<JTypeMirror> getThrownExceptionTypes(Substitution subst) {
176
            return Collections.emptyList();
×
177
        }
178

179
        @Override
180
        public List<JTypeVar> getTypeParameters() {
UNCOV
181
            return Collections.emptyList();
×
182
        }
183

184
        @Override
185
        public int getModifiers() {
186
            return Modifier.PUBLIC;
1✔
187
        }
188

189
        @Override
190
        public String getSimpleName() {
191
            return "(*unknown method*)";
1✔
192
        }
193

194
        @Override
195
        public String toString() {
196
            return getSimpleName();
×
197
        }
198

199
        @Override
200
        public JMethodSig getGenericSignature() {
201
            return getTypeSystem().UNRESOLVED_METHOD;
×
202
        }
203
    }
204
}
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