mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Accept (and prefer) "import type" as a scoped import for any non-protocol type.
Previously this was spelled "import typealias", and that spelling will continue to be allowed (since someone may specifically be importing a typealias and want that to match), but now that 'type' is a keyword, "import type" is the right way to spell the generic "import any type" scoped import. Swift SVN r14488
This commit is contained in:
@@ -119,9 +119,10 @@
|
|||||||
module:</p>
|
module:</p>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li><code>typealias</code> can be used to import any concrete type (struct,
|
<li><code>type</code> can be used to import any concrete type (struct,
|
||||||
class, enum, or another typealias). It cannot be used to import protocols,
|
class, enum, or typealias). It cannot be used to import protocols, which are
|
||||||
which are often used for more than just their existential type.</li>
|
often used for more than just their existential type.
|
||||||
|
<code>typealias</code> is accepted as an alias for <code>type</code></li>
|
||||||
|
|
||||||
<li><code>struct</code>, <code>class</code>, <code>enum</code> can be used
|
<li><code>struct</code>, <code>class</code>, <code>enum</code> can be used
|
||||||
to import any type whose <i>canonical type</i> is a struct, class,
|
to import any type whose <i>canonical type</i> is a struct, class,
|
||||||
@@ -141,7 +142,7 @@
|
|||||||
import Swift
|
import Swift
|
||||||
|
|
||||||
<i>// Import a single type.</i>
|
<i>// Import a single type.</i>
|
||||||
import typealias Swift.BufferedStream
|
import type Swift.BufferedStream
|
||||||
|
|
||||||
<i>// Import all addition overloads.</i>
|
<i>// Import all addition overloads.</i>
|
||||||
import func Swift.+
|
import func Swift.+
|
||||||
|
|||||||
@@ -563,7 +563,7 @@ void PrintAST::visitImportDecl(ImportDecl *decl) {
|
|||||||
case ImportKind::Module:
|
case ImportKind::Module:
|
||||||
break;
|
break;
|
||||||
case ImportKind::Type:
|
case ImportKind::Type:
|
||||||
Printer << "typealias ";
|
Printer << "type ";
|
||||||
break;
|
break;
|
||||||
case ImportKind::Struct:
|
case ImportKind::Struct:
|
||||||
Printer << "struct ";
|
Printer << "struct ";
|
||||||
|
|||||||
@@ -321,7 +321,7 @@ void DerivedFileUnit::lookupValue(Module::AccessPathTy accessPath,
|
|||||||
|
|
||||||
// If this import is specific to some named type or decl ("import Swift.int")
|
// If this import is specific to some named type or decl ("import Swift.int")
|
||||||
// then filter out any lookups that don't match.
|
// then filter out any lookups that don't match.
|
||||||
if (accessPath.size() == 1 && accessPath.front().first != Name)
|
if (accessPath.size() == 1 && accessPath.front().first != name)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (name == DerivedDecl->getName())
|
if (name == DerivedDecl->getName())
|
||||||
|
|||||||
@@ -819,7 +819,7 @@ void Parser::parseDeclDelayed() {
|
|||||||
/// decl-import:
|
/// decl-import:
|
||||||
/// 'import' attribute-list import-kind? import-path
|
/// 'import' attribute-list import-kind? import-path
|
||||||
/// import-kind:
|
/// import-kind:
|
||||||
/// 'typealias'
|
/// ('type'|'typealias')
|
||||||
/// 'struct'
|
/// 'struct'
|
||||||
/// 'class'
|
/// 'class'
|
||||||
/// 'enum'
|
/// 'enum'
|
||||||
@@ -847,6 +847,7 @@ ParserResult<ImportDecl> Parser::parseDeclImport(ParseDeclOptions Flags,
|
|||||||
SourceLoc KindLoc;
|
SourceLoc KindLoc;
|
||||||
if (Tok.isKeyword()) {
|
if (Tok.isKeyword()) {
|
||||||
switch (Tok.getKind()) {
|
switch (Tok.getKind()) {
|
||||||
|
case tok::kw_type:
|
||||||
case tok::kw_typealias:
|
case tok::kw_typealias:
|
||||||
Kind = ImportKind::Type;
|
Kind = ImportKind::Type;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ static const char *getImportKindString(ImportKind kind) {
|
|||||||
case ImportKind::Module:
|
case ImportKind::Module:
|
||||||
llvm_unreachable("module imports do not bring in decls");
|
llvm_unreachable("module imports do not bring in decls");
|
||||||
case ImportKind::Type:
|
case ImportKind::Type:
|
||||||
return "typealias";
|
return "type";
|
||||||
case ImportKind::Struct:
|
case ImportKind::Struct:
|
||||||
return "struct";
|
return "struct";
|
||||||
case ImportKind::Class:
|
case ImportKind::Class:
|
||||||
|
|||||||
Reference in New Issue
Block a user