protected LightweightTypeReference doGetReturnType(XExpression expression, boolean onlyExplicitReturn) { TypeData typeData = getTypeData(expression, true, onlyExplicitReturn); if (typeData != null) return typeData.getActualType(); return null; }
protected LightweightTypeReference doGetActualType(XExpression expression) { TypeData typeData = getTypeData(expression, false); if (typeData != null) return typeData.getActualType(); return null; }
private LightweightTypeReference getMergedType(MergeData mergeData, List<TypeData> values) { LightweightTypeReference mergedType = !mergeData.references.isEmpty() || !mergeData.voidSeen ? getMergedType(/*mergedFlags, */mergeData.references) : values.get(0).getActualType(); return mergedType; }
private TypeData getSingleMergeResult(TypeData typeData, final XExpression expression, boolean returnType) { LightweightTypeReference upperBoundSubstitute = typeData.getActualType().getUpperBoundSubstitute(); if (upperBoundSubstitute != typeData.getActualType()) return new TypeData(expression, typeData.getExpectation(), upperBoundSubstitute, typeData.getConformanceFlags(), returnType); return typeData; }
protected void refineExpectedType(XExpression receiver, ITypeExpectation refinedExpectation) { Collection<TypeData> typeData = ensureExpressionTypesMapExists().get(receiver); List<TypeData> replaced = Lists.newArrayListWithCapacity(typeData.size()); for(TypeData existing: typeData) { TypeData newTypeData = new TypeData(receiver, refinedExpectation, existing.getActualType(), existing.getConformanceFlags(), existing.isReturnType()); replaced.add(newTypeData); } ensureExpressionTypesMapExists().put(receiver, replaced); }
private void enhanceMergeData(List<TypeData> values, MergeData mergeData) { for (int i = 0, size = values.size(); i < size; i++) { TypeData value = values.get(i); LightweightTypeReference reference = value.getActualType().getUpperBoundSubstitute(); int flags = value.getConformanceFlags(); if (reference.isPrimitiveVoid()) {
protected TypeData prepareMerge(TypeData typeData, ITypeReferenceOwner owner) { LightweightTypeReference typeReference = typeData.getActualType(); if (typeData.isOwnedBy(owner) && !(typeReference instanceof UnboundTypeReference)) return typeData; if (typeReference instanceof UnboundTypeReference && super.isResolved(((UnboundTypeReference) typeReference).getHandle())) { typeReference = typeReference.getUpperBoundSubstitute(); } return new TypeData(typeData.getExpression(), typeData.getExpectation().copyInto(owner), typeReference.copyInto(owner), typeData.getConformanceFlags(), typeData.isReturnType()); }
protected int getConformanceFlags(TypeData typeData, boolean recompute) { int flags = typeData.getConformanceFlags(); if (recompute) { if ((flags & ConformanceFlags.SEALED) != 0) { ConformanceFlags.sanityCheck(flags); return flags; } flags &= ~(ConformanceFlags.INCOMPATIBLE | ConformanceFlags.SUCCESS); flags |= ConformanceFlags.UNCHECKED; } if ((flags & ConformanceFlags.UNCHECKED) != 0) { LightweightTypeReference actualType = typeData.getActualType(); ITypeExpectation expectation = typeData.getExpectation(); LightweightTypeReference expectedType = expectation.getExpectedType(); if (expectedType != null) { int conformanceResult = expectedType.getUpperBoundSubstitute().internalIsAssignableFrom( actualType, TypeConformanceComputationArgument.DEFAULT); flags |= conformanceResult | ConformanceFlags.CHECKED; flags &= ~ConformanceFlags.UNCHECKED; } else { flags &= ~ConformanceFlags.UNCHECKED; flags |= ConformanceFlags.CHECKED_SUCCESS; } } ConformanceFlags.sanityCheck(flags); typeData.setConformanceFlags(flags); return flags; }
protected void addTypeDiagnostic(XExpression expression, /* @Nullable */ TypeData typeData, IAcceptor<? super AbstractDiagnostic> acceptor) { if (typeData != null) { LightweightTypeReference actualType = typeData.getActualType(); ITypeExpectation expectation = typeData.getExpectation(); int knownFlags = typeData.getConformanceFlags();