Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ public final class IllegalSafeLoggingArgument extends BugChecker
.named("of");

private static Type resolveParameterType(Type input, ExpressionTree tree, VisitorState state) {
if (input instanceof TypeVar) {
// Important not to call getReceiver/getReceiverType on a NewClassTree, which throws.
if (input instanceof TypeVar && tree instanceof MethodInvocationTree) {
TypeVar typeVar = (TypeVar) input;

Type receiver = ASTHelpers.getReceiverType(tree);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1574,6 +1574,24 @@ public void testBindingToSafeMethodTypeVariable() {
.doTest();
}

@Test
public void testTypeVariablesInConstructor() {
helper().addSourceLines(
"Test.java",
"import com.palantir.logsafe.*;",
"import java.util.*;",
"import java.util.function.*;",
"class Test {",
" static final class Foo<T> {",
" Foo(T input) {}",
" }",
" static Foo<String> f(Supplier<String> value) {",
" return new Foo<>(value.get());",
" }",
"}")
.doTest();
}

private CompilationTestHelper helper() {
return CompilationTestHelper.newInstance(IllegalSafeLoggingArgument.class, getClass());
}
Expand Down