Changeset View
Changeset View
Standalone View
Standalone View
duchain/builders/typebuilder.cpp
Show First 20 Lines • Show All 439 Lines • ▼ Show 20 Line(s) | 438 | { | |||
---|---|---|---|---|---|
440 | // qCDebug(DUCHAIN) << "return" << (ft->returnType() ? ft->returnType()->toString() : "none") << lastType()->toString(); | 440 | // qCDebug(DUCHAIN) << "return" << (ft->returnType() ? ft->returnType()->toString() : "none") << lastType()->toString(); | ||
441 | AbstractType::Ptr type = getTypeForNode(node->returnExpr); | 441 | AbstractType::Ptr type = getTypeForNode(node->returnExpr); | ||
442 | if (type) { | 442 | if (type) { | ||
443 | // ignore references for return values, PHP does so as well | 443 | // ignore references for return values, PHP does so as well | ||
444 | if ( ReferenceType::Ptr rType = ReferenceType::Ptr::dynamicCast(type) ) { | 444 | if ( ReferenceType::Ptr rType = ReferenceType::Ptr::dynamicCast(type) ) { | ||
445 | type = rType->baseType(); | 445 | type = rType->baseType(); | ||
446 | } | 446 | } | ||
447 | if (ft->returnType() && !ft->returnType()->equals(type.data())) { | 447 | if (ft->returnType() && !ft->returnType()->equals(type.data())) { | ||
448 | bool existingTypeIsCallable = ft->returnType().cast<IntegralTypeExtended>() && | ||||
449 | ft->returnType().cast<IntegralTypeExtended>()->dataType() == IntegralTypeExtended::TypeCallable; | ||||
450 | bool newTypeIsCallable = type.cast<IntegralTypeExtended>() && | ||||
451 | type.cast<IntegralTypeExtended>()->dataType() == IntegralTypeExtended::TypeCallable; | ||||
448 | if (ft->returnType().cast<IntegralType>() | 452 | if (ft->returnType().cast<IntegralType>() | ||
449 | && ft->returnType().cast<IntegralType>()->dataType() == IntegralType::TypeMixed) | 453 | && ft->returnType().cast<IntegralType>()->dataType() == IntegralType::TypeMixed) | ||
450 | { | 454 | { | ||
451 | //don't add TypeMixed to the list, just ignore | 455 | //don't add TypeMixed to the list, just ignore | ||
452 | ft->setReturnType(type); | 456 | ft->setReturnType(type); | ||
457 | } else if ((existingTypeIsCallable && type.cast<FunctionType>()) || (newTypeIsCallable && ft->returnType().cast<FunctionType>())) { | ||||
458 | //If one type is "callable" and the other a real function, the result is just a "callable". | ||||
459 | ft->setReturnType(AbstractType::Ptr(new IntegralTypeExtended(IntegralTypeExtended::TypeCallable))); | ||||
453 | } else { | 460 | } else { | ||
454 | UnsureType::Ptr retT; | 461 | UnsureType::Ptr retT; | ||
455 | if (ft->returnType().cast<UnsureType>()) { | 462 | if (ft->returnType().cast<UnsureType>()) { | ||
456 | //qCDebug(DUCHAIN) << "we already have an unsure type"; | 463 | //qCDebug(DUCHAIN) << "we already have an unsure type"; | ||
457 | retT = ft->returnType().cast<UnsureType>(); | 464 | retT = ft->returnType().cast<UnsureType>(); | ||
458 | if (type.cast<UnsureType>()) { | 465 | if (type.cast<UnsureType>()) { | ||
459 | //qCDebug(DUCHAIN) << "add multiple to returnType"; | 466 | //qCDebug(DUCHAIN) << "add multiple to returnType"; | ||
460 | FOREACH_FUNCTION(const IndexedType& t, type.cast<UnsureType>()->types) { | 467 | FOREACH_FUNCTION(const IndexedType& t, type.cast<UnsureType>()->types) { | ||
▲ Show 20 Lines • Show All 94 Lines • Show Last 20 Lines |