8267578: Remove unnecessary preview checks

Reviewed-by: jlahoda
This commit is contained in:
Guoxiong Li 2021-05-24 12:31:21 +00:00 committed by Jan Lahoda
parent 49f622c947
commit f4531661b5
3 changed files with 3 additions and 10 deletions

View File

@ -167,9 +167,7 @@ public class Attr extends JCTree.Visitor {
allowLambda = Feature.LAMBDA.allowedInSource(source);
allowDefaultMethods = Feature.DEFAULT_METHODS.allowedInSource(source);
allowStaticInterfaceMethods = Feature.STATIC_INTERFACE_METHODS.allowedInSource(source);
allowReifiableTypesInInstanceof =
Feature.REIFIABLE_TYPES_INSTANCEOF.allowedInSource(source) &&
(!preview.isPreview(Feature.REIFIABLE_TYPES_INSTANCEOF) || preview.isEnabled());
allowReifiableTypesInInstanceof = Feature.REIFIABLE_TYPES_INSTANCEOF.allowedInSource(source);
allowRecords = Feature.RECORDS.allowedInSource(source);
sourceName = source.name;
useBeforeDeclarationWarning = options.isSet("useBeforeDeclarationWarning");
@ -3996,9 +3994,6 @@ public class Attr extends JCTree.Visitor {
if (!clazztype.isErroneous() && !types.isReifiable(clazztype)) {
boolean valid = false;
if (allowReifiableTypesInInstanceof) {
if (preview.isPreview(Feature.REIFIABLE_TYPES_INSTANCEOF)) {
preview.warnPreview(tree.expr.pos(), Feature.REIFIABLE_TYPES_INSTANCEOF);
}
Warner warner = new Warner();
if (!types.isCastable(exprtype, clazztype, warner)) {
chk.basicHandler.report(tree.expr.pos(),

View File

@ -146,8 +146,7 @@ public class Resolve {
Target target = Target.instance(context);
allowFunctionalInterfaceMostSpecific = Feature.FUNCTIONAL_INTERFACE_MOST_SPECIFIC.allowedInSource(source);
allowLocalVariableTypeInference = Feature.LOCAL_VARIABLE_TYPE_INFERENCE.allowedInSource(source);
allowYieldStatement = (!preview.isPreview(Feature.SWITCH_EXPRESSION) || preview.isEnabled()) &&
Feature.SWITCH_EXPRESSION.allowedInSource(source);
allowYieldStatement = Feature.SWITCH_EXPRESSION.allowedInSource(source);
checkVarargsAccessAfterResolution =
Feature.POST_APPLICABILITY_VARARGS_ACCESS_CHECK.allowedInSource(source);
polymorphicSignatureScope = WriteableScope.create(syms.noSymbol);

View File

@ -183,8 +183,7 @@ public class JavacParser implements Parser {
this.keepLineMap = keepLineMap;
this.errorTree = F.Erroneous();
endPosTable = newEndPosTable(keepEndPositions);
this.allowYieldStatement = (!preview.isPreview(Feature.SWITCH_EXPRESSION) || preview.isEnabled()) &&
Feature.SWITCH_EXPRESSION.allowedInSource(source);
this.allowYieldStatement = Feature.SWITCH_EXPRESSION.allowedInSource(source);
this.allowRecords = Feature.RECORDS.allowedInSource(source);
this.allowSealedTypes = Feature.SEALED_CLASSES.allowedInSource(source);
}