Commit Graph

733 Commits

Author SHA1 Message Date
David Farler
dbd78643ce Build fix: Adventure triggers nullptr dereference
Fix a nullptr dereference when looking for a base expression
in a member access. Remove use of Optional<T*>, it wasn't providing
any value versus nullptr checking.

Swift SVN r28648
2015-05-15 23:36:33 +00:00
David Farler
80571cf916 Check base expr when determining mutability of a member
When in an initializer, we allow setting into immutable properties
provided that the type of base in `base.member` matches that of that
initializer's containing type. This was an approximation for allowing
full access into `self` during initialization but this doesn't work when
passing in a different struct of the same type because that struct
should be still be immutable.

Check whether the base of the member access is the implicit self
parameter of the initializer before allowing mutation.

rdar://problem/19814302

Swift SVN r28634
2015-05-15 18:48:54 +00:00
Doug Gregor
2f0c1b151e Use the archetype for unqualified lookup within protocols and extensions thereof.
When performing unqualified lookup within a type context (or method
thereof) that is a protocol or a protocol extension, use the Self
archetype of the protocol or extension so we look in types implied by
the requirements as well. Part of rdar://problem/20509152, fixing the
example provided in rdar://problem/20694545.

Swift SVN r28363
2015-05-09 03:42:16 +00:00
Doug Gregor
2653a6569b Eliminate ModuleExpr; DeclRefExpr is good enough for anyone.
Swift SVN r28285
2015-05-07 21:10:53 +00:00
Doug Gregor
297c9e2911 Introduce NameLookupOptions for TypeChecker::lookupMember(). NFC
Swift SVN r28281
2015-05-07 21:10:38 +00:00
Doug Gregor
a30ca2a60d Replace bool parameter to TypeChecker::conformsToProtocol() with an option set.
NFC; we can extend this option set more readily later.

Swift SVN r27894
2015-04-29 00:08:22 +00:00
Chris Lattner
d18740d603 Fix <rdar://problem/19773562> Closures executed immediately { like this }() are not automatically @noescape
In addition to being better for performance in these cases, this disables the "self." 
requirement in these blocks.  {}() constructs are often used to work around statements
that are not exprs in Swift, so they are reasonably important.

Fixing this takes a couple of pieces working together:
 - Add a new 'extraFunctionAttrs' map to the ConstraintSystem for solution
   invariant function attributes that are inferred (like @noescape).
 - Teach constraint simplification of function applications to propagate 
   @noescape between unified function types.
 - Teach CSGen of ApplyExprs to mark the callee functiontype as noescape
   when it is obviously a ClosureExpr.

This is a very limited fix in some ways: you could argue that ApplyExpr should
*always* mark its callee as noescape.  However, doing so would just introduce a
ton of function conversions to remove it again, so we don't do that.




Swift SVN r27723
2015-04-25 23:34:18 +00:00
Joe Pamer
3f572cab62 Remove hack to bind throwing initializer overloads based on the presence of a throwing initializer in the overload group.
Swift SVN r27694
2015-04-24 17:48:29 +00:00
Doug Gregor
c45c5d4bd1 Stop performing silly, ridiculous hasTypeWitness checks.
Swift SVN r27638
2015-04-23 18:20:56 +00:00
Chris Willmore
d4db635e3d Add object literal syntax and _{Color,Image}LiteralConvertible protocols
Add syntax "[#Color(...)#]" for object literals, to be used by
Playgrounds for inline color wells etc. The arguments are forwarded to
the relevant constructor (although we will probably change this soon,
since (colorLiteralRed:... blue:... green:... alpha) is kind of
verbose). Add _ColorLiteralConvertible and _ImageLiteralConvertible
protocols, and link them to the new expressions in the type checker.
CSApply replaces the object literal expressions with a call to the
appropriate protocol witness.

Swift SVN r27479
2015-04-20 12:55:56 +00:00
Doug Gregor
7687be3a9a Fix another bogus use of ProtocolConformance::isComplete().
Swift SVN r27382
2015-04-16 21:22:11 +00:00
Doug Gregor
f554fb9680 Member type lookup: when we have a type witness, use it.
This doesn't actually break the circular type-checking issues with
have with associated type inference, but it makes them less
painful. Fixes rdar://problem/20549165.

