function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jay reddyJay reddy 

Winter '18 Apex complier Changes

I have received an email from SALESFORCE regarding WINTER '18 APEX COMPLIER CHANGES [ACTION REQUIRED: Code Changes Required for your Apex Compiler].
 
https://help.salesforce.com/articleView?id=000264742&type=1&language=en_US

in that, could someone help me understanding the BEHAVIOR 6

BEHAVIOR 6:

"Account" type binds to "Schema.Account" when namespace is null or empty
The compiler is not correctly requiring the use of the Schema namespace when there is a user-defined type with the same name. For example, in the following code, the type Contact should be specified to be in the Schema namespace if there is also a Contact class in the same implicit namespace:

public map<String, Contact> getContacts(List<String> mails){
return getContactsByMap([SELECT Id, Email FROM Contact WHERE Email IN :mails]);
}

It's possible that your code is not behaving the way you expect because it may be binding to a different type than the one you intended. In other words, if you have shadowed a standard SObject type with an apex class of the same name, this change will cause your custom class to take precedence over the standard SObject type, unless the Schema namespace is explicitly specified.
Suggested fix
We suggest fixing the code by prepending the correct namespace to types in the Schema namespace if a name collision with a user-defined type is possible, and you intend to bind to the Schema SObject type.

public map<String, Schema.Contact> getContacts(List<String> mails){
return getContactsByMap([SELECT Id, Email FROM Contact WHERE Email IN :mails ]);
}

I really appreciate your time and help.

Thanks
GR