Skip to content

Commit

Permalink
Merge branch 'pr-5177'
Browse files Browse the repository at this point in the history
  • Loading branch information
jsotuyod committed Aug 24, 2024
2 parents dcee6e6 + be47aab commit 6f505b9
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 1 deletion.
4 changes: 3 additions & 1 deletion docs/pages/release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ This is a {{ site.pmd.release_type }} release.
### 🐛 Fixed Issues
* apex-performance
* [#5139](https://github.com/pmd/pmd/issues/5139): \[apex] OperationWithHighCostInLoop not firing in triggers
* pmd-bestpractices
* java
* [#5167](https://github.com/pmd/pmd/pull/5167): \[java] java.lang.IllegalArgumentException: \<\?\> cannot be a wildcard bound
* java-bestpractices
* [#5145](https://github.com/pmd/pmd/issues/5145): \[java] False positive UnusedPrivateMethod
* plsql-bestpractices
* [#5132](https://github.com/pmd/pmd/issues/5132): \[plsql] TomKytesDespair - exception for more complex exception handler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1170,6 +1170,13 @@ public JTypeMirror visitClass(JClassType t, RecursionStop recursionStop) {
} else if (!upwards) {
// If Ai is a type that mentions a restricted type variable, then Ai' is undefined.
return NO_DOWN_PROJECTION;
} else if (u instanceof JWildcardType) {
// The rest of this function, below, treats u as the bound of a wildcard,
// but if u is already a wildcard (and therefore ai was a wildcard), we
// are already done.
newTargs.add(u);
change = true;
continue;
}

change = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,44 @@ class TypeOpsTest : FunSpec({


}
test("#5167 problem in projection") {
val (acu, spy) = javaParser.parseWithTypeInferenceSpy(
"""
import java.lang.annotation.Annotation;
interface Bar<T> {
Baz<T> getBaz();
}

interface Predicate<T> {
boolean check(T t);
}
interface Stream<T>{
T findSome();
}
interface Baz<T>{
Stream<Bar<? super T>> filterMethods(Predicate<? super T> p);
}

class Foo {

private static Bar<?> foo(
Bar<?> type, Class<? extends Annotation> annotation, boolean required) {
var method = type.getBaz().filterMethods(m -> true).findSome();
return method;
}
}
""".trimIndent()
)

val (barT) = acu.declaredTypeSignatures()
val methodId = acu.varId("method")

spy.shouldBeOk {
methodId shouldHaveType barT[`?`]
}
}
}
}


})

0 comments on commit 6f505b9

Please sign in to comment.