IDE: Use GenericSignatures and interface types (mostly)

There was a ton of complicated logic here to work around
two problems:

- Same-type constraints were not represented properly in
  RequirementReprs, requiring us to store them in strong form
  and parse them out when printing type interfaces.

- The TypeBase::getAllGenericArgs() method did not do the
  right thing for members of protocols and protocol extensions,
  and so instead of simple calls to Type::subst(), we had
  an elaborate 'ArchetypeTransformer' abstraction repeated
  in two places.

Rewrite this code to use GenericSignatures and
GenericFunctionType instead of old-school GenericParamLists
and PolymorphicFunctionType.

This changes the code completion and AST printer output
slightly. A few of the changes are actually fixes for cases
where the old code didn't handle substitutions properly.
A few others are subjective, for example a generic parameter
list of the form <T : Proto> now prints as <T where T : Proto>.

We can add heuristics to make the output whatever we want
here; the important thing is that now we're using modern
abstractions.
This commit is contained in:
Slava Pestov
2016-09-15 19:41:29 -07:00
parent 0b8beea69b
commit cfe9e6a3de
39 changed files with 1698 additions and 2226 deletions

View File

@@ -168,7 +168,7 @@ printTypeInterface(ModuleDecl *M, Type Ty, ASTPrinter &Printer,
}
Ty = Ty->getRValueType();
if (auto ND = Ty->getNominalOrBoundGenericNominal()) {
PrintOptions Options = PrintOptions::printTypeInterface(Ty.getPointer(), M);
PrintOptions Options = PrintOptions::printTypeInterface(Ty.getPointer());
ND->print(Printer, Options);
printTypeNameToString(Ty, TypeName);
return false;
@@ -574,8 +574,7 @@ void swift::ide::printSubmoduleInterface(
Decls.back().first == ET.first, true};
if (ET.second)
AdjustedOptions.
initArchetypeTransformerForSynthesizedExtensions(NTD,
pAnalyzer.get());
initArchetypeTransformerForSynthesizedExtensions(NTD);
ET.first->print(Printer, AdjustedOptions);
if (ET.second)
AdjustedOptions.
@@ -607,8 +606,7 @@ void swift::ide::printSubmoduleInterface(
Printer << "\n";
if (ET.second)
AdjustedOptions.
initArchetypeTransformerForSynthesizedExtensions(NTD,
pAnalyzer.get());
initArchetypeTransformerForSynthesizedExtensions(NTD);
ET.first->print(Printer, AdjustedOptions);
if (ET.second)
AdjustedOptions.