Example usage for org.eclipse.jdt.internal.compiler.lookup BlockScope problemReporter

List of usage examples for org.eclipse.jdt.internal.compiler.lookup BlockScope problemReporter

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.compiler.lookup BlockScope problemReporter.

Prototype

@Override
    public ProblemReporter problemReporter() 

Source Link

Usage

From source file:lombok.eclipse.agent.PatchExtensionMethod.java

License:Open Source License

public static TypeBinding resolveType(TypeBinding resolvedType, MessageSend methodCall, BlockScope scope) {
    List<Extension> extensions = new ArrayList<Extension>();
    TypeDeclaration decl = scope.classScope().referenceContext;

    EclipseNode owningType = null;//from   ww  w .j  av  a2 s .c  o  m

    for (EclipseNode typeNode = getTypeNode(decl); typeNode != null; typeNode = upToType(typeNode)) {
        Annotation ann = getAnnotation(ExtensionMethod.class, typeNode);
        if (ann != null) {
            extensions.addAll(0,
                    getApplicableExtensionMethods(typeNode, ann, methodCall.receiver.resolvedType));
            if (owningType == null)
                owningType = typeNode;
        }
    }

    boolean skip = false;

    if (methodCall.receiver instanceof ThisReference
            && (((ThisReference) methodCall.receiver).bits & ASTNode.IsImplicitThis) != 0)
        skip = true;
    if (methodCall.receiver instanceof SuperReference)
        skip = true;
    if (methodCall.receiver instanceof NameReference) {
        Binding binding = ((NameReference) methodCall.receiver).binding;
        if (binding instanceof TypeBinding)
            skip = true;
    }

    if (!skip)
        for (Extension extension : extensions) {
            if (!extension.suppressBaseMethods && !(methodCall.binding instanceof ProblemMethodBinding))
                continue;
            for (MethodBinding extensionMethod : extension.extensionMethods) {
                if (!Arrays.equals(methodCall.selector, extensionMethod.selector))
                    continue;
                MessageSend_postponedErrors.clear(methodCall);
                if (methodCall.receiver instanceof ThisReference) {
                    methodCall.receiver.bits &= ~ASTNode.IsImplicitThis;
                }
                List<Expression> arguments = new ArrayList<Expression>();
                arguments.add(methodCall.receiver);
                if (methodCall.arguments != null)
                    arguments.addAll(Arrays.asList(methodCall.arguments));
                List<TypeBinding> argumentTypes = new ArrayList<TypeBinding>();
                for (Expression argument : arguments) {
                    if (argument.resolvedType != null)
                        argumentTypes.add(argument.resolvedType);
                    // TODO: Instead of just skipping nulls entirely, there is probably a 'unresolved type' placeholder. THAT is what we ought to be adding here!
                }
                Expression[] originalArgs = methodCall.arguments;
                methodCall.arguments = arguments.toArray(new Expression[0]);
                MethodBinding fixedBinding = scope.getMethod(extensionMethod.declaringClass,
                        methodCall.selector, argumentTypes.toArray(new TypeBinding[0]), methodCall);
                if (fixedBinding instanceof ProblemMethodBinding) {
                    methodCall.arguments = originalArgs;
                    if (fixedBinding.declaringClass != null) {
                        PostponedInvalidMethodError.invoke(scope.problemReporter(), methodCall, fixedBinding,
                                scope);
                    }
                } else {
                    for (int i = 0, iend = arguments.size(); i < iend; i++) {
                        Expression arg = arguments.get(i);
                        if (fixedBinding.parameters[i].isArrayType() != arg.resolvedType.isArrayType())
                            break;
                        if (arg instanceof MessageSend) {
                            ((MessageSend) arg).valueCast = arg.resolvedType;
                        }
                        if (!fixedBinding.parameters[i].isBaseType() && arg.resolvedType.isBaseType()) {
                            int id = arg.resolvedType.id;
                            arg.implicitConversion = TypeIds.BOXING | (id + (id << 4)); // magic see TypeIds
                        } else if (fixedBinding.parameters[i].isBaseType() && !arg.resolvedType.isBaseType()) {
                            int id = fixedBinding.parameters[i].id;
                            arg.implicitConversion = TypeIds.UNBOXING | (id + (id << 4)); // magic see TypeIds
                        }
                    }

                    methodCall.receiver = createNameRef(extensionMethod.declaringClass, methodCall);
                    methodCall.actualReceiverType = extensionMethod.declaringClass;
                    methodCall.binding = fixedBinding;
                    methodCall.resolvedType = methodCall.binding.returnType;
                }
                return methodCall.resolvedType;
            }
        }

    PostponedError error = MessageSend_postponedErrors.get(methodCall);
    if (error != null)
        error.fire();

    MessageSend_postponedErrors.clear(methodCall);
    return resolvedType;
}

