{
if (!Grammar.isValidIdentifier(lib.getName())) {
throw new RuntimeException("Name of '"+dottedname+"' is invalid");
}
Name name = Grammar.parseDottedName(dottedname);
IncrementalScope scope = this;
int i = 0;
int n = name.size();
while(i < n) {
String s = name.get(i++);
Type type = scope.lookupDeclaration(s);
if (type == null) {
if (i < n) {
SyntheticNamespace ns = new SyntheticNamespace(scope, s);
scope.addDeclaration(ns);
scope = ns;
} else {
scope.addDeclaration(lib);
lib.setParent(scope);
return;
}
} else {
if (type instanceof IncrementalScope) {