| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 9f1272b commit 722c25b
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -236,12 +236,11 @@ private static Class<?> checkType(@Nullable Class<?> existingElemType, Class<?> | |||
| 236 | 236 | * @throws TypeException if the type does not accurately describe all elements | |
| 237 | 237 | */ | |
| 238 | 238 | public <T> NestedSet<T> getSet(Class<T> type) throws TypeException { | |
| 239 | - ElementType elemType = getElementType(); | ||
| 240 | - if (!set.isEmpty() && !elemType.canBeCastTo(type)) { | ||
| 239 | + if (!set.isEmpty() && !ElementType.canBeCastTo(elemClass, type)) { | ||
| 241 | 240 | throw new TypeException( | |
| 242 | 241 | String.format( | |
| 243 | 242 | "got a depset of '%s', expected a depset of '%s'", | |
| 244 | - elemType, Starlark.classType(type))); | ||
| 243 | + getElementType(), Starlark.classType(type))); | ||
| 245 | 244 | } | |
| 246 | 245 | @SuppressWarnings("unchecked") | |
| 247 | 246 | NestedSet<T> res = (NestedSet<T>) set; | |
@@ -539,10 +538,11 @@ private static Class<?> getTypeClass(Class<?> cls) { | |||
| 539 | 538 | // getTypeClass calls here and in ElementType.of, and remove the special | |
| 540 | 539 | // case for Object.class since isAssignableFrom will allow any supertype | |
| 541 | 540 | // of the element type, whether or not it is a Starlark value class. | |
| 542 | - private boolean canBeCastTo(Class<?> cls) { | ||
| 543 | - return this.cls == null | ||
| 541 | + private static boolean canBeCastTo(@Nullable Class<?> elemClass, Class<?> cls) { | ||
| 542 | + return elemClass == null | ||
| 543 | + || elemClass == cls | ||
| 544 | 544 | || cls == Object.class // historical exception | |
| 545 | - || getTypeClass(cls).isAssignableFrom(this.cls); | ||
| 545 | + || getTypeClass(cls).isAssignableFrom(elemClass); | ||
| 546 | 546 | } | |
| 547 | 547 | ||
| 548 | 548 | @Override | |
| Back | FazBrowse Home | New Git URL |
0 commit comments