From source file:org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding.java

License:Open Source License

public FieldBinding addSyntheticFieldForClassLiteral(TypeBinding targetType, BlockScope blockScope) {
    if (this.synthetics == null)
        this.synthetics = new HashMap[MAX_SYNTHETICS];
    if (this.synthetics[SourceTypeBinding.CLASS_LITERAL_EMUL] == null)
        this.synthetics[SourceTypeBinding.CLASS_LITERAL_EMUL] = new HashMap(5);

    // use a different table than FIELDS, given there might be a collision between emulation of X.this$0 and X.class.
    FieldBinding synthField = (FieldBinding) this.synthetics[SourceTypeBinding.CLASS_LITERAL_EMUL]
            .get(targetType);/*ww w  .  j a va  2s .  com*/
    if (synthField == null) {
        synthField = new SyntheticFieldBinding(
                CharOperation.concat(TypeConstants.SYNTHETIC_CLASS,
                        String.valueOf(this.synthetics[SourceTypeBinding.CLASS_LITERAL_EMUL].size())
                                .toCharArray()),
                blockScope.getJavaLangClass(),
                ClassFileConstants.AccDefault | ClassFileConstants.AccStatic | ClassFileConstants.AccSynthetic,
                this, Constant.NotAConstant, this.synthetics[SourceTypeBinding.CLASS_LITERAL_EMUL].size());
        this.synthetics[SourceTypeBinding.CLASS_LITERAL_EMUL].put(targetType, synthField);
    }
    // ensure there is not already such a field defined by the user
    FieldBinding existingField;
    if ((existingField = getField(synthField.name, true /*resolve*/)) != null) {
        TypeDeclaration typeDecl = blockScope.referenceType();
        FieldDeclaration[] typeDeclarationFields = typeDecl.fields;
        int max = typeDeclarationFields == null ? 0 : typeDeclarationFields.length;
        for (int i = 0; i < max; i++) {
            FieldDeclaration fieldDecl = typeDeclarationFields[i];
            if (fieldDecl.binding == existingField) {
                blockScope.problemReporter().duplicateFieldInType(this, fieldDecl);
                break;
            }
        }
    }
    return synthField;
}

From source file:org.eclipse.objectteams.otdt.internal.core.compiler.ast.BaseAllocationExpression.java

License:Open Source License

/**
 * Initialize the type to create from the "playedBy" clause.
 * @param scope non-null/* w w w . j a  v a2  s  . c o m*/
 */
