Android Studio抱怨我没有使用菱形运算符,但不幸的是,否则我无法构建它:
protected Pair<Boolean, Constructor<? extends ClipboardToken>> getTokenCreator(Class[] parameterTypes)
throws NoSuchMethodException {
Constructor<? extends ClipboardToken> constructor = tokenClass.getConstructor(parameterTypes);
return new Pair<Boolean, Constructor<? extends ClipboardToken>>(this.constructor == constructor, constructor);
}
如果在第4行中将其更改为菱形运算符,则会出现以下错误:
error: incompatible types: Pair<Boolean,Constructor<CAP#1>> cannot be converted to Pair<Boolean,Constructor<? extends ClipboardToken>>
return new Pair<>(this.constructor == constructor, constructor);
^
where CAP#1 is a fresh type-variable:
CAP#1 extends ClipboardToken from capture of ? extends ClipboardToken
除了忽略警告之外,我是否可以做些其他事情?