250 || |
250 || |
251 !((base == null || |
251 !((base == null || |
252 (base.getTag() == JCTree.IDENT && TreeInfo.name(base) == names._this)) && |
252 (base.getTag() == JCTree.IDENT && TreeInfo.name(base) == names._this)) && |
253 isAssignableAsBlankFinal(v, env)))) { |
253 isAssignableAsBlankFinal(v, env)))) { |
254 if (v.isResourceVariable()) { //TWR resource |
254 if (v.isResourceVariable()) { //TWR resource |
255 log.error(pos, "twr.resource.may.not.be.assigned", v); |
255 log.error(pos, "try.resource.may.not.be.assigned", v); |
256 } else { |
256 } else { |
257 log.error(pos, "cant.assign.val.to.final.var", v); |
257 log.error(pos, "cant.assign.val.to.final.var", v); |
258 } |
258 } |
259 } else if ((v.flags() & EFFECTIVELY_FINAL) != 0) { |
259 } else if ((v.flags() & EFFECTIVELY_FINAL) != 0) { |
260 v.flags_field &= ~EFFECTIVELY_FINAL; |
260 v.flags_field &= ~EFFECTIVELY_FINAL; |
1043 localEnv; |
1043 localEnv; |
1044 // Attribute resource declarations |
1044 // Attribute resource declarations |
1045 for (JCTree resource : tree.resources) { |
1045 for (JCTree resource : tree.resources) { |
1046 if (resource.getTag() == JCTree.VARDEF) { |
1046 if (resource.getTag() == JCTree.VARDEF) { |
1047 attribStat(resource, tryEnv); |
1047 attribStat(resource, tryEnv); |
1048 chk.checkType(resource, resource.type, syms.autoCloseableType, "twr.not.applicable.to.type"); |
1048 chk.checkType(resource, resource.type, syms.autoCloseableType, "try.not.applicable.to.type"); |
1049 VarSymbol var = (VarSymbol)TreeInfo.symbolFor(resource); |
1049 VarSymbol var = (VarSymbol)TreeInfo.symbolFor(resource); |
1050 var.setData(ElementKind.RESOURCE_VARIABLE); |
1050 var.setData(ElementKind.RESOURCE_VARIABLE); |
1051 } else { |
1051 } else { |
1052 attribExpr(resource, tryEnv, syms.autoCloseableType, "twr.not.applicable.to.type"); |
1052 attribExpr(resource, tryEnv, syms.autoCloseableType, "try.not.applicable.to.type"); |
1053 } |
1053 } |
1054 } |
1054 } |
1055 // Attribute body |
1055 // Attribute body |
1056 attribStat(tree.body, tryEnv); |
1056 attribStat(tree.body, tryEnv); |
1057 if (isTryWithResource) |
1057 if (isTryWithResource) |
2256 if (sitesym != null && |
2256 if (sitesym != null && |
2257 sitesym.kind == VAR && |
2257 sitesym.kind == VAR && |
2258 ((VarSymbol)sitesym).isResourceVariable() && |
2258 ((VarSymbol)sitesym).isResourceVariable() && |
2259 sym.kind == MTH && |
2259 sym.kind == MTH && |
2260 sym.overrides(syms.autoCloseableClose, sitesym.type.tsym, types, true) && |
2260 sym.overrides(syms.autoCloseableClose, sitesym.type.tsym, types, true) && |
2261 env.info.lint.isEnabled(Lint.LintCategory.ARM)) { |
2261 env.info.lint.isEnabled(Lint.LintCategory.TRY)) { |
2262 log.warning(tree, "twr.explicit.close.call"); |
2262 log.warning(Lint.LintCategory.TRY, tree, "try.explicit.close.call"); |
2263 } |
2263 } |
2264 |
2264 |
2265 // Disallow selecting a type from an expression |
2265 // Disallow selecting a type from an expression |
2266 if (isType(sym) && (sitesym==null || (sitesym.kind&(TYP|PCK)) == 0)) { |
2266 if (isType(sym) && (sitesym==null || (sitesym.kind&(TYP|PCK)) == 0)) { |
2267 tree.type = check(tree.selected, pt, |
2267 tree.type = check(tree.selected, pt, |