private void createAst(BlockScope scope) {
    if (this.isAstCreated)
        return; // already done.

    this.isAstCreated = true; // even if creation fails, don't try again.

    ReferenceBinding enclType;
    AbstractMethodDeclaration enclMethodDecl;
    ReferenceBinding baseclass = null;

    enclType = scope.enclosingSourceType();
    enclMethodDecl = (AbstractMethodDeclaration) scope.methodScope().referenceContext;

    if (enclType.isDirectRole())
        baseclass = ((MemberTypeBinding) enclType).baseclass();
    if (baseclass == null || !enclMethodDecl.isConstructor()) {
        scope.problemReporter().baseConstructorCallInWrongMethod(this, scope.methodScope().referenceContext);
        return;
    }
    ConstructorDeclaration enclCtor = (ConstructorDeclaration) enclMethodDecl;
    if (this.isExpression) {
        if (!isArgOfOtherCtor(enclCtor, scope))
            scope.problemReporter().baseConstructorExpressionOutsideCtorCall(this);
    } else {
        if (enclCtor.statements[0] != this)
            scope.problemReporter().baseConstructorCallIsNotFirst(this);
    }

    AstGenerator gen = new AstGenerator(this.sourceStart, this.sourceEnd);
    Expression allocation;
    if (this.enclosingInstance != null) {
        this.enclosingInstance = new PotentialLowerExpression(this.enclosingInstance,
                baseclass.enclosingType());
        // FIXME(SH): check baseclass.enclosingType();
    }

    if (baseclass.isDirectRole()) {
        // instead of new B() create:
        //       receiver._OT$createB():
        Expression receiver;
        if (RoleTypeBinding.isRoleWithExplicitAnchor(baseclass)) {
            RoleTypeBinding baseRole = (RoleTypeBinding) baseclass;
            ITeamAnchor anchor = baseRole._teamAnchor;
            ReferenceBinding startClass = anchor.getFirstDeclaringClass();
            char[][] tokens = anchor.tokens();
            if (startClass != null) {
                // relevant start class, create as receiver:
                //     EnclType.this.field1.
                TypeReference startReference = gen.typeReference(startClass);
                startReference.setBaseclassDecapsulation(DecapsulationState.ALLOWED);
                receiver = gen.qualifiedThisReference(startReference);
                for (int i = 0; i < tokens.length; i++) {
                    receiver = gen.fieldReference(receiver, tokens[i]);
                }
            } else {
                // the best name path defines the receiver:
                receiver = gen.qualifiedNameReference(tokens);
            }
        } else {
            if (this.enclosingInstance != null) {
                receiver = this.enclosingInstance;
            } else {
                if (TypeBinding.equalsEquals(baseclass.enclosingType(), enclType.enclosingType()))
                    receiver = gen.thisReference(); // creating a role of the same team as base instance??
                else
                    receiver = gen.qualifiedThisReference(gen.typeReference(baseclass.enclosingType()));
            }
        }
        char[] selector = CharOperation.concat(CREATOR_PREFIX_NAME, baseclass.sourceName());

        MessageSend allocSend = new MessageSend() {
            @Override
            public boolean isDecapsulationAllowed(Scope scope2) {
                // this message send can decapsulate independent of scope
                return true;
            }

            @Override
            public DecapsulationState getBaseclassDecapsulation() {
                return DecapsulationState.ALLOWED;
            }
        };
        gen.setPositions(allocSend);
        allocSend.receiver = receiver;
        allocSend.selector = selector;
        allocSend.arguments = this.arguments;
        allocSend.accessId = -1; // request that MessageSend.resolveType() assigns a fresh accessId if decapsulation is detected
        allocation = allocSend;
    } else {
        AllocationExpression alloc = newAllocation(baseclass, gen);
        alloc.type.setBaseclassDecapsulation(DecapsulationState.ALLOWED); // report individually
        alloc.arguments = this.arguments;
        alloc.sourceStart = this.sourceStart;
        alloc.sourceEnd = this.sourceEnd;
        alloc.statementEnd = this.statementEnd;
        allocation = alloc;
    }
    this.arguments = null; // don't use any more.

    ExplicitConstructorCall selfcall = enclCtor.constructorCall;
    if (selfcall.isImplicitSuper() && enclType.superclass().isDirectRole()
            && enclType.superclass().baseclass() != null) {
        // implement 2.4.2(c):
        // transform "super(); base(args);" => "super(new MyBase(args)); nop;"
        enclCtor.constructorCall = genLiftCtorCall(allocation);
        enclCtor.statements[0] = new AstGenerator(this.sourceStart, this.sourceEnd).emptyStatement();
        // pretend we are not calling base() because we already call the lifting-ctor.
    } else if (this.isExpression) {
        // similar to above:
        // translate "super(base(args), ...);" as "super(new MyBase(args), ...);"
        this.expression = allocation; // and ignore the assignment flavor of this node.
    } else {
        // needed by ASTConverter:
        this.expression = allocation;
        if (!enclType.roleModel.hasBaseclassProblem() && !scope.referenceType().ignoreFurtherInvestigation) {

            MethodModel.setCallsBaseCtor(enclCtor);

            // really creating base here, need to register this base object
            RoleModel boundRootRoleModel = enclType.roleModel.getBoundRootRole();
            if (boundRootRoleModel == null)
                throw new InternalCompilerError(
                        "Unexpected: role has neither baseclassProblem nor boundRootRole"); //$NON-NLS-1$
            Statement[] regStats = Lifting.genRoleRegistrationStatements(scope, boundRootRoleModel, baseclass,
                    enclCtor, gen);
            int len = enclCtor.statements.length;
            Statement[] newStats = new Statement[len + regStats.length];
            newStats[0] = this;
            System.arraycopy(regStats, 0, newStats, 1, regStats.length);
            System.arraycopy(enclCtor.statements, 1, newStats, regStats.length + 1, len - 1);
            enclCtor.setStatements(newStats);
        }
    }
}

