mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Implement type sugar "T?" for Optional<T>.
- New type representation OptionalTypeRepr. - New sugared type OptionalType. - New base type SyntaxSugarType, parent of ArraySliceType and OptionalType. These two are the same in a lot of ways. - The form "T[]?" is forbidden, because it makes "Int[4][2]" oddly different from "Int[4]?[2]". The type can be spelled "(T[])?" or Optional<T[]>. - Like Slice, "Optional" is just looked up in the current module. This may or may not be the desired behavior in the long run. <rdar://problem/14666783> Swift SVN r7100
This commit is contained in:
@@ -239,6 +239,7 @@ namespace decls_block {
|
||||
ARRAY_TYPE,
|
||||
REFERENCE_STORAGE_TYPE,
|
||||
UNBOUND_GENERIC_TYPE,
|
||||
OPTIONAL_TYPE,
|
||||
|
||||
TYPE_ALIAS_DECL = 100,
|
||||
STRUCT_DECL,
|
||||
@@ -388,12 +389,16 @@ namespace decls_block {
|
||||
BCFixed<1> // noreturn?
|
||||
>;
|
||||
|
||||
using ArraySliceTypeLayout = BCRecordLayout<
|
||||
ARRAY_SLICE_TYPE,
|
||||
template <unsigned Code>
|
||||
using SyntaxSugarTypeLayout = BCRecordLayout<
|
||||
Code,
|
||||
TypeIDField, // element type
|
||||
TypeIDField // implementation type
|
||||
>;
|
||||
|
||||
using ArraySliceTypeLayout = SyntaxSugarTypeLayout<ARRAY_SLICE_TYPE>;
|
||||
using OptionalTypeLayout = SyntaxSugarTypeLayout<OPTIONAL_TYPE>;
|
||||
|
||||
using ArrayTypeLayout = BCRecordLayout<
|
||||
ARRAY_TYPE,
|
||||
TypeIDField, // element type
|
||||
|
||||
Reference in New Issue
Block a user