mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
remove support for looking up global names with dot syntax. "x.y" != "y(x)" now.
Swift SVN r917
This commit is contained in:
@@ -411,11 +411,6 @@ class UnresolvedDotExpr : public Expr {
|
||||
SourceLoc DotLoc;
|
||||
Identifier Name;
|
||||
SourceLoc NameLoc;
|
||||
|
||||
/// ResolvedDecl - If the name refers to any local or top-level declarations,
|
||||
/// the name binder fills them in here.
|
||||
ArrayRef<ValueDecl*> ResolvedDecls;
|
||||
|
||||
public:
|
||||
UnresolvedDotExpr(Expr *subexpr, SourceLoc dotloc, Identifier name,
|
||||
SourceLoc nameloc)
|
||||
@@ -441,12 +436,6 @@ public:
|
||||
Identifier getName() const { return Name; }
|
||||
SourceLoc getNameLoc() const { return NameLoc; }
|
||||
|
||||
ArrayRef<ValueDecl*> getResolvedDecls() const { return ResolvedDecls; }
|
||||
void setResolvedDecls(ArrayRef<ValueDecl*> Decls) {
|
||||
assert(ResolvedDecls.empty());
|
||||
ResolvedDecls = Decls;
|
||||
}
|
||||
|
||||
// Implement isa/cast/dyncast/etc.
|
||||
static bool classof(const UnresolvedDotExpr *) { return true; }
|
||||
static bool classof(const Expr *E) {
|
||||
|
||||
@@ -37,8 +37,7 @@ namespace swift {
|
||||
/// by various query methods.
|
||||
enum class NLKind {
|
||||
UnqualifiedLookup,
|
||||
QualifiedLookup,
|
||||
DotLookup
|
||||
QualifiedLookup
|
||||
};
|
||||
|
||||
/// Module - A unit of modularity. The current translation unit is a
|
||||
|
||||
@@ -723,9 +723,6 @@ public:
|
||||
void visitUnresolvedDotExpr(UnresolvedDotExpr *E) {
|
||||
OS.indent(Indent) << "(unresolved_dot_expr type='" << E->getType();
|
||||
OS << "\' field '" << E->getName().str() << "'";
|
||||
if (!E->getResolvedDecls().empty())
|
||||
OS << " decl resolved to " << E->getResolvedDecls().size()
|
||||
<< " candidate(s)!";
|
||||
if (E->getBase()) {
|
||||
OS << '\n';
|
||||
printRec(E->getBase());
|
||||
|
||||
@@ -157,13 +157,8 @@ void TUModuleCache::lookupValue(AccessPathTy AccessPath, Identifier Name,
|
||||
if (I == TopLevelValues.end()) return;
|
||||
|
||||
Result.reserve(I->second.size());
|
||||
for (ValueDecl *Elt : I->second) {
|
||||
// Dot Lookup ignores values with non-function types.
|
||||
if (LookupKind == NLKind::DotLookup && !Elt->getType()->is<FunctionType>())
|
||||
continue;
|
||||
|
||||
for (ValueDecl *Elt : I->second)
|
||||
Result.push_back(Elt);
|
||||
}
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
@@ -217,23 +217,10 @@ static Expr *BindNames(Expr *E, WalkOrder Order, NameBinder &Binder) {
|
||||
if (Order == WalkOrder::PreOrder)
|
||||
return E;
|
||||
|
||||
// A reference to foo.bar may be an application ("bar foo"), so look up bar.
|
||||
// It may also be a tuple field reference, so don't report an error here if we
|
||||
// don't find anything juicy.
|
||||
if (UnresolvedDotExpr *UDE = dyn_cast<UnresolvedDotExpr>(E)) {
|
||||
SmallVector<ValueDecl*, 4> Decls;
|
||||
// Perform .-style name lookup.
|
||||
Binder.TU->lookupGlobalValue(UDE->getName(), NLKind::DotLookup, Decls);
|
||||
|
||||
// Copy the overload set into ASTContext memory.
|
||||
if (!Decls.empty())
|
||||
UDE->setResolvedDecls(Binder.Context.AllocateCopy(Decls));
|
||||
return UDE;
|
||||
}
|
||||
|
||||
Identifier Name;
|
||||
SourceLoc Loc;
|
||||
SmallVector<ValueDecl*, 4> Decls;
|
||||
|
||||
// Process UnresolvedDeclRefExpr by doing an unqualified lookup.
|
||||
if (UnresolvedDeclRefExpr *UDRE = dyn_cast<UnresolvedDeclRefExpr>(E)) {
|
||||
Name = UDRE->getName();
|
||||
|
||||
@@ -439,33 +439,6 @@ Expr *SemaExpressionTree::visitUnresolvedDotExpr(UnresolvedDotExpr *E) {
|
||||
return Call;
|
||||
}
|
||||
|
||||
// Next, check to see if "a.f" is actually being used as sugar for "f a",
|
||||
// which is a function application of 'a' to 'f'.
|
||||
if (!E->getResolvedDecls().empty()) {
|
||||
assert(E->getResolvedDecls()[0]->getType()->is<FunctionType>() &&
|
||||
"Should have only bound to functions");
|
||||
Expr *FnRef;
|
||||
// Apply the base value to the function there is a single candidate in the
|
||||
// set then this is directly resolved, otherwise it is an overload case.
|
||||
if (E->getResolvedDecls().size() == 1)
|
||||
FnRef = new (TC.Context) DeclRefExpr(E->getResolvedDecls()[0],
|
||||
E->getNameLoc(),
|
||||
E->getResolvedDecls()[0]->getTypeJudgement());
|
||||
else {
|
||||
FnRef = new (TC.Context) OverloadSetRefExpr(E->getResolvedDecls(),
|
||||
E->getNameLoc());
|
||||
FnRef->setDependentType(DependentType::get(TC.Context));
|
||||
}
|
||||
|
||||
CallExpr *Call = new (TC.Context) CallExpr(FnRef, Base,
|
||||
/*DotSyntax=*/true,
|
||||
TypeJudgement());
|
||||
if (TC.semaApplyExpr(Call))
|
||||
return 0;
|
||||
|
||||
return Call;
|
||||
}
|
||||
|
||||
// If this is a member access to a oneof with a single element constructor
|
||||
// (e.g. a struct), allow direct access to the type underlying the single
|
||||
// element.
|
||||
|
||||
Reference in New Issue
Block a user