From source file:org.eclipse.objectteams.otdt.internal.core.compiler.ast.BaseAllocationExpression.java

License:Open Source License

private boolean internalCheckGenerate(BlockScope scope) {
    if (scope == null)
        return false;
    ReferenceContext referenceContext = scope.methodScope().referenceContext;
    if (!(referenceContext instanceof AbstractMethodDeclaration)) {
        scope.problemReporter().baseConstructorCallInWrongMethod(this, referenceContext);
        return false;
    }/* www.j  av  a  2 s. c  om*/
    AbstractMethodDeclaration enclosingMethodDeclaration = (AbstractMethodDeclaration) referenceContext;
    if (!enclosingMethodDeclaration.ignoreFurtherInvestigation) {
        createAst(scope);
        return this.expression != null;
    }
    return false;
}

From source file:org.eclipse.objectteams.otdt.internal.core.compiler.ast.BaseAllocationExpression.java

License:Open Source License

public TypeBinding resolveType(BlockScope scope) {
    TypeDeclaration roleDecl = scope.referenceType();
    if (roleDecl != null && roleDecl.isRole() && roleDecl.getRoleModel()._playedByEnclosing) {
        scope.problemReporter().baseAllocationDespiteBaseclassCycle(this, roleDecl);
        return null;
    }/*w  w  w . j  a v  a2s .c o  m*/
    if (!checkGenerate(scope)) { // createAst failed.
        return null;
    }
    if (this.isExpression) // don't treat as assignment
        return this.resolvedType = this.expression.resolveType(scope);
    if (!scope.methodScope().referenceContext.hasErrors())
        return super.resolveType(scope);
    return null;
}

From source file:org.eclipse.objectteams.otdt.internal.core.compiler.ast.BaseCallMessageSend.java

License:Open Source License

public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) {
    flowInfo = super.analyseCode(currentScope, flowContext, flowInfo);
    MethodDeclaration callinMethod = getEnclosingCallinMethod(currentScope);
    LocalVariableBinding trackingVariable = callinMethod.baseCallTrackingVariable.binding;
    if (flowInfo.isDefinitelyAssigned(callinMethod.baseCallTrackingVariable))
        currentScope.problemReporter().definitelyDuplicateBasecall(this._wrappee);
    else if (flowInfo.isPotentiallyAssigned(trackingVariable))
        currentScope.problemReporter().potentiallyDuplicateBasecall(this._wrappee);
    else/*w  w w  .  jav a  2s  . co m*/
        flowInfo.markAsDefinitelyAssigned(trackingVariable);

    // check exceptions thrown by any bound base method:
    MethodScope methodScope = currentScope.methodScope();
    if (methodScope != null) {
        MethodModel methodModel = methodScope.referenceMethod().binding.model;
        if (methodModel != null && methodModel._baseExceptions != null) {
            for (ReferenceBinding exceptionType : methodModel._baseExceptions)
                flowContext.checkExceptionHandlers(exceptionType, this, flowInfo, currentScope);
        }
    }

    if (this.isSuperAccess)
        //    signal that the base call surrogate needs to handle super-access:
        MethodModel.addCallinFlag(currentScope.methodScope().referenceMethod(),
                IOTConstants.CALLIN_FLAG_BASE_SUPER_CALL);

    return flowInfo;
}