While here, and as a test, remove the _prext_underestimateCount
workound from the library. _CollectionDefaultsType now refines
_SequenceDefaultsType.

Swift SVN r27368
2015-04-16 19:55:53 +00:00
Doug Gregor
997136962e Always open existential types in the type checker.
Consistently open all references into existentials into
opened-existential archetypes within the constraint solver. Then,
during constraint application, use OpenExistentialExprs to record in
the AST where an existential is opened into an archetype, then use
that archetype throughout the subexpression. This simplifies the
overall representation, since we don't end up with a mix of operations
on existentials and operations on archetypes; it's all archetypes,
which tend to have better support down the line in SILGen already.

Start simplifying the code in SILGen by taking away the existential
paths that are no longer needed. I suspect there are more
simplifications to be had here.

The rules for placing OpenExistentialExprs are still a bit ad hoc;
this will get cleaned up later so that we can centralize that
information. Indeed, the one regression in the compiler-crasher suite
is because we're not closing out an open existential along an error
path.

Swift SVN r27230
2015-04-11 03:20:22 +00:00
Doug Gregor
5f4bea74e1 Open existential uses of dynamic-Self methods and initializers in the constraint solver.
Previously, we were only opening the existentials as part of
constraint application, which involved some ugly, redundant code. This
should be NFC because it's just moving the existential opening
operation earlier, but it's a step toward opening up all existential
references.

Swift SVN r27190
2015-04-09 23:58:55 +00:00
Doug Gregor
f4d98da668 Support the use of members of protocol extensions on existential types.
To use members of protocol extensions on existential types, we
introduce an OpenExistentialExpr expression to open up the existential
type (into a local archetype) and perform the operations on that local
archetype.

Unlike with uses of initializers or dynamic-Self-producing
methods of protocols, which produce similar ASTs, we have the type
checker perform the "open" operation and then track it through
constraint application. This scheme is better (because it's more
direct), but it's still using a simplistic approach to deciding where
the actual OpenExistentialExpr goes that needs improvement.

Swift SVN r26964
2015-04-04 00:00:14 +00:00
Joe Pamer
eee40fc53f Add basic parsing, sema and mangling support for throwing function types. Next up, metadata and serialization support, as well as more tests.
Swift SVN r26767
2015-03-31 18:55:19 +00:00
Doug Gregor
3d77855b31 Start allowing extensions of protocol types.
Remove the semantic restrictions that prohibited extensions of
protocol types, and start making some systematic changes so that
protocol extensions start to make sense:
  - Replace a lot of occurrences of isa<ProtocolDecl> and
    dyn_cast<ProtocolDecl> on DeclContexts to use the new
    DeclContext::isProtocolOrProtocolExtensionContext(), where we want
    that behavior to apply equally to protocols and protocol extensions.
  - Eliminate ProtocolDecl::getSelf() in favor of
    DeclContext::getProtocolSelf(), which produces the appropriate
    generic type parameter for the 'Self' of a protocol or protocol
    extension. Update all of the callers of ProtocolDecl::getSelf()
    appropriately.
  - Update extension validation to appropriately form generic
    parameter lists for protocol extensions.
  - Methods in protocol extensions always use the witnesscc calling
  convention.

At this point, we can type check and SILGen very basic definitions of
protocol extensions with methods that can call protocol requirements,
generic free functions, and other methods within the same protocol
extension.

Regresses four compiler crashers but improves three compiler
crashers... we'll call that "progress"; the four regressions all hit
the same assertion in the constraint system that will likely be
addressed as protocol extensions starts working.

Swift SVN r26579
2015-03-26 04:50:51 +00:00
Doug Gregor
3805e18090 Explicitly track the mapping from dependent types to their opened type variables.
Previously, we were reconstructing this mapping from the "full" opened
type produced by declaration references. However, when dealing with
same-type constraints between associated types and type parameters, we
could end up with an incomplete mapping, which let archetypes slip
through. Most of the churn here is sorting out the locators we need to
use to find the opened-type information. Fixes rdar://problem/18208283
and at least 3 dupes of it that I've found so far.

