[BUG]升级到fastjson2兼容包之后,原本的类型判断失效了
- Dominant language
- Java
- Stars
- 4.4k
- Forks
- 613
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 6
Description
### 问题描述
*简要描述您碰到的问题。*
### 环境信息
*请填写以下信息:*
- OS信息: [e.g.:CentOS 8.4.2105 4Core 3.10GHz 16 GB]
- JDK信息: [e.g.:Openjdk 1.8.0_312]
- 版本信息:[e.g.:Fastjson2 2.0.12]
### 重现步骤
*如何操作可以重现该问题:*
1. 使用 `com.alibaba.fastjson.JSONObject#getJSONArray` 及`com.alibaba.fastjson.JSON#parseObject(java.lang.String, com.alibaba.fastjson.TypeReference, com.alibaba.fastjson.parser.Feature...)`方法
2. 如果嵌套范型,如Optional,会编译不通过
这样的代码就变成错的了
他会把
```java
//可在此输入示例代码
Optional.ofNullable(event).filter(map -> HEART_BEAT_EVENT.equals(event))
.map(map -> JSON.parseObject(data, new TypeReference>() {
}));
```
识别为`Optional` 导致编译不通过,我只有像下面这样提前制定好类型,才可以链式调用

以及
JSONArray.stream()原本也可以这样调用
```java
config.getJSONArray("uekms").stream().map(Object::toString).collect(Collectors.toList());
```
但是这么调用在2.0.12中编译不通过了已经;

现在我好像只能用
```java
config.getJSONArray("uekms").toJavaList(String.class);
```
### 期待的正确结果
我希望可以和之前一样,直接进行链式调用
Contributor guide
Research direction
Start by reproducing the reported generic-inference failures with JSONObject#getJSONArray, JSON#parseObject, and JSONArray#stream under Fastjson2 2.0.12. Compare these calls with the earlier behavior and verify that nested Optional and stream chains compile as expected when the compatibility issue is resolved.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend-api-design
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100