From source file:org.eclipse.objectteams.otdt.internal.core.compiler.ast.BaseCallMessageSend.java

License:Open Source License

private void resolveSyntheticBaseCallSurrogate(MethodDeclaration outerCallinMethod, BlockScope scope,
        WeavingScheme weavingScheme) {// w ww . java2s  .  co m
    // find the method:
    AbstractMethodDeclaration callinMethodDecl = outerCallinMethod;
    if (callinMethodDecl == null) {
        if (checkContext(scope)) {
            callinMethodDecl = scope.methodScope().referenceMethod();
        } else {
            return; // error reported by checkContext
        }
    }
    MethodBinding callinMethod = callinMethodDecl.binding;
    if (callinMethod == null) {
        if (callinMethodDecl.ignoreFurtherInvestigation)
            return;
        throw new InternalCompilerError("Unresolved method without an error"); //$NON-NLS-1$
    }
    // check name match:
    if (!CharOperation.equals(this._sendOrig.selector, callinMethod.selector))
        scope.problemReporter().baseCallNotSameMethod(callinMethodDecl, this._sendOrig);

    // find the receiver type:
    this._receiver.resolve(scope);
    int depth = 0;
    while (this._receiver.resolvedType.isLocalType()) {
        this._receiver.resolvedType = this._receiver.resolvedType.enclosingType();
        depth++;
    }
    this._receiver.bits |= depth << DepthSHIFT;
    if (this._receiver.resolvedType instanceof ReferenceBinding) {
        ReferenceBinding receiverType = (ReferenceBinding) this._receiver.resolvedType;
        this._receiver.resolvedType = receiverType.getRealClass();
    }

    // resolve arguments:
    TypeBinding[] sendparams = new TypeBinding[this._sendOrig.arguments.length];
    for (int i = 0; i < sendparams.length; i++)
        sendparams[i] = this._sendOrig.arguments[i].resolveType(scope);

    // check arguments:
    int sourceArgsLen = 0;
    if (this.sourceArgs != null)
        sourceArgsLen = this.sourceArgs.length;
    TypeBinding[] methodParams = callinMethod.getSourceParameters();
    if (sourceArgsLen != methodParams.length) {
        scope.problemReporter().baseCallDoesntMatchRoleMethodSignature(this);
    } else {
        for (int i = 0; i < sourceArgsLen; i++) {
            TypeBinding srcArgType = this.sourceArgs[i].resolvedType;
            if (srcArgType == null) {
                if (!callinMethodDecl.hasErrors())
                    throw new InternalCompilerError(
                            "Unexpected: srcArgType should only ever be missing in declarations with reported errors"); //$NON-NLS-1$
                continue;
            }
            if (!srcArgType.isCompatibleWith(methodParams[i])) {
                if (isBoxingCompatible(srcArgType, methodParams[i], this.sourceArgs[i], scope)) {
                    int enhancedArgIdx = i + MethodSignatureEnhancer.getEnhancingArgLen(weavingScheme) + 1; // normal enhancement plus isSuperAccess flag
                    this._sendOrig.arguments[enhancedArgIdx].computeConversion(scope, methodParams[i],
                            srcArgType);
                } else {
                    scope.problemReporter().baseCallDoesntMatchRoleMethodSignature(this);
                    break;
                }
            }
        }
    }

    // create and link the synthetic method binding:
    MethodBinding surrogate = null;
    MethodModel model = callinMethod.model;
    if (model != null)
        surrogate = model.getBaseCallSurrogate();
    if (surrogate == null) {
        SourceTypeBinding receiverClass = ((SourceTypeBinding) ((ReferenceBinding) this._receiver.resolvedType)
                .getRealClass());
        if (SyntheticBaseCallSurrogate.isBindingForCallinMethodInherited(callinMethod)) {
            ReferenceBinding currentRole = callinMethod.declaringClass;
            while (surrogate == null && ((currentRole = currentRole.superclass()) != null)) {
                surrogate = receiverClass
                        .getExactMethod(SyntheticBaseCallSurrogate.genSurrogateName(this.sourceSelector,
                                currentRole.sourceName(), callinMethod.isStatic()), sendparams, null);
            }
        } else {
            surrogate = receiverClass.addSyntheticBaseCallSurrogate(callinMethod);
        }
    }
    this._sendOrig.binding = surrogate;
    this._sendOrig.actualReceiverType = this._receiver.resolvedType;
    this._sendOrig.constant = Constant.NotAConstant;
    this.resolvedType = this._sendOrig.resolvedType = MethodModel.getReturnType(this._sendOrig.binding);
}