Swift SVN r25375
2015-02-18 19:41:40 +00:00
Doug Gregor
0e74268ea5 Strongly prefer available declarations to unavailable ones in type checking.
Fixes rdar://problem/18847642, rdar://problem/16554496, and the
current 1_stdlib/Array.swift.

Swift SVN r25212
2015-02-12 01:01:11 +00:00
John McCall
9e26ecf2af Make ArchetypeType::NestedType its own proper type
with more explicit/semantic conversions in and out.

Using a PointerUnion with overlapping pointer types
is both error-prone and pretty close to illegible.

Swift SVN r24707
2015-01-24 13:05:38 +00:00
Joe Pamer
35184ff7b5 Utilize argument type information to favor overload binding constraints on initializers. Doing so addresses a number of cases where the type checker was going exponential on seemingly simple user code.
Also, these changes fix the performance regressions that were introduced as a result of September's convertible/init requirement modifications, and allow us to roll back the associated workarounds that were added to the Adventure sample (rdar://problem/18942100).

Swift SVN r24520
2015-01-19 20:59:14 +00:00
Doug Gregor
fea55d98f2 Eliminate dependent types from within archetypes.
When dealing with multiple levels of generic parameters, the mapping
from potential archetypes down to actual archetypes did not have
access to the archetypes for outer generic parameters. When same-type
requirements equated a type from the inner generic parameter list with
one from the outer generic parameter list, the reference to the outer
generic parameter list's type would remain dependent. For example,
given:

  struct S<A: P> {
    init<Q: P where Q.T == A>(_ q: Q) {}
  }

we would end up with the dependent type for A (τ_0_0) in the same-type
constraint in the initializer requirement.

Now, notify the ArchetypeBuilder of outer generic signatures (and,
therefore, outer generic parameters), so that it has knowledge of the
mapping from those generic parameters to the corresponding
archetypes. Use that mapping when translating potential archetypes to
real archetypes. Additionally, when a potential archetype is mapped to
a concrete type (via a same-type constraint to a concrete type),
substitute archetypes for any dependent types within the concrete
type.

Remove a bunch of hacks in the compiler that identified dependent
types in "strange" places and tried to map them back to
archetypes. Those hacks handled some narrow cases we saw in the
standard library and some external code, but papered over the
underlying issue and left major gaps.

Sadly, introduce one hack into the type checker to help with the
matching of generic witnesses to generic requirements that follow the
pattern described above. See ConstraintSystem::SelfTypeVar; the proper
implementation for this matching involves substituting the adoptee
type in for Self within the requirement, and synthesizing new
archetypes from the result.

Fixes rdar://18435371, rdar://18803556, rdar://19082500,
rdar://19245317, rdar://19371678 and a half dozen compiler crashers
from the crash suite. There are a few other radars that I suspect this
fixes, but which require more steps to reproduce.

Swift SVN r24460
2015-01-16 00:27:18 +00:00
Doug Gregor
562b529d7a Start simplifying the "dependent type opener" contract.
The archetype opener only needs to perform basic substitutions; let it
do so, avoiding the creation of a pile of type variables that simply
get immediately bound.

Swift SVN r24399
2015-01-13 23:17:52 +00:00
Joe Pamer
2912159776 Improve diagnostics for expression typecheck errors
These changes make the following improvements to how we generate diagnostics for expression typecheck failure:
- Customizing a diagnostic for a specific expression kind is as easy as adding a new method to the FailureDiagnosis class,
  and does not require intimate knowledge of the constraint solver’s inner workings.
    - As part of this patch, I’ve introduced specialized diagnostics for call, binop, unop, subscript, assignment and inout
      expressions, but we can go pretty far with this.
    - This also opens up the possibility to customize diagnostics not just for the expression kind, but for the specific types
      involved as well.
