官术网_书友最值得收藏!

Non-denotable types

Java types that you can use in a program, like int, Byte, Comparable, or String, are called denotable types. The types used by a compiler internally, like the subclass of an anonymous class, which you can't write in your program, are called non-denotable types.

Up until now, type inference with variables seemed quite easy to implement—just get the information about the values passed to a method and returned from a method, and infer the type. However, it isn't as simple as that when it comes to inference with non-denotable types—null types, intersection types, anonymous class types, and capture types.

For example, consider the following code and think about the type of the inferred variables:

// inferred type java.util.ImmutableCollections$ListN 
var a = List.of(1, "2", new StringBuilder());
var b = List.of(new ArrayList<String>(), LocalTime.now());

Type of variable a and b isn't a type that you would have read before. But that doesn't stop them from being inferred. The compiler infers them to a non-denotable type.

主站蜘蛛池模板: 武宣县| 五华县| 海原县| 丹巴县| 丰台区| 华安县| 安吉县| 紫金县| 广河县| 依安县| 高清| 曲阜市| 美姑县| 渭南市| 康乐县| 竹北市| 高雄县| 社会| 延边| 湟中县| 尼玛县| 礼泉县| 齐河县| 福清市| 岳池县| 通榆县| 安陆市| 宁波市| 定州市| 西贡区| 仙桃市| 棋牌| 钟祥市| 邯郸市| 民丰县| 沂南县| 丰宁| 平原县| 北京市| 桂阳县| 洞口县|