From source file:org.eclipse.objectteams.otdt.internal.core.compiler.ast.BaseCallMessageSend.java

License:Open Source License

private boolean checkContext(BlockScope scope) {
    if (scope.methodScope() == null
            || !(scope.methodScope().referenceContext instanceof AbstractMethodDeclaration)) // initializer
    {//from www  .  j  a v  a2s . c o  m
        scope.problemReporter().baseCallOutsideMethod(this);
        return false;
    }

    AbstractMethodDeclaration methodDecl = (AbstractMethodDeclaration) scope.methodScope().referenceContext;
    // base call only allowed in callin methods:
    if ((methodDecl.modifiers & ExtraCompilerModifiers.AccCallin) == 0) {
        scope.problemReporter().basecallInRegularMethod(this, methodDecl);
        return false;
    }
    return true;
}

From source file:org.eclipse.objectteams.otdt.internal.core.compiler.ast.LiftingTypeReference.java

License:Open Source License

@Override
public TypeBinding resolveType(BlockScope scope, boolean checkBounds) {
    TypeBinding baseType = this.resolvedType = this.baseReference.resolveType(scope);
    if (this.roleReference.getTypeName().length > 1) {
        scope.problemReporter().qualifiedLiftingType(this.roleReference, scope.enclosingSourceType());
        return invalidate(baseType);
    }//from ww  w  .ja v  a  2 s .  c o m
    TypeBinding roleType = this.roleReference.resolveType(scope);
    if (scope.kind != Scope.BLOCK_SCOPE) { // not a catch block?
        if (!TeamModel.isAnyTeam(scope.enclosingSourceType())) {
            scope.problemReporter().liftingTypeNotAllowedHere(scope.methodScope().referenceContext, this);
            return invalidate(roleType);
        }
    }
    if (baseType == null || baseType instanceof MissingTypeBinding)
        return invalidate(roleType);
    if (roleType == null || roleType instanceof MissingTypeBinding)
        return invalidate(baseType);
    if (roleType.isArrayType()) {
        baseType = baseType.leafComponentType();
        roleType = roleType.leafComponentType();
    }
    if (roleType.isBaseType()) {
        scope.problemReporter().primitiveTypeNotAllowedForLifting(scope.referenceType(), this.roleReference,
                roleType);
        return invalidate(roleType);
    }
    if (baseType.isBaseType()) {
        scope.problemReporter().primitiveTypeNotAllowedForLifting(scope.referenceType(), this.baseReference,
                baseType);
        return invalidate(roleType);
    }

    ReferenceBinding roleRefType = (ReferenceBinding) roleType;
    if (!roleRefType.isValidBinding()) // already reported.
        return invalidate(roleType);

    if (!roleRefType.isDirectRole()) {
        scope.problemReporter().needRoleInLiftingType(scope.referenceType(), this.roleReference, roleType);
        return invalidate(roleType);
    }
    if (roleRefType.isSynthInterface())
        roleRefType = roleRefType.getRealClass();

    if (roleRefType.roleModel.hasBaseclassProblem()) {// already reported for the role class.
        scope.referenceContext().tagAsHavingErrors(); // -> mark method as erroneous, too.
        return invalidate(roleType);
    }

    // TODO (SH): maybe look for bound sub-type?
    // Note (SH): calling baseclass() requires STATE_LENV_DONE_FIELDS_AND_METHODS:
    Dependencies.ensureBindingState(roleRefType, ITranslationStates.STATE_LENV_DONE_FIELDS_AND_METHODS);

    if (baseType.isTypeVariable() && ((TypeVariableBinding) baseType).roletype != null) {
        // resolving "<B base R> as R":
        roleRefType = ((TypeVariableBinding) baseType).roletype;
        // ambiguity is handled by _OT$lift_dynamic which may or may not declare LiftingFailedException
    } else if ((baseType.tagBits & TagBits.HierarchyHasProblems) != 0) {
        // already reported (?)
    } else {
        // static adjustment (OTJLD 2.3.2(a)):
        roleRefType = (ReferenceBinding) TeamModel.getRoleToLiftTo(scope, baseType, roleRefType, true, this);
        if (roleRefType == null)
            roleRefType = (ReferenceBinding) roleType; // revert unsuccessful adjustment
        if (roleRefType.baseclass() == null
                || RoleModel.hasTagBit(roleRefType, RoleModel.BaseclassHasProblems)) {
            scope.problemReporter().roleNotBoundCantLift(scope.referenceType(), this.roleReference, roleType);
            return invalidate(roleType);
        }
        if (baseType.isRole()) // see http://trac.objectteams.org/ot/ticket/73
            baseType = RoleTypeCreator.maybeWrapUnqualifiedRoleType(baseType, scope.enclosingReceiverType());
        if (baseType == null)
            return invalidate(roleType);
        Config oldConfig = Config.createOrResetConfig(this);
        try {
            // fetch role's base class and perform substitutions:
            ReferenceBinding roleBase = roleRefType.baseclass();
            if (roleType.isParameterizedType()) {
                ParameterizedTypeBinding parameterizedRole = (ParameterizedTypeBinding) roleType;
                TypeBinding[] typeArgs = parameterizedRole.arguments;
                ITeamAnchor anchor = null;
                if (roleRefType.baseclass() instanceof RoleTypeBinding)
                    anchor = ((RoleTypeBinding) roleRefType.baseclass())._teamAnchor;
                roleBase = parameterizedRole.environment.createParameterizedType(
                        (ReferenceBinding) roleBase.original(), typeArgs, anchor, -1, roleBase.enclosingType(),
                        roleBase.getTypeAnnotations());
            }
            // THE compatibility check:
            if (!baseType.isCompatibleWith(roleBase) || Config.getLoweringRequired()) {
                scope.problemReporter().incompatibleBaseForRole(scope.referenceType(), this, roleType,
                        baseType);
                return invalidate(roleType);
            }
        } finally {
            Config.removeOrRestore(oldConfig, this);
        }
    }
    return this.resolvedType;
}

From source file:org.eclipse.objectteams.otdt.internal.core.compiler.ast.LiftingTypeReference.java

License:Open Source License

public void updateBindingAndCheckNullness(BlockScope scope) {
    this.baseReference.resolvedType = this.resolvedType;
    TypeBinding roleType = this.roleReference.resolvedType;
    if (roleType != null && roleType.isValidBinding()
            && scope.compilerOptions().isAnnotationBasedNullAnalysisEnabled) {
        NullAnnotationMatching status = NullAnnotationMatching.analyse(roleType, this.resolvedType, -1);
        if (status.isAnyMismatch()) {
            scope.problemReporter().nullityMismatchingTypeAnnotation(this.fakedArgument.initialization,
                    this.resolvedType, roleType, status);
        }//from  ww  w.ja  v  a 2 s . c om
    }
}