mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-14 04:16:19 +00:00
[jdk9] Workaround for a weird casting issue that shows up for singularizer support.
This commit is contained in:
1 parent
6b3aa5ffd3
commit
1db7052464
2 files changed
+7
-4
No files matched your search
@@ -165,6 +165,9 @@ abstract class JavacJavaUtilSingularizer extends JavacSingularizer {
|
||||
JCExpression pluralnameDotPut = maker.Select(maker.Ident(data.getPluralName()), builderType.toName("put"));
|
||||
JCExpression arg1 = maker.Apply(jceBlank, chainDots(builderType, "this", data.getPluralName() + "$key", "get"), List.<JCExpression>of(maker.Ident(ivar)));
|
||||
JCExpression arg2 = maker.Apply(jceBlank, chainDots(builderType, "this", data.getPluralName() + "$value", "get"), List.<JCExpression>of(maker.Ident(ivar)));
|
||||
// [jdk9] We add an unneccessary (V) cast here. Not doing so gives an error in javac (build 9-ea+156-jigsaw-nightly-h6072-20170212):
|
||||
// error: method put in interface Map<K#2,V#2> cannot be applied to given types;
|
||||
arg2 = maker.TypeCast(createTypeArgs(2, false, builderType, data.getTypeArgs(), source).get(1), arg2);
|
||||
JCStatement putStatement = maker.Exec(maker.Apply(jceBlank, pluralnameDotPut, List.of(arg1, arg2)));
|
||||
JCStatement forInit = maker.VarDef(maker.Modifiers(0), ivar, maker.TypeIdent(CTC_INT), maker.Literal(CTC_INT, 0));
|
||||
JCExpression checkExpr = maker.Binary(CTC_LESS_THAN, maker.Ident(ivar), getSize(maker, builderType, keyVarName, nullGuard, true));
|
||||
|
||||
@@ -166,11 +166,11 @@ class BuilderSingularMaps<K, V> {
|
||||
break;
|
||||
default:
|
||||
women = new java.util.LinkedHashMap<K, V>(this.women$key.size() < 1073741824 ? 1 + this.women$key.size() + (this.women$key.size() - 3) / 3 : Integer.MAX_VALUE);
|
||||
for (int $i = 0; $i < this.women$key.size(); $i++) women.put(this.women$key.get($i), this.women$value.get($i));
|
||||
for (int $i = 0; $i < this.women$key.size(); $i++) women.put(this.women$key.get($i), (V) this.women$value.get($i));
|
||||
women = java.util.Collections.unmodifiableMap(women);
|
||||
}
|
||||
java.util.SortedMap<K, Number> men = new java.util.TreeMap<K, Number>();
|
||||
if (this.men$key != null) for (int $i = 0; $i < (this.men$key == null ? 0 : this.men$key.size()); $i++) men.put(this.men$key.get($i), this.men$value.get($i));
|
||||
if (this.men$key != null) for (int $i = 0; $i < (this.men$key == null ? 0 : this.men$key.size()); $i++) men.put(this.men$key.get($i), (Number) this.men$value.get($i));
|
||||
men = java.util.Collections.unmodifiableSortedMap(men);
|
||||
java.util.Map<Object, Object> rawMap;
|
||||
switch (this.rawMap$key == null ? 0 : this.rawMap$key.size()) {
|
||||
@@ -182,7 +182,7 @@ class BuilderSingularMaps<K, V> {
|
||||
break;
|
||||
default:
|
||||
rawMap = new java.util.LinkedHashMap<Object, Object>(this.rawMap$key.size() < 1073741824 ? 1 + this.rawMap$key.size() + (this.rawMap$key.size() - 3) / 3 : Integer.MAX_VALUE);
|
||||
for (int $i = 0; $i < this.rawMap$key.size(); $i++) rawMap.put(this.rawMap$key.get($i), this.rawMap$value.get($i));
|
||||
for (int $i = 0; $i < this.rawMap$key.size(); $i++) rawMap.put(this.rawMap$key.get($i), (Object) this.rawMap$value.get($i));
|
||||
rawMap = java.util.Collections.unmodifiableMap(rawMap);
|
||||
}
|
||||
java.util.Map<String, V> stringMap;
|
||||
@@ -195,7 +195,7 @@ class BuilderSingularMaps<K, V> {
|
||||
break;
|
||||
default:
|
||||
stringMap = new java.util.LinkedHashMap<String, V>(this.stringMap$key.size() < 1073741824 ? 1 + this.stringMap$key.size() + (this.stringMap$key.size() - 3) / 3 : Integer.MAX_VALUE);
|
||||
for (int $i = 0; $i < this.stringMap$key.size(); $i++) stringMap.put(this.stringMap$key.get($i), this.stringMap$value.get($i));
|
||||
for (int $i = 0; $i < this.stringMap$key.size(); $i++) stringMap.put(this.stringMap$key.get($i), (V) this.stringMap$value.get($i));
|
||||
stringMap = java.util.Collections.unmodifiableMap(stringMap);
|
||||
}
|
||||
return new BuilderSingularMaps<K, V>(women, men, rawMap, stringMap);
|
||||
|
||||
Reference in new issue
Block a user