mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-01 22:02:45 +01:00
When declaring a class (or interface), we create a scope that covers the entire class declaration. If the class was declared in a lexical scope, we would declare the class name in the innermost scope, which was the class's own scope instead of the enclosing lexical scope. Fix this by instead adding the name to the lexical scope at the start of the class declaration, not the lexical scope created to hold the class. For now, we reject if the class name would have been shadowed by a name that has already been declared within its scope, such as a generic parameter, so we only ever need to modify the end of the list of lexical lookup results for the class name. This appears to be sufficient to make local declarations and definitions of classes and interfaces work properly throughout check, though testing is pretty minimal so far.