3434import com .sun .tools .javac .code .TypeTag ;
3535import com .sun .tools .javac .code .Types ;
3636import com .sun .tools .javac .comp .Attr .ResultInfo ;
37+ import com .sun .tools .javac .comp .Check .CheckContext ;
38+ import com .sun .tools .javac .comp .Check .NestedCheckContext ;
3739import com .sun .tools .javac .comp .DeferredAttr .AttrMode ;
3840import com .sun .tools .javac .tree .JCTree ;
3941import com .sun .tools .javac .tree .JCTree .JCBlock ;
@@ -66,6 +68,7 @@ public class AttrRecover {
6668 protected static final Context .Key <AttrRecover > attrRepairKey = new Context .Key <>();
6769
6870 final Attr attr ;
71+ final Check chk ;
6972 final DeferredAttr deferredAttr ;
7073 final Names names ;
7174 final TreeMaker make ;
@@ -84,6 +87,7 @@ protected AttrRecover(Context context) {
8487 context .put (attrRepairKey , this );
8588
8689 attr = Attr .instance (context );
90+ chk = Check .instance (context );
8791 deferredAttr = DeferredAttr .instance (context );
8892 names = Names .instance (context );
8993 make = TreeMaker .instance (context );
@@ -192,8 +196,14 @@ public void visitClassDef(JCClassDecl tree) {
192196 while (pats .length () < args .length ()) {
193197 pats = pats .append (syms .errType );
194198 }
199+ CheckContext recoveryCheckContext = new NestedCheckContext (todo .resultInfo .checkContext ) {
200+ @ Override
201+ public void report (JCDiagnostic .DiagnosticPosition pos , JCDiagnostic details ) {
202+ chk .basicHandler .report (pos , details );
203+ }
204+ };
195205 owntype = attr .checkMethod (todo .site , todo .candSym ,
196- attr .new ResultInfo (todo .resultInfo .pkind , todo .resultInfo .pt .getReturnType (), todo . resultInfo . checkContext , todo .resultInfo .checkMode ),
206+ attr .new ResultInfo (todo .resultInfo .pkind , todo .resultInfo .pt .getReturnType (), recoveryCheckContext , todo .resultInfo .checkMode ),
197207 todo .env , args , pats ,
198208 todo .resultInfo .pt .getTypeArguments ());
199209 rollback .forEach (Runnable ::run );
0 commit comments