Skip to content

Instantly share code, notes, and snippets.

@imagest
imagest / generics-type.java
Created December 11, 2023 18:29
Interesting Java compiler riddle
public class Example {
interface Identifier {}
class Request {}
class Response<T extends Identifier> {}
class ErrorResponse extends Response {}
// the inline lambda and the method _should_ behave exactly the same,
// but compiler somehow retains parameterzied upper bound type for _lambda_, but not for method.
// Ljava/util/function/Function<LExample$Request;LExample$Response<+LExample$Identifier;>;>;