File tree Expand file tree Collapse file tree 2 files changed +6
-5
lines changed
main/java/org/sonar/python/types
test/java/org/sonar/python/types Expand file tree Collapse file tree 2 files changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -131,12 +131,13 @@ public boolean isCompatibleWith(InferredType other) {
131
131
132
132
@ Override
133
133
public boolean mustBeOrExtend (String typeName ) {
134
- return alternativeTypeSymbols ().stream ().flatMap (a -> {
134
+ List < Symbol > classSymbols = alternativeTypeSymbols ().stream ().flatMap (a -> {
135
135
if (a .is (Symbol .Kind .AMBIGUOUS )) {
136
136
return ((AmbiguousSymbol ) a ).alternatives ().stream ().filter (alternative -> alternative .is (CLASS ));
137
137
}
138
138
return Stream .of (a );
139
- }).filter (a -> a .is (CLASS )).allMatch (a -> ((ClassSymbol ) a ).isOrExtends (typeName ));
139
+ }).filter (a -> a .is (CLASS )).collect (Collectors .toList ());
140
+ return !classSymbols .isEmpty () && classSymbols .stream ().allMatch (a -> ((ClassSymbol ) a ).isOrExtends (typeName ));
140
141
}
141
142
142
143
@ Override
Original file line number Diff line number Diff line change @@ -169,9 +169,9 @@ public void test_mustBeOrExtend() {
169
169
assertThat (typeAmbiguousX1 .mustBeOrExtend ("other" )).isFalse ();
170
170
171
171
DeclaredType declaredType = new DeclaredType (new SymbolImpl ("C" , "foo.C" ));
172
- assertThat (declaredType .mustBeOrExtend ("other" )).isTrue ();
173
- assertThat (declaredType .mustBeOrExtend ("foo.C" )).isTrue ();
174
- assertThat (declaredType .mustBeOrExtend ("C" )).isTrue ();
172
+ assertThat (declaredType .mustBeOrExtend ("other" )).isFalse ();
173
+ assertThat (declaredType .mustBeOrExtend ("foo.C" )).isFalse ();
174
+ assertThat (declaredType .mustBeOrExtend ("C" )).isFalse ();
175
175
}
176
176
177
177
@ Test
You can’t perform that action at this time.
0 commit comments