Java Code Examples for com.sun.tools.javac.code.Type.UndetVar#substBounds()

The following examples show how to use com.sun.tools.javac.code.Type.UndetVar#substBounds() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InferenceContext.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Instantiate inference variables in legacy mode (JLS 15.12.2.7, 15.12.2.8).
 * During overload resolution, instantiation is done by doing a partial
 * inference process using eq/lower bound instantiation. During check,
 * we also instantiate any remaining vars by repeatedly using eq/upper
 * instantiation, until all variables are solved.
 */
public void solveLegacy(boolean partial, Warner warn, EnumSet<InferenceStep> steps) {
    while (true) {
        List<Type> solvedVars = solveBasic(steps);
        if (restvars().isEmpty() || partial) {
            //all variables have been instantiated - exit
            break;
        } else if (solvedVars.isEmpty()) {
            //some variables could not be instantiated because of cycles in
            //upper bounds - provide a (possibly recursive) default instantiation
            infer.instantiateAsUninferredVars(restvars(), this);
            break;
        } else {
            //some variables have been instantiated - replace newly instantiated
            //variables in remaining upper bounds and continue
            for (Type t : undetvars) {
                UndetVar uv = (UndetVar)t;
                uv.substBounds(solvedVars, asInstTypes(solvedVars), types);
            }
        }
    }
    infer.doIncorporation(this, warn);
}
 
Example 2
Source File: InferenceContext.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Instantiate inference variables in legacy mode (JLS 15.12.2.7, 15.12.2.8).
 * During overload resolution, instantiation is done by doing a partial
 * inference process using eq/lower bound instantiation. During check,
 * we also instantiate any remaining vars by repeatedly using eq/upper
 * instantiation, until all variables are solved.
 */
public void solveLegacy(boolean partial, Warner warn, EnumSet<InferenceStep> steps) {
    while (true) {
        List<Type> solvedVars = solveBasic(steps);
        if (restvars().isEmpty() || partial) {
            //all variables have been instantiated - exit
            break;
        } else if (solvedVars.isEmpty()) {
            //some variables could not be instantiated because of cycles in
            //upper bounds - provide a (possibly recursive) default instantiation
            infer.instantiateAsUninferredVars(restvars(), this);
            break;
        } else {
            //some variables have been instantiated - replace newly instantiated
            //variables in remaining upper bounds and continue
            for (Type t : undetvars) {
                UndetVar uv = (UndetVar)t;
                uv.substBounds(solvedVars, asInstTypes(solvedVars), types);
            }
        }
    }
    infer.doIncorporation(this, warn);
}
 
Example 3
Source File: Infer.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
void apply(InferenceContext inferenceContext, Warner warn) {
    for (Type undet : inferenceContext.undetvars) {
        //we could filter out variables not mentioning uv2...
        UndetVar uv2 = (UndetVar)undet;
        uv2.substBounds(List.of(uv.qtype), List.of(uv.getInst()), types);
        checkCompatibleUpperBounds(uv2, inferenceContext);
    }
    super.apply(inferenceContext, warn);
}