Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8199452

[lworld] Check#checkRefType is too strict and forbids various legitimate operations on value classes

XMLWordPrintable

    • generic
    • generic

      com.sun.tools.javac.comp.Check#checkRefType(com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition, com.sun.tools.javac.code.Type)

      as it stands on lworld branch tip reads:

      if (t.isReference() && !types.isValue(t))
          return t;
      else
          return typeTagError(pos,
                                      diags.fragment(Fragments.TypeReqRef),
                                      t);

      This code was carried over from the original valhalla prototype, where values were rooted at a point other than j.l.O and so such forbiddance made sense. (values cannot be type arguments unless a class was anyfied)

      As it stands it forbids various operations on value types that are legitimate in the lworld such as:

          - Value types can be type arguments in generic type parameterizations.
          - Value types can be explicit type witnesses in generic method invocations
          - Value types can be wildcard bounds (even if only with limited utility on account of being final classes - a la String)
          - Value types can be intersection (cast) type components
          - Value instances can be enclosing instances.

      (Whether values should be restricted to top level classes, or can also be
      inner local nested is an open design question - but javac already supports
      them as non-top level classes also, but that support is partial and broken in ways that will be addressed by a fix to this ticket)

            sadayapalam Srikanth Adayapalam (Inactive)
            sadayapalam Srikanth Adayapalam (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: