4161
4162 AccessError(Env<AttrContext> env, Type site, Symbol sym) {
4163 super(HIDDEN, sym, "access error");
4164 this.env = env;
4165 this.site = site;
4166 }
4167
4168 @Override
4169 public boolean exists() {
4170 return false;
4171 }
4172
4173 @Override
4174 JCDiagnostic getDiagnostic(JCDiagnostic.DiagnosticType dkind,
4175 DiagnosticPosition pos,
4176 Symbol location,
4177 Type site,
4178 Name name,
4179 List<Type> argtypes,
4180 List<Type> typeargtypes) {
4181 if (sym.owner.type.hasTag(ERROR))
4182 return null;
4183
4184 if (sym.name == names.init && sym.owner != site.tsym) {
4185 return new SymbolNotFoundError(ABSENT_MTH).getDiagnostic(dkind,
4186 pos, location, site, name, argtypes, typeargtypes);
4187 }
4188 else if ((sym.flags() & PUBLIC) != 0
4189 || (env != null && this.site != null
4190 && !isAccessible(env, this.site))) {
4191 if (sym.owner.kind == PCK) {
4192 return diags.create(dkind, log.currentSource(),
4193 pos, "not.def.access.package.cant.access",
4194 sym, sym.location(), inaccessiblePackageReason(env, sym.packge()));
4195 } else if ( sym.packge() != syms.rootPackage
4196 && !symbolPackageVisible(env, sym)) {
4197 return diags.create(dkind, log.currentSource(),
4198 pos, "not.def.access.class.intf.cant.access.reason",
4199 sym, sym.location(), sym.location().packge(),
4200 inaccessiblePackageReason(env, sym.packge()));
4201 } else {
4202 return diags.create(dkind, log.currentSource(),
4203 pos, "not.def.access.class.intf.cant.access",
|
4161
4162 AccessError(Env<AttrContext> env, Type site, Symbol sym) {
4163 super(HIDDEN, sym, "access error");
4164 this.env = env;
4165 this.site = site;
4166 }
4167
4168 @Override
4169 public boolean exists() {
4170 return false;
4171 }
4172
4173 @Override
4174 JCDiagnostic getDiagnostic(JCDiagnostic.DiagnosticType dkind,
4175 DiagnosticPosition pos,
4176 Symbol location,
4177 Type site,
4178 Name name,
4179 List<Type> argtypes,
4180 List<Type> typeargtypes) {
4181 if (sym.name == names.init && sym.owner != site.tsym) {
4182 return new SymbolNotFoundError(ABSENT_MTH).getDiagnostic(dkind,
4183 pos, location, site, name, argtypes, typeargtypes);
4184 }
4185 else if ((sym.flags() & PUBLIC) != 0
4186 || (env != null && this.site != null
4187 && !isAccessible(env, this.site))) {
4188 if (sym.owner.kind == PCK) {
4189 return diags.create(dkind, log.currentSource(),
4190 pos, "not.def.access.package.cant.access",
4191 sym, sym.location(), inaccessiblePackageReason(env, sym.packge()));
4192 } else if ( sym.packge() != syms.rootPackage
4193 && !symbolPackageVisible(env, sym)) {
4194 return diags.create(dkind, log.currentSource(),
4195 pos, "not.def.access.class.intf.cant.access.reason",
4196 sym, sym.location(), sym.location().packge(),
4197 inaccessiblePackageReason(env, sym.packge()));
4198 } else {
4199 return diags.create(dkind, log.currentSource(),
4200 pos, "not.def.access.class.intf.cant.access",
|