- For the purpose of presenting accurate type info, partially-specialized subexpressions are individually re-typechecked
  free of any contextual types. This allows us to:
    - Properly surface subexpression errors.
    - Almost completely avoid any type variables in our diagnostics. In cases where they could not be eliminated, we now
      substitute in "_".
    - More accurately indicate the sources of errors.
- We do a much better job of diagnosing disjunction failures. (So no more nonsensical ‘UInt8’ error messages.)
- We now present reasonable error messages for overload resolution failures, informing the user of partially-matching
  parameter lists when possible.

At the very least, these changes address the following bugs:

<rdar://problem/15863738> More information needed in type-checking error messages
<rdar://problem/16306600> QoI: passing a 'let' value as an inout results in an unfriendly diagnostic
<rdar://problem/16449805> Wrong error for struct-to-protocol downcast
<rdar://problem/16699932> improve type checker diagnostic when passing Double to function taking a Float
<rdar://problem/16707914> fatal error: Can't unwrap Optional.None…Optional.swift, line 75 running Master-Detail Swift app built from template
<rdar://problem/16785829> Inout parameter fixit
<rdar://problem/16900438> We shouldn't leak the internal type placeholder
<rdar://problem/16909379> confusing type check diagnostics
<rdar://problem/16951521> Extra arguments to functions result in an unhelpful error
<rdar://problem/16971025> Two Terrible Diagnostics
<rdar://problem/17007804> $T2 in compiler error string
<rdar://problem/17027483> Terrible diagnostic
<rdar://problem/17083239> Mysterious error using find() with Foundation types
<rdar://problem/17149771> Diagnostic for closure with no inferred return value leaks type variables
<rdar://problem/17212371> Swift poorly-worded error message when overload resolution fails on return type
<rdar://problem/17236976> QoI: Swift error for incorrectly typed parameter is confusing/misleading
<rdar://problem/17304200> Wrong error for non-self-conforming protocols
<rdar://problem/17321369> better error message for inout protocols
<rdar://problem/17539380> Swift error seems wrong
<rdar://problem/17559593> Bogus locationless "treating a forced downcast to 'NSData' as optional will never produce 'nil'" warning
<rdar://problem/17567973> 32-bit error message is really far from the mark: error: missing argument for parameter 'withFont' in call
<rdar://problem/17671058> Wrong error message: "Missing argument for parameter 'completion' in call"
<rdar://problem/17704609> Float is not convertible to UInt8
<rdar://problem/17705424> Poor error reporting for passing Doubles to NSColor: extra argument 'red' in call
<rdar://problem/17743603> Swift compiler gives misleading error message in "NSLayoutConstraint.constraintsWithVisualFormat("x", options: 123, metrics: nil, views: views)"
<rdar://problem/17784167> application of operator to generic type results in odd diagnostic
<rdar://problem/17801696> Awful diagnostic trying to construct an Int when .Int is around
<rdar://problem/17863882> cannot convert the expression's type '()' to type 'Seq'
<rdar://problem/17865869> "has different argument names" diagnostic when parameter defaulted-ness differs
<rdar://problem/17937593> Unclear error message for empty array literal without type context
<rdar://problem/17943023> QoI: compiler displays wrong error when a float is provided to a Int16 parameter in init method
<rdar://problem/17951148> Improve error messages for expressions inside if statements by pre-evaluating outside the 'if'
<rdar://problem/18057815> Unhelpful Swift error message
<rdar://problem/18077468> Incorrect argument label for insertSubview(...)
<rdar://problem/18079213> 'T1' is not identical to 'T2' lacks directionality
<rdar://problem/18086470> Confusing Swift error message: error: 'T' is not convertible to 'MirrorDisposition'
<rdar://problem/18098995> QoI: Unhelpful compiler error when leaving off an & on an inout parameter
<rdar://problem/18104379> Terrible error message
<rdar://problem/18121897> unexpected low-level error on assignment to immutable value through array writeback
<rdar://problem/18123596> unexpected error on self. capture inside class method
<rdar://problem/18152074> QoI: Improve diagnostic for type mismatch in dictionary subscripting
<rdar://problem/18242160> There could be a better error message when using [] instead of [:]
<rdar://problem/18242812> 6A1021a : Type variable leaked
<rdar://problem/18331819> Unclear error message when trying to set an element of an array constant (Swift)
<rdar://problem/18414834> Bad diagnostics example
<rdar://problem/18422468> Calculation of constant value yields unexplainable error
<rdar://problem/18427217> Misleading error message makes debugging difficult
<rdar://problem/18439742> Misleading error: "cannot invoke" mentions completely unrelated types as arguments
<rdar://problem/18535804> Wrong compiler error from swift compiler
<rdar://problem/18567914> Xcode 6.1. GM, Swift, assignment from Int64 to NSNumber. Warning shown as problem with UInt8
<rdar://problem/18784027> Negating Int? Yields Float
<rdar://problem/17691565> attempt to modify a 'let' variable with ++ results in typecheck error about @lvalue Float
<rdar://problem/17164001> "++" on let value could give a better error message

