Let's say we have a simple code
Schema.DescribeSObjectResult res = Schema.SObjectType.Account;
system.debug(Schema.SObjectType.Account.fields.Name.isAccessible());
system.debug(res.fields.Name.isAccessible());
system.debug(res.isAccessible());
but it fails in line 3 with the message
Line: 3, Column: 25 Variable does not exist: Name
what did i miss?
In the example above, the system uses special parsing to validate that the final member variable (Name) is valid for the specified sObject at compile time. When the parser finds the fields member variable, it looks backwards to find the name of the sObject (Account). It validates that the field name following the fields member variable is legitimate. The fields member variable only works when used in this manner.