com.sun.tools.javac.code.Types.containsType()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(6.3k)|赞(0)|评价(0)|浏览(132)

本文整理了Java中com.sun.tools.javac.code.Types.containsType()方法的一些代码示例,展示了Types.containsType()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Types.containsType()方法的具体详情如下:
包路径:com.sun.tools.javac.code.Types
类名称:Types
方法名:containsType

Types.containsType介绍

[英]Check if t contains s.

T contains S if:

L(T) This relation is only used by ClassType.isSubtype(), that is,

C if T contains S.

Because of F-bounds, this relation can lead to infinite recursion. Thus we must somehow break that recursion. Notice that containsType() is only called from ClassType.isSubtype(). Since the arguments have already been checked against their bounds, we know:

U(S) L(T)
[中]检查t是否包含s。
如果:
L(T)此关系仅由类类型使用。isSubtype(),即,
如果T包含S。
由于F-界,这种关系可能导致无限递归。因此,我们必须以某种方式打破这种循环。请注意,containsType()仅从类类型调用。isSubtype()。由于参数已经根据其界限进行了检查,我们知道:
U(S)L(T)

代码示例

代码示例来源:origin: org.jvnet.sorcerer/sorcerer-javac

private boolean containsTypeEquivalent(Type t, Type s) {
  return
    isSameType(t, s) || // shortcut
    containsType(t, s) && containsType(s, t);
}

代码示例来源:origin: sc.fiji/javac

private boolean containsTypeEquivalent(Type t, Type s) {
  return
    isSameType(t, s) || // shortcut
    containsType(t, s) && containsType(s, t);
}

代码示例来源:origin: konsoletyper/teavm-javac

private boolean containsTypeEquivalent(Type t, Type s) {
  return
    isSameType(t, s) || // shortcut
    containsType(t, s) && containsType(s, t);
}

代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac

private boolean containsTypeEquivalent(Type t, Type s) {
  return
    isSameType(t, s) || // shortcut
    containsType(t, s) && containsType(s, t);
}

代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac

public boolean contains(TypeMirror t1, TypeMirror t2) {
  validateTypeNotIn(t1, EXEC_OR_PKG);
  validateTypeNotIn(t2, EXEC_OR_PKG);
  return types.containsType((Type) t1, (Type) t2);
}

代码示例来源:origin: konsoletyper/teavm-javac

public boolean contains(TypeMirror t1, TypeMirror t2) {
  validateTypeNotIn(t1, EXEC_OR_PKG);
  validateTypeNotIn(t2, EXEC_OR_PKG);
  return types.containsType((Type) t1, (Type) t2);
}

代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac

private boolean containsTypeRecursive(Type t, Type s) {
  TypePair pair = new TypePair(t, s);
  if (cache.add(pair)) {
    try {
      return containsType(t.getTypeArguments(),
                s.getTypeArguments());
    } finally {
      cache.remove(pair);
    }
  } else {
    return containsType(t.getTypeArguments(),
              rewriteSupers(s).getTypeArguments());
  }
}

代码示例来源:origin: sc.fiji/javac

private boolean containsTypeRecursive(Type t, Type s) {
  TypePair pair = new TypePair(t, s);
  if (cache.add(pair)) {
    try {
      return containsType(t.getTypeArguments(),
                s.getTypeArguments());
    } finally {
      cache.remove(pair);
    }
  } else {
    return containsType(t.getTypeArguments(),
              rewriteSupers(s).getTypeArguments());
  }
}

代码示例来源:origin: konsoletyper/teavm-javac

private boolean containsTypeRecursive(Type t, Type s) {
  TypePair pair = new TypePair(t, s);
  if (cache.add(pair)) {
    try {
      return containsType(t.getTypeArguments(),
                s.getTypeArguments());
    } finally {
      cache.remove(pair);
    }
  } else {
    return containsType(t.getTypeArguments(),
              rewriteSupers(s).getTypeArguments());
  }
}

代码示例来源:origin: org.jvnet.sorcerer/sorcerer-javac

private boolean containsTypeRecursive(Type t, Type s) {
  TypePair pair = new TypePair(t, s);
  if (cache.add(pair)) {
    try {
      return containsType(t.getTypeArguments(),
                s.getTypeArguments());
    } finally {
      cache.remove(pair);
    }
  } else {
    return containsType(t.getTypeArguments(),
              rewriteSupers(s).getTypeArguments());
  }
}