Swift SVN r23782
2014-12-08 21:56:47 +00:00
Chris Willmore
36d0f187ec Sema, SILGen, ClangImporter: Add special support for Set<T>
Add the following functionality to the Swift compiler:

* covariant subtyping of Set
* upcasting, downcasting of Set
* automatic bridging between Set and NSSet, including
    * NSSet params/return values in ObjC are imported as Set<NSObject>
    * Set params/return values in Swift are visible to ObjC as NSSet

<rdar://problem/18853078> Implement Set<T> up and downcasting

Swift SVN r23751
2014-12-06 02:52:33 +00:00
Jordan Rose
f0582e27b9 Testing whether a type is bridged to ObjC isn't always a public use.
Push the "in expression" flag up through TypeChecker::getBridgedToObjC and
TypeChecker::getDynamicBridgedThroughObjCClass.

Swift SVN r23701
2014-12-05 00:23:29 +00:00
Jordan Rose
2b0fbcbe80 Looking up conformances for a type isn't always a public use of the type.
Specifically, it's not when
- the conformance is being used within a function body (test included)
- the conformance is being used for or within a private type (test included)
- the conformance is being used to generate a diagnostic string

We're still a bit imprecise in some places (checking ObjC bridging), but
in general this means less of an issue for checking literals.

Swift SVN r23700
2014-12-05 00:23:24 +00:00
Jordan Rose
02a286821f Dependencies: member lookups in constraint systems are usually private.
This adds a new parameter to TypeChecker::lookupMember to specify when
something is known-private, which can then be passed along to
DeclContext::lookupQualified. This makes many of the existing member
lookup dependencies in the reference-dependencies.swift test correctly
count as private.

Swift SVN r23631
2014-12-03 02:55:58 +00:00
Ben Langmuir
e9e1666ab0 Update for upstream LLVM changes
* removal of StringMap's GetOrCreateValue
* SmallSet::insert now returns a pair like std::set

Swift SVN r23435
2014-11-19 16:49:30 +00:00
Doug Gregor
caca3ea2d1 Include outer generic parameters in the generic signatures for nominal types.
Generic function signatures were including outer generic parameters,
but generic type signatures were not. This is a small part of the
problem with nested generics (in general), but also a useful cleanup
for generic signatures.

Swift SVN r23011
2014-10-29 22:27:38 +00:00
Devin Coughlin
0aa115c09b Add diagnostics for potentially unavailable initializers.
This patch adds diagnostics for initializers that are potentially unavailable.
It does not treat such initializers as optionals, even when
EnableExperimentalUnavailableAsOptional is true -- there is some tricky
interaction with failable initializers that still needs to be worked out.



Swift SVN r22548
2014-10-06 19:50:08 +00:00
Jordan Rose
042569a3be Optional: Replace uses of Nothing with None.
llvm::Optional (like Swift.Optional!) uses None as its placeholder value,
not Nothing.

