public List<Binding> getRequiredBindings() { List<Binding> requiredBindings = new ArrayList<>(); for (FieldBinding fieldBinding : fieldBindings) { if (fieldBinding.isRequired()) { requiredBindings.add(fieldBinding); } } return requiredBindings; }
void checkAssignment(BlockScope scope, TypeBinding lhsType, TypeBinding rhsType) { FieldBinding leftField = getLastField(this.lhs); if (leftField != null && rhsType != TypeBinding.NULL && (lhsType.kind() == Binding.WILDCARD_TYPE) && ((WildcardBinding) lhsType).boundKind != Wildcard.SUPER) { scope.problemReporter().wildcardAssignment(lhsType, rhsType, this.expression); } else if (leftField != null && !leftField.isStatic() && leftField.declaringClass != null /*length pseudo field*/ && leftField.declaringClass.isRawType()) { scope.problemReporter().unsafeRawFieldAssignment(leftField, rhsType, this.lhs); } else if (rhsType.needsUncheckedConversion(lhsType)) { scope.problemReporter().unsafeTypeConversion(this.expression, rhsType, lhsType); } }
private Binding findSingleStaticImport(char[][] compoundName, int mask) { Binding binding = findImport(compoundName, compoundName.length - 1); if (!binding.isValidBinding()) return binding; char[] name = compoundName[compoundName.length - 1]; if (binding instanceof PackageBinding) { Binding temp = ((PackageBinding) binding).getTypeOrPackage(name); if (temp != null && temp instanceof ReferenceBinding) // must resolve to a member type or field, not a top level type return new ProblemReferenceBinding( compoundName, (ReferenceBinding) temp, ProblemReasons.InvalidTypeForStaticImport); return binding; // cannot be a package, error is caught in sender } // look to see if its a static field first ReferenceBinding type = (ReferenceBinding) binding; FieldBinding field = (mask & Binding.FIELD) != 0 ? findField(type, name, null, true) : null; if (field != null) { if (field.problemId() == ProblemReasons.Ambiguous && ((ProblemFieldBinding) field).closestMatch.isStatic()) return field; // keep the ambiguous field instead of a possible method match if (field.isValidBinding() && field.isStatic() && field.canBeSeenBy(type, null, this)) return field; } // look to see if there is a static method with the same selector MethodBinding method = (mask & Binding.METHOD) != 0 ? findStaticMethod(type, name) : null; if (method != null) return method; type = findMemberType(name, type); if (type == null || !type.isStatic()) { if (field != null && !field.isValidBinding() && field.problemId() != ProblemReasons.NotFound) return field; return new ProblemReferenceBinding(compoundName, type, ProblemReasons.NotFound); } if (type.isValidBinding() && !type.canBeSeenBy(this.fPackage)) return new ProblemReferenceBinding(compoundName, type, ProblemReasons.NotVisible); if (type.problemId() == ProblemReasons.NotVisible) // ensure compoundName is correct return new ProblemReferenceBinding( compoundName, ((ProblemReferenceBinding) type).closestMatch, ProblemReasons.NotVisible); return type; }