代码示例来源:origin: sc.fiji/javac

private boolean giveWarning(Type from, Type to) {
  // To and from are (possibly different) parameterizations
  // of the same class or interface
  return to.isParameterized() && !containsType(to.getTypeArguments(), from.getTypeArguments());
}

代码示例来源:origin: org.jvnet.sorcerer/sorcerer-javac

private boolean giveWarning(Type from, Type to) {
  // To and from are (possibly different) parameterizations
  // of the same class or interface
  return to.isParameterized() && !containsType(to.getTypeArguments(), from.getTypeArguments());
}

代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac

boolean containsType(List<Type> ts, List<Type> ss) {
  while (ts.nonEmpty() && ss.nonEmpty()
      && containsType(ts.head, ss.head)) {
    ts = ts.tail;
    ss = ss.tail;
  }
  return ts.isEmpty() && ss.isEmpty();
}

代码示例来源:origin: org.jvnet.sorcerer/sorcerer-javac

boolean containsType(List<Type> ts, List<Type> ss) {
  while (ts.nonEmpty() && ss.nonEmpty()
      && containsType(ts.head, ss.head)) {
    ts = ts.tail;
    ss = ss.tail;
  }
  return ts.isEmpty() && ss.isEmpty();
}

代码示例来源:origin: konsoletyper/teavm-javac

boolean containsType(List<Type> ts, List<Type> ss) {
  while (ts.nonEmpty() && ss.nonEmpty()
      && containsType(ts.head, ss.head)) {
    ts = ts.tail;
    ss = ss.tail;
  }
  return ts.isEmpty() && ss.isEmpty();
}

代码示例来源:origin: sc.fiji/javac

boolean containsType(List<Type> ts, List<Type> ss) {
  while (ts.nonEmpty() && ss.nonEmpty()
      && containsType(ts.head, ss.head)) {
    ts = ts.tail;
    ss = ss.tail;
  }
  return ts.isEmpty() && ss.isEmpty();
}

代码示例来源:origin: sc.fiji/javac

@Override
  public Boolean visitClassType(ClassType t, Void ignored) {
    List<Type> parms = t.tsym.type.allparams();
    List<Type> args = t.allparams();
    while (parms.nonEmpty()) {
      WildcardType unb = new WildcardType(syms.objectType,
                        BoundKind.UNBOUND,
                        syms.boundClass,
                        (TypeVar)parms.head);
      if (!containsType(args.head, unb))
        return false;
      parms = parms.tail;
      args = args.tail;
    }
    return true;
  }
};

代码示例来源:origin: konsoletyper/teavm-javac

@Override
  public Boolean visitClassType(ClassType t, Void ignored) {
    List<Type> parms = t.tsym.type.allparams();
    List<Type> args = t.allparams();
    while (parms.nonEmpty()) {
      WildcardType unb = new WildcardType(syms.objectType,
                        BoundKind.UNBOUND,
                        syms.boundClass,
                        (TypeVar)parms.head.unannotatedType());
      if (!containsType(args.head, unb))
        return false;
      parms = parms.tail;
      args = args.tail;
    }
    return true;
  }
};

代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac

private boolean giveWarning(Type from, Type to) {
  List<Type> bounds = to.isCompound() ?
      ((IntersectionClassType)to.unannotatedType()).getComponents() : List.of(to);
  for (Type b : bounds) {
    Type subFrom = asSub(from, b.tsym);
    if (b.isParameterized() &&
        (!(isUnbounded(b) ||
        isSubtype(from, b) ||
        ((subFrom != null) && containsType(b.allparams(), subFrom.allparams()))))) {
      return true;
    }
  }
  return false;
}

代码示例来源:origin: konsoletyper/teavm-javac

private boolean giveWarning(Type from, Type to) {
  List<Type> bounds = to.isCompound() ?
      ((IntersectionClassType)to.unannotatedType()).getComponents() : List.of(to);
  for (Type b : bounds) {
    Type subFrom = asSub(from, b.tsym);
    if (b.isParameterized() &&
        (!(isUnbounded(b) ||
        isSubtype(from, b) ||
        ((subFrom != null) && containsType(b.allparams(), subFrom.allparams()))))) {
      return true;
    }
  }
  return false;
}

相关文章

Types类方法