private IType getMoreSpecificType(IType type1, IType type2) { if (type1.isAssignableFrom(type2)) { return type2; } else if (type2.isAssignableFrom(type1)){ return type1; } else { return type1; } }
public boolean isDomainInstance(Object value) { IType type = TypeSystem.get(value.getClass()); return (_typekeyType != null && _typekeyType.isAssignableFrom(type)) || (_keyType != null && _keyType.isAssignableFrom(type)) || (_beanType != null && _beanType.isAssignableFrom(type)); }
private boolean areAssignableBytecodeTypes( ICoercer coercer, IType asType, IType lhsType ) { return (coercer instanceof IdentityCoercer || coercer == null) && (asType.isAssignableFrom( lhsType ) || lhsType.isAssignableFrom( asType )) && TypeSystem.isBytecodeType( lhsType ) && TypeSystem.isBytecodeType( asType ); }
@Override public IConstructorInfo getCallableConstructor( IType... params ) { if( params == null || params.length == 0 ) { return _dci.get( 0 ); } else if( params.length == 1 && TypeSystem.get( IExpando.class ).isAssignableFrom( params[0] ) ) { return _dci.get( 1 ); } return null; }
private static boolean isGosuClassAccessingProtectedMemberOfClassNotInHierarchy( ICompilableTypeInternal callingClass, IType declaringClass, IRelativeTypeInfo.Accessibility accessibility ) { // This is legal in Gosu if the member is accessed indirectly through a subclass that lives in same package as calling class if( IGosuClass.ProxyUtil.isProxy( declaringClass ) ) { declaringClass = IGosuClass.ProxyUtil.getProxiedType( declaringClass ); } return accessibility == IRelativeTypeInfo.Accessibility.PROTECTED && !declaringClass.isAssignableFrom( callingClass ); }
protected static boolean isInEnhancedTypesHierarchy(IType ownersClass, IType whosAskin) { return (whosAskin instanceof IGosuEnhancement && ((IGosuEnhancement)whosAskin).getEnhancedType() != null && ownersClass.isAssignableFrom(((IGosuEnhancement) whosAskin).getEnhancedType())); }
default boolean isAssignableFrom( IJavaClassType from ) { if( equals( from ) || GosuObjectUtil.equals( getConcreteType(), from ) ) { return true; } IType actualFrom = from.getActualType( TypeVarToTypeMap.EMPTY_MAP ); IType actualTo = getActualType( TypeVarToTypeMap.EMPTY_MAP ); return actualTo != null && actualFrom != null && actualTo.isAssignableFrom( actualFrom ) || getConcreteType().getActualType( TypeVarToTypeMap.EMPTY_MAP ).isAssignableFrom( actualFrom ); }
/** */ public boolean isAssignableFrom( IType type ) { return type.getAllTypesInHierarchy().contains( getThisRef() ) || (type.isArray() && type.getClass().isInstance( getThisRef() ) && this.getComponentType().isAssignableFrom( type.getComponentType() )); }
@Override public boolean isAssignableFrom( IType type ) { if( type == this ) { return true; } return type.isArray() && getComponentType().isAssignableFrom( type.getComponentType() ); } }
private boolean _genericInterfacesClash( IType rhsType, IType lhsType ) { if( !rhsType.isParameterizedType() || !lhsType.isParameterizedType() ) { return false; } IType lhsTypeInRhs = TypeLord.findParameterizedType( lhsType, rhsType.getGenericType() ); if( lhsTypeInRhs != null ) { lhsTypeInRhs = TypeLord.replaceTypeVariableTypeParametersWithBoundingTypes( lhsTypeInRhs, lhsTypeInRhs.getEnclosingType() ); return !rhsType.isAssignableFrom( lhsTypeInRhs ) && !lhsTypeInRhs.isAssignableFrom( rhsType ); } return false; }
private boolean isExectedTypeAssignableFrom( BeanTree beanTree ) { return _expectedType.isAssignableFrom( beanTree.getBeanNode().getType() ) || (beanTree.getBeanNode().getType() instanceof IFunctionType && _expectedType.isAssignableFrom( ((IFunctionType)beanTree.getBeanNode().getType()).getReturnType() )); }
public boolean acceptFeature(IType beanType, IFeatureInfo fi) { if (!fi.getOwnersType().isAssignableFrom(beanType)) { return false; } if (!isEntityClass(beanType)) { return false; } IType type = TypeSystem.get(ExtendedProperty.class); return ((IAnnotatedFeatureInfo) fi).hasAnnotation(type); } };
public static boolean enclosingTypeInstanceInScope( IType type, IGosuClassInternal inner ) { return inner != null && !inner.isStatic() && ((type != null && type.isAssignableFrom( inner.getEnclosingType() )) || enclosingTypeInstanceInScope( type, (IGosuClassInternal)inner.getEnclosingType() )); }
@Override protected boolean areReturnTypesAssignable( FunctionType that ) { IType thisType = getReturnType(); IType thatType = that.getReturnType(); return thisType == thatType || thatType != JavaTypes.pVOID() && thisType.isAssignableFrom( thatType ) || StandardCoercionManager.arePrimitiveTypesAssignable( thisType, thatType ); }
private boolean isProxyClassCompiling() { IType compilingClass = GosuClassCompilingStack.getCurrentCompilingType(); if (compilingClass != null && getOwnersType() != null) { IType owner = getOwnersType(); if (compilingClass instanceof IGosuClassInternal && ((IGosuClassInternal) compilingClass).isProxy()) { return owner.isAssignableFrom(compilingClass); // the proxy class should have the extended type in its hierarchy } } return false; }
protected static boolean isInHierarchy(IType ownersClass, IType whosAskin) { return ownersClass.isAssignableFrom(whosAskin) || ownersClass.getEnclosingType() != null && isInHierarchy( ownersClass.getEnclosingType(), whosAskin ) || (ownersClass instanceof IGosuClass && ((IGosuClass) ownersClass).isSubClass( whosAskin )); }
protected IRExpression pushOuter( IType outerTarget, IType currentOuter, IRExpression root ) { IRExpression result = root; while( !outerTarget.isAssignableFrom( currentOuter ) ) { IRMethod irMethod = IRMethodFactory.createIRMethod( currentOuter, OUTER_ACCESS, getRuntimeEnclosingType( currentOuter ), new IType[]{currentOuter}, AccessibilityUtil.forOuter(), true); result = callMethod( irMethod, null, Collections.singletonList(result)); currentOuter = maybeUnwrapProxy( currentOuter.getEnclosingType() ); } return result; }
public static boolean isStructurallyAssignable( IType toType, IType fromType ) { if( !(toType instanceof IGosuClass && ((IGosuClass)toType).isStructure()) && !(isStrictGenerics( toType ) && toType.getGenericType().isAssignableFrom( TypeSystem.getPureGenericType( fromType ) )) ) { return false; } return isStructurallyAssignable_Laxed( toType, fromType ); } public static boolean isStructurallyAssignable_Laxed( IType toType, IType fromType )
protected boolean areReturnTypesAssignable( FunctionType from ) { IType toType = getReturnType(); IType fromType = from.getReturnType(); if( isThisReturnTypeNotVoidThatReturnTypeVoid( toType, fromType ) ) { return false; } return toType == fromType || toType.isAssignableFrom( fromType ) || StandardCoercionManager.isStructurallyAssignable( toType, fromType ) || StandardCoercionManager.arePrimitiveTypesAssignable( toType, fromType ) || toType == GosuParserTypes.NULL_TYPE(); }
private boolean returnTypesCompatible( DynamicFunctionSymbol dfsExisting, DynamicFunctionSymbol dfs ) { IType existingReturnType = maybeResolveFunctionTypeVars( dfsExisting, dfsExisting.getReturnType() ); IType overrideReturnType = maybeResolveFunctionTypeVars( dfs, dfs.getReturnType() ); if( existingReturnType.isAssignableFrom( overrideReturnType ) || StandardCoercionManager.isStructurallyAssignable( existingReturnType, overrideReturnType ) ) { return true; } else { return dfs.getReturnType() instanceof ErrorType; } }