Swift SVN r22476
2014-10-02 18:51:42 +00:00
Jordan Rose
4adeb66b9f Drop uses of Optional's variadic forwarding constructor.
In preparation for the switch to llvm::Optional, which doesn't have this.
I suggested it, but got some pushback from David Blaikie, which is
understandable because implicit conversions are dangerous.
std::experimental::optional also doesn't have this, and we don't use it
too much. The only cost is being slightly more explicit when relying on
conversions to give us a T to then wrap in an Optional.

Swift SVN r22472
2014-10-02 18:51:37 +00:00
Devin Coughlin
b727b6d932 Treat potentially unavailable global variable references as optional.
This patch adds the ability (-enable-experimental-unavailable-as-optional) to
treat potentially unavailable declarations as if they had optional types. For
the moment, this is only implemented for global variables.

The high-level approach is to (1) record the potential unavailability of a
declaration reference in the overload choice during constraint generation; (2)
treat the declaration as if it had an optional type during overload resolution
(this is similar to how optional protocol members are treated); and (3) add an
implicit conversion (UnavailableToOptionalExpr) during constraint application
to represent the run-time availability check and optional injection.

This patch does not implement SILGen for UnavailableToOptionalExpr.


Swift SVN r22245
2014-09-24 00:07:46 +00:00
Doug Gregor
7764f64cf8 Simplify assertion machinery in the standard library.
This change includes a number of simplifications that allow us to
eliminate the type checker hack that specifically tries
AssertString. Doing so provides a 25% speedup in the
test/stdlib/ArrayNew.swift test (which is type-checker bound).

The specific simplifications here:
  - User-level
  assert/precondition/preconditionalFailure/assertionFailer/fatalError
  always take an autoclosure producing a String, eliminating the need
  for the StaticString/AssertString dance.
  - Standard-library internal _precondition/_sanityCheck/etc. always
  take a StaticString. When we want to improve the diagnostics in the
  standard library, we can provide a separate overload or
  differently-named function.
  - Remove AssertString, AssertStringType, StaticStringType, which are
  no longer used or needed
  - Remove the AssertString hack from the compiler
  - Remove the "BooleanType" overloads of these functions, because
  their usefuless left when we stopped making optional types conform
  to BooleanType (sorry, should have been a separate patch).



Swift SVN r22139
2014-09-19 17:56:50 +00:00
Doug Gregor
f0d03efb4c Drastically restrict the set of alternative literal types checked by the solver.
When the solver has attempted to produce a solution using the default
literal type tha has failed, dont' try every type that conforms to
that literal type. Instead, try the bridged class type (which deals
with the common AnyObject case) or one of two other options:
  - For integer literals, try the default floating point type (Double)
  - For string literals, try the standard library's AssertString (this
  is a temporary hack)

This limits exponential blow-up in cases where the literal's type
cannot be determined from context. Addresses rdar://problem/18307267.



Swift SVN r22131
2014-09-19 16:22:21 +00:00
Doug Gregor
43b6ed364a Thread constraint locators through opening of generic types.
Locators that refer to opened type parameters now carry information
about the source location where we needed to open the type, so that
(for example) we can trace an opened type parameter back to the
location it was opened. As part of this, eliminate the "rootExpr"
fallback, because we're threading constraint locators everywhere.

This is infrastructural, and should be NFC.

Swift SVN r21919
2014-09-12 20:27:19 +00:00
Doug Gregor
9be2802761 Calls to failable initializers produce the appropriate optional type.
Swift SVN r21295
2014-08-19 21:08:17 +00:00
Dmitri Hrybenko
938e7c2676 stdlib: introduce UnicodeScalarLiteralConvertible protocol
This allows UnicodeScalars to be constructed from an integer, rather
then from a string.  Not only this avoids an unnecessary memory
allocation (!) when creating a UnicodeScalar, this also allows the
compiler to statically check that the string contains a single scalar
value (in the same way the compiler checks that Character contains only
a single extended grapheme cluster).

rdar://17966622

Swift SVN r21198
2014-08-14 16:04:39 +00:00
Joe Pamer
cd4c8f8900 Remove an unnecessary null check that was preventing type member constraints from being added to some freshly opened type variables.
This addresses rdar://problem/17128913, of which there are likely dupes that have yet to be recognized as such.

