36 import com.sun.source.tree.TreeVisitor; |
36 import com.sun.source.tree.TreeVisitor; |
37 import com.sun.source.util.SimpleTreeVisitor; |
37 import com.sun.source.util.SimpleTreeVisitor; |
38 import com.sun.tools.javac.code.*; |
38 import com.sun.tools.javac.code.*; |
39 import com.sun.tools.javac.code.Lint.LintCategory; |
39 import com.sun.tools.javac.code.Lint.LintCategory; |
40 import com.sun.tools.javac.code.Scope.WriteableScope; |
40 import com.sun.tools.javac.code.Scope.WriteableScope; |
|
41 import com.sun.tools.javac.code.Source.Feature; |
41 import com.sun.tools.javac.code.Symbol.*; |
42 import com.sun.tools.javac.code.Symbol.*; |
42 import com.sun.tools.javac.code.Type.*; |
43 import com.sun.tools.javac.code.Type.*; |
43 import com.sun.tools.javac.code.TypeMetadata.Annotations; |
44 import com.sun.tools.javac.code.TypeMetadata.Annotations; |
44 import com.sun.tools.javac.code.Types.FunctionDescriptorLookupError; |
45 import com.sun.tools.javac.code.Types.FunctionDescriptorLookupError; |
45 import com.sun.tools.javac.comp.ArgumentAttr.LocalCacheContext; |
46 import com.sun.tools.javac.comp.ArgumentAttr.LocalCacheContext; |
148 argumentAttr = ArgumentAttr.instance(context); |
149 argumentAttr = ArgumentAttr.instance(context); |
149 |
150 |
150 Options options = Options.instance(context); |
151 Options options = Options.instance(context); |
151 |
152 |
152 Source source = Source.instance(context); |
153 Source source = Source.instance(context); |
153 allowStringsInSwitch = source.allowStringsInSwitch(); |
154 allowStringsInSwitch = Feature.STRINGS_IN_SWITCH.allowedInSource(source); |
154 allowPoly = source.allowPoly(); |
155 allowPoly = Feature.POLY.allowedInSource(source); |
155 allowTypeAnnos = source.allowTypeAnnotations(); |
156 allowTypeAnnos = Feature.TYPE_ANNOTATIONS.allowedInSource(source); |
156 allowLambda = source.allowLambda(); |
157 allowLambda = Feature.LAMBDA.allowedInSource(source); |
157 allowDefaultMethods = source.allowDefaultMethods(); |
158 allowDefaultMethods = Feature.DEFAULT_METHODS.allowedInSource(source); |
158 allowStaticInterfaceMethods = source.allowStaticInterfaceMethods(); |
159 allowStaticInterfaceMethods = Feature.STATIC_INTERFACE_METHODS.allowedInSource(source); |
159 sourceName = source.name; |
160 sourceName = source.name; |
160 useBeforeDeclarationWarning = options.isSet("useBeforeDeclarationWarning"); |
161 useBeforeDeclarationWarning = options.isSet("useBeforeDeclarationWarning"); |
161 |
162 |
162 statInfo = new ResultInfo(KindSelector.NIL, Type.noType); |
163 statInfo = new ResultInfo(KindSelector.NIL, Type.noType); |
163 varAssignmentInfo = new ResultInfo(KindSelector.ASG, Type.noType); |
164 varAssignmentInfo = new ResultInfo(KindSelector.ASG, Type.noType); |
1390 try { |
1391 try { |
1391 |
1392 |
1392 boolean enumSwitch = (seltype.tsym.flags() & Flags.ENUM) != 0; |
1393 boolean enumSwitch = (seltype.tsym.flags() & Flags.ENUM) != 0; |
1393 boolean stringSwitch = types.isSameType(seltype, syms.stringType); |
1394 boolean stringSwitch = types.isSameType(seltype, syms.stringType); |
1394 if (stringSwitch && !allowStringsInSwitch) { |
1395 if (stringSwitch && !allowStringsInSwitch) { |
1395 log.error(DiagnosticFlag.SOURCE_LEVEL, tree.selector.pos(), Errors.StringSwitchNotSupportedInSource(sourceName)); |
1396 log.error(DiagnosticFlag.SOURCE_LEVEL, tree.selector.pos(), Feature.STRINGS_IN_SWITCH.error(sourceName)); |
1396 } |
1397 } |
1397 if (!enumSwitch && !stringSwitch) |
1398 if (!enumSwitch && !stringSwitch) |
1398 seltype = chk.checkType(tree.selector.pos(), seltype, syms.intType); |
1399 seltype = chk.checkType(tree.selector.pos(), seltype, syms.intType); |
1399 |
1400 |
1400 // Attribute all cases and |
1401 // Attribute all cases and |
3665 tree.pos(), site, sym.name, true); |
3666 tree.pos(), site, sym.name, true); |
3666 } |
3667 } |
3667 } |
3668 } |
3668 if (!allowStaticInterfaceMethods && sitesym.isInterface() && |
3669 if (!allowStaticInterfaceMethods && sitesym.isInterface() && |
3669 sym.isStatic() && sym.kind == MTH) { |
3670 sym.isStatic() && sym.kind == MTH) { |
3670 log.error(DiagnosticFlag.SOURCE_LEVEL, tree.pos(), Errors.StaticIntfMethodInvokeNotSupportedInSource(sourceName)); |
3671 log.error(DiagnosticFlag.SOURCE_LEVEL, tree.pos(), Feature.STATIC_INTERFACE_METHODS_INVOKE.error(sourceName)); |
3671 } |
3672 } |
3672 } else if (sym.kind != ERR && |
3673 } else if (sym.kind != ERR && |
3673 (sym.flags() & STATIC) != 0 && |
3674 (sym.flags() & STATIC) != 0 && |
3674 sym.name != names._class) { |
3675 sym.name != names._class) { |
3675 // If the qualified item is not a type and the selected item is static, report |
3676 // If the qualified item is not a type and the selected item is static, report |