/* Ċ Ġ* ĠCopyright Ġ 2 0 1 0 - 2 0 2 0 ĠJetBrains Ġs . r . o . Ġand ĠKotlin ĠProgramming ĠLanguage Ġcontributors . Ċ Ġ* ĠUse Ġof Ġthis Ġsource Ġcode Ġis Ġgoverned Ġby Ġthe ĠApache Ġ 2 . 0 Ġlicense Ġthat Ġcan Ġbe Ġfound Ġin Ġthe Ġlicense / LICENSE . txt Ġfile . Ċ Ġ*/ Ċ Ċ package Ġorg . jetbrains . kotlin . resolve . check ers Ċ Ċ import Ġcom . intellij . psi . Psi Element Ċ import Ġorg . jetbrains . kotlin . diagnostics . Errors Ċ import Ġorg . jetbrains . kotlin . name . Name Ċ import Ġorg . jetbrains . kotlin . psi . Kt Call Expression Ċ import Ġorg . jetbrains . kotlin . psi . Kt Name Reference Expression Ċ import Ġorg . jetbrains . kotlin . psi . Kt Parent hesized Expression Ċ import Ġorg . jetbrains . kotlin . psi . Kt Safe Qualified Expression Ċ import Ġorg . jetbrains . kotlin . resolve . calls . check ers . Call Checker Ċ import Ġorg . jetbrains . kotlin . resolve . calls . check ers . Call Checker Context Ċ import Ġorg . jetbrains . kotlin . resolve . calls . model . Resolved Call Ċ import Ġorg . jetbrains . kotlin . resolve . calls . model . is Re ally Success Ċ import Ġorg . jetbrains . kotlin . resolve . scopes . re ceiv ers . Expression Receiver Ċ import Ġorg . jetbrains . kotlin . resolve . scopes . re ceiv ers . Receiver Value Ċ import Ġorg . jetbrains . kotlin . types . is Flex ible Ċ import Ġorg . jetbrains . kotlin . types . is Nullable Ċ import Ġorg . jetbrains . kotlin . util . Operator Name Con ventions Ċ Ċ object ĠNullable Extension Operator With Safe Call Checker Ġ: ĠCall Checker Ġ{ ĊĠĠĠ Ġprivate Ġval ĠRE LE V ANT _ OPER ATORS Ġ= Ġmutable Set Of < Name >(). apply Ġ{ ĊĠĠĠĠĠĠĠ Ġadd All ( Operator Name Con ventions . ASSIGN MENT _ OPER ATIONS ) ĊĠĠĠĠĠĠĠ Ġadd ( Operator Name Con ventions . INC ) ĊĠĠĠĠĠĠĠ Ġadd ( Operator Name Con ventions . DEC ) ĊĠĠĠĠĠĠĠ Ġadd ( Operator Name Con ventions . GET ) ĊĠĠĠĠĠĠĠ Ġadd ( Operator Name Con ventions . SET ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġcheck ( resolved Call : ĠResolved Call <* >, Ġreport On : ĠPsi Element , Ġcontext : ĠCall Checker Context ) Ġ{ ĊĠĠĠĠĠĠĠ Ġif Ġ(! resolved Call . is Re ally Success ()) Ġreturn ĊĠĠĠĠĠĠĠ Ġval Ġname Ġ= Ġresolved Call . result ing Descriptor . name ĊĠĠĠĠĠĠĠ Ġif Ġ( name Ġ! in ĠRE LE V ANT _ OPER ATORS ) Ġreturn ĊĊĠĠĠĠĠĠĠ Ġif Ġ(! is Nullable Safe Call Receiver ( resolved Call . extension Receiver )) Ġreturn ĊĊĠĠĠĠĠĠĠ Ġval Ġcall Element Ġ= Ġresolved Call . call . call Element ĊĊĠĠĠĠĠĠĠ Ġ// ĠIt 's Ġan Ġoperator Ġcall , Ġnot Ġa Ġregular Ġone ĊĠĠĠĠĠĠĠ Ġif Ġ( call Element Ġis ĠK t Call Expression Ġ&& Ġname . identifier Ġ== Ġ( call Element . callee Expression Ġas ? ĠK t Name Reference Expression )?. get Referenced Name ()) Ġreturn ĊĊĠĠĠĠĠĠĠ Ġcontext . trace . report ( Errors . NULL ABLE _ EXTENSION _ OPERATOR _ WITH _ SAFE _ CALL _ RECE IVER . on ( report On )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġis Nullable Safe Call Receiver ( receiver Value : ĠReceiver Value ?): ĠBoolean Ġ{ ĊĠĠĠĠĠĠĠ Ġif Ġ( receiver Value Ġ! is ĠExpression Receiver ) Ġreturn Ġfalse ĊĠĠĠĠĠĠĠ Ġif Ġ(! receiver Value . type . is Nullable () Ġ|| Ġreceiver Value . type . is Flex ible ()) Ġreturn Ġfalse ĊĊĠĠĠĠĠĠĠ Ġval Ġexpression Ġ= Ġreceiver Value . expression ĊĊĠĠĠĠĠĠĠ Ġif Ġ( expression Ġ! is ĠK t Safe Qualified Expression ) Ġreturn Ġfalse ĊĠĠĠĠĠĠĠ Ġif Ġ( expression . parent Ġis ĠK t Parent hesized Expression ) Ġreturn Ġfalse ĊĊĠĠĠĠĠĠĠ Ġreturn Ġtrue ĊĠĠĠ Ġ} Ċ } Ċ