Swift SVN r21034
2014-08-05 03:01:18 +00:00
Joe Groff
623aba1786 Encapsulate Substitution's state.
Expose Substitution's archetype, replacement, and conformances only through getters so we can actually assert invariants about them. To start, require  replacement types to be materializable in order to catch cases where the type-checker tries to bind type variables to lvalue or inout types, and require the conformance array to match the number of protocol conformances required by the archetype. This exposes some latent bugs in the test suite I've marked as failures for now:

- test/Constraints/overload.swift was quietly suffering from <rdar://problem/17507421>, but we didn't notice because we never tried to codegen it.
- test/SIL/Parser/array_roundtrip.swift doesn't correctly roundtrip substitutions, which I filed as <rdar://problem/17781140>.

Swift SVN r20418
2014-07-23 18:00:38 +00:00
Doug Gregor
bd9ead4371 Remove -[no-]strict-keyword-arguments.
Swift SVN r19850
2014-07-11 16:58:35 +00:00
Chris Lattner
35dcc3aa10 Move the @optional attribute to being a SIMPLE_DECL_ATTR, which
simplifies a bunch of code, makes them more consistent with the
other attributes, and is generally the newfangled way to do things.



Swift SVN r19779
2014-07-10 04:34:00 +00:00
Joe Pamer
470718d44a Add a missing null check to the archetype opener. This unfortunately won't make the new Range work any easier, but it essentially turns rdar://problem/17598049 into rdar://problem/17597651.
Swift SVN r19745
2014-07-09 21:46:29 +00:00
Doug Gregor
2f3f6acf21 Make "true" and "false" Boolean literal constants for the BooleanLiteralConvertible protocol.
Introduce the new BooleanLiteralConvertible protocol for Boolean
literals. Take "true" and "false" as real keywords (which is most of the
reason for the testsuite churn). Make Bool BooleanLiteralConvertible
and the default Boolean literal type, and ObjCBool
BooleanLiteralConvertible. Fixes <rdar://problem/17405310> and the
recent regression that made ObjCBool not work with true/false.


Swift SVN r19728
2014-07-09 16:57:35 +00:00
Jordan Rose
b892892871 Disallow use of TypeBase::getAs/isa/castAs with sugared types.
These methods all act on the desugared type, so the result would always be
false/null.

Also removes a few mistaken uses of getAs caught by this change.

Swift SVN r19585
2014-07-06 22:07:26 +00:00
Joe Groff
3c539b7f24 Sema: Look through optional types for .member lookup.
When we see a '.member' expression in optional context, look for the member in the optional's object type if it isn't found in Optional itself. <rdar://problem/16125392>

Swift SVN r19469
2014-07-02 16:33:45 +00:00
Doug Gregor
39bcf3bd85 Re-sugar the types we deduce for type variables.
This makes us deduce types like "[Int]" and "[String : Int]" from
array/dictionary literals, giving a nicer REPL experience.


Swift SVN r19258
2014-06-26 22:04:47 +00:00
John McCall
7effec113c Change ImplicitlyUnwrappedOptional to be an enum type itself,
not a struct wrapping an Optional.

Among other things, this means you can now pattern-match on
an IUO.  It also makes it more convenient to build and destroy
them.

SILGen's type lowering should probably canonicalize one kind
of optional to the other so that we don't get silly abstraction
costs from conversion.

Swift SVN r18991
2014-06-18 23:27:08 +00:00
Doug Gregor
1c06c309bc Automatically reflect non-Foundation categories of bridged Objective-C classes onto their bridged value types.
This makes categories of NSString, NSArray, and NSDictionary available
on String, Array, and Dictionary. Note that we only consider
categories not present in the Objective-C Foundation module, because
we want to manually map those APIs ourselves. Hence, no changes to the
NSStringAPI. Implements <rdar://problem/13653329>.


Swift SVN r18920
2014-06-16 09:07:00 +00:00