src/share/classes/com/sun/tools/javac/code/Type.java

changeset 396
dda7e13f09fb
parent 299
22872b24d38c
child 404
14735c7932d7
     1.1 --- a/src/share/classes/com/sun/tools/javac/code/Type.java	Mon Aug 31 19:43:06 2009 -0700
     1.2 +++ b/src/share/classes/com/sun/tools/javac/code/Type.java	Tue Sep 01 14:53:39 2009 +0100
     1.3 @@ -1068,7 +1068,7 @@
     1.4  
     1.5          /**
     1.6           * Replaces this ForAll's typevars with a set of concrete Java types
     1.7 -         * and returns the instantiated generic type. Subclasses might override
     1.8 +         * and returns the instantiated generic type. Subclasses should override
     1.9           * in order to check that the list of types is a valid instantiation
    1.10           * of the ForAll's typevars.
    1.11           *
    1.12 @@ -1081,6 +1081,42 @@
    1.13              return types.subst(qtype, tvars, actuals);
    1.14          }
    1.15  
    1.16 +        /**
    1.17 +         * Kind of type-constraint derived during type inference
    1.18 +         */
    1.19 +        public enum ConstraintKind {
    1.20 +            /**
    1.21 +             * upper bound constraint (a type variable must be instantiated
    1.22 +             * with a type T, where T is a subtype of all the types specified by
    1.23 +             * its EXTENDS constraints).
    1.24 +             */
    1.25 +            EXTENDS,
    1.26 +            /**
    1.27 +             * lower bound constraint (a type variable must be instantiated
    1.28 +             * with a type T, where T is a supertype of all the types specified by
    1.29 +             * its SUPER constraints).
    1.30 +             */
    1.31 +            SUPER,
    1.32 +            /**
    1.33 +             * equality constraint (a type variable must be instantiated to the type
    1.34 +             * specified by its EQUAL constraint.
    1.35 +             */
    1.36 +            EQUAL;
    1.37 +        }
    1.38 +
    1.39 +        /**
    1.40 +         * Get the type-constraints of a given kind for a given type-variable of
    1.41 +         * this ForAll type. Subclasses should override in order to return more
    1.42 +         * accurate sets of constraints.
    1.43 +         *
    1.44 +         * @param tv the type-variable for which the constraint is to be retrieved
    1.45 +         * @param ck the constraint kind to be retrieved
    1.46 +         * @return the list of types specified by the selected constraint
    1.47 +         */
    1.48 +        public List<Type> getConstraints(TypeVar tv, ConstraintKind ck) {
    1.49 +            return List.nil();
    1.50 +        }
    1.51 +
    1.52          public Type map(Mapping f) {
    1.53              return f.apply(qtype);
    1.54          }

mercurial