Commit Graph

781 Commits

Author SHA1 Message Date
practicalswift
4ef5c6d840 [gardening] Remove unused variables 2017-04-25 21:03:41 +02:00
Joe Groff
595e0e4ede Merge branch 'master' into keypaths 2017-04-19 18:38:24 -07:00
practicalswift
5e255e07d7 [gardening] Remove redundant logic 2017-04-11 23:04:55 +02:00
Joe Groff
964dc0e174 Sema: (wip) Overload resolution for keypath subscripts.
TODO: Some diagnostic regressions:
test-macosx-x86_64/Compatibility/tuple_arguments.swift
test-macosx-x86_64/Constraints/diagnostics.swift
test-macosx-x86_64/Constraints/tuple_arguments.swift
test-macosx-x86_64/expr/unary/keypath/keypath.swift
test-macosx-x86_64/expr/unary/selector/selector.swift
2017-04-09 16:38:02 -07:00
Slava Pestov
162b2d252e AST: Include gardening to minimize dependencies on Expr.h
A lot of files transitively include Expr.h, because it was
included from SILInstruction.h, SILLocation.h and SILDeclRef.h.

However in reality most of these files don't do anything
with Exprs, especially not anything in IRGen or the SILOptimizer.

Now we're down to 171 files in the frontend which depend on
Expr.h, which is still a lot but much better than before.
2017-03-12 22:26:56 -07:00
Huon Wilson
731953b879 [Sema] replace std::pair<bool, bool> with something clearer.
TypeChecker::{checkGenericArguments, conformsToProtocol} used booleans
inappropriately.
2017-03-10 14:55:46 -08:00
Joe Groff
c6dc44d5de Merge pull request #7841 from jckarter/leading-dot-pattern-fallback
Sema: Let `.foo` patterns fall back to being ExprPatterns if they don't match an enum case.
2017-03-01 08:55:25 -08:00
Joe Groff
fc16cb5dda Sema: Let .foo patterns fall back to being ExprPatterns if they don't match an enum case.
This lets you match `case .foo` when `foo` resolves to any static member, instead of only a `case`, albeit without the exhaustiveness checking and subpattern capabilities of proper cases. While we're here, adjust the type system we set up for unresolved patterns embedded in expressions so that we give better signal in the error messages too.
2017-02-28 21:51:39 -08:00
Doug Gregor
5c2fe3496f Merge pull request #7740 from huonw/parse-assoc-type-where
(Mostly) Type-check where clauses on associated types
2017-02-27 22:06:51 -08:00
Slava Pestov
721e6178f5 AST: Remove TypeBase::isUnspecializedGeneric() 2017-02-27 20:00:35 -08:00
Huon Wilson
c518f4bd0f [TypeCheck] Check all requirements of a protocol are satisfied by a conformance. 2017-02-24 19:40:45 -08:00
Mark Lacey
f1f9e88360 Cache expression types in failure diagnosis.
After we call into typeCheckExpression() we need to cache the
resulting types in the constraint system type map because we later
call into code that reads the types out of the type map.

Fixes rdar://problem/30376186 as well as a couple crashers.
2017-02-14 19:22:41 -08:00
Hugh Bellamy
f001b7562b Use relatively new LLVM_FALLLTHROUGH instead of our own SWIFT_FALLTHROUGH 2017-02-12 10:47:03 +07:00
Doug Gregor
b412961003 [AST] Maintain type sugar in TypeMatcher. 2017-02-09 15:03:34 -08:00
Slava Pestov
a16faae73b AST: Move ProtocolConformance::getTypeWitnessByName() to ProtocolConformanceRef
I need to move some #includes around ("include what you use") to
break circularities for an upcoming refactoring.
2017-02-08 15:33:46 -08:00
Jacob Bandes-Storch
c98e515734 [QoI] Improvements to function call & closure diagnostics (#7224) 2017-02-07 17:36:11 -08:00
swift-ci
014abc3b4f Merge pull request #7088 from graydon/rdar-29684330-count-constraint-solving-memory-more-precisely 2017-02-06 14:55:55 -08:00
Graydon Hoare
9cb1c52fd8 Count constraint-solving memory more precisely, rdar://29684330 2017-02-06 13:04:19 -08:00
Slava Pestov
5a9f674bf8 Sema: Use the return value of checkGenericArguments() 2017-02-03 19:55:40 -08:00
Doug Gregor
42c253bf78 Merge pull request #7144 from DougGregor/string-interpolation-typecheck
[Type checker] Detangle the constraints of interpolated string literals.
2017-01-30 11:09:22 -08:00
Doug Gregor
4127f700f1 [Type checker] Remove the now-unused InterpolationArgument locator element.
NFC; the prior commit eliminated all uses of this locator path element.
2017-01-30 10:04:55 -08:00
Slava Pestov
dca292c652 Serialization: Don't serialize contextual enum argument type
Storing this separately is unnecessary since we already
serialize the enum element's interface type. Also, this
eliminates one of the few remaining cases where we serialize
archetypes during AST serialization.
2017-01-30 00:08:53 -08:00
Slava Pestov
7da7651345 Sema: Fix assertion failure in typo correction with static base
For some reason we weren't desugaring the base type, so the
metatype check would fail.
2017-01-28 18:35:25 -08:00
Slava Pestov
3fd645ba0b Sema: Fix assertion failure for constructor call on non-nominal type 2017-01-28 18:35:24 -08:00
practicalswift
a9d6d8938c [gardening] Fix recently introduced typos 2017-01-22 20:40:45 +01:00
Slava Pestov
c86b5ae427 AST: Header file gardening - include what you use 2017-01-19 20:07:06 -08:00
Pavel Yaskevich
671d470322 [Diagnostics] Don't attempt member lookup if base type has unresolved type parameters
If there are unresolved generic parameters present and we are trying
to diagnose problems related to initializer call, it makes sense to
check argument expression first, which might be erroneous and then move
on to the ambiguity checking instead of trying to lookup possible
constructors directly.
2017-01-19 14:01:57 -08:00
Pavel Yaskevich
35b0ffeff8 [Diagnostics] Fix diagnoseImplicitSelfErrors to accept only valid argument types.
Add additional checks before trying to re-check argument expression in
`FailureDiagnosis::diagnoseImplicitSelfErrors` and before trying to use
its resulting type, which can only be either tuple or paren type.
2017-01-17 01:49:09 -08:00
Pavel Yaskevich
24e8cdfdc1 [Diagnostics] Nullify contextual type if it's generic with type variables
It's undesirable to have generic type which contains type variables
as contextual conversion type while diagnosing sub-expressions, it's
going to result in attempt to convert generic arguments to unresolved
type which produces worse diagnostics than no contextual type at all.

Resolves: SR-3525.
2017-01-16 00:33:45 -08:00
swift-ci
a716d403d6 Merge pull request #6774 from jckarter/nsnumber-conditional-casting 2017-01-13 15:20:12 -08:00
Joe Groff
c03371afc1 Sema: NSValue-to-value-type casts are failable and should be checked.
In Swift 4 mode, no longer consider e.g. 'nsNumber as Int' or 'nsValue as NSRange' to be valid coercions. This would break compatibility with Swift 3, so in Swift 3 mode, accept the coercion, but *also* accept a checked cast without a warning, and raise a migration warning about the unchecked coercion.
2017-01-13 13:51:27 -08:00
Pavel Yaskevich
599be90009 [QoI] Refactor TypeChecker::checkGenericArguments. NFC
Refactor TypeChecker::checkGenericArguments to enable it
to be used by FailureDiagnosis::diagnoseArgumentGenericRequirements,
which consolidates requirement checking in one place.
2017-01-12 18:41:18 -08:00
Pavel Yaskevich
c158f49417 [Diagnostics] Improve diagnostics for generic types with unfulfilled requirements 2017-01-11 15:25:16 -08:00
swift-ci
a6419f27f2 Merge pull request #6726 from rudkx/fix-release-build-warning 2017-01-10 23:43:30 -08:00
Mark Lacey
75c8afce2a Fix release build warning. 2017-01-10 23:01:21 -08:00
Slava Pestov
5eb16e6b34 Include-what-you-use: Initializer.h should not be pulled in from AST.h 2017-01-09 16:46:31 -08:00
Slava Pestov
c04c6c9c61 Merge pull request #6586 from xedin/SR_3520
Generic function taking closure with inout parameter returns erroneous results
2017-01-09 12:25:20 -08:00
Slava Pestov
7731d4c6cb Sema: Remove some unnecessary calls to getCanonicalType() 2017-01-08 21:01:13 -08:00
Pavel Yaskevich
dd7360e821 [Diagnostics] Improve diagnostics for closures with erroneous implicit return types 2017-01-07 22:07:15 -08:00
practicalswift
30a88d38e6 [gardening] Fix recently introduced typos 2017-01-06 21:16:02 +01:00
practicalswift
94091980b3 [gardening] Remove dupe word 2017-01-06 20:43:48 +01:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
Robert Widmann
96f2a04f55 Merge pull request #6490 from modocache/ast
[SR-2757][Sema] Mark VarDecl in capture lists
2017-01-05 21:36:16 -07:00
Slava Pestov
18adb53226 Sema: Tighten up name lookup routines to not look through metatypes/lvalues/etc
Previously all of the following would strip off varying amounts of
MetatypeType, LValueType, InOutType, DynamicSelfType, etc:

- ConstraintSystem::performMemberLookup()
- ConstraintSystem::lookupMember()
- TypeChecker::lookupMember()
- DeclContext::lookupQualified()
- Type::getContextSubstitutions()

The problem is that the higher level methods that took a lookup type
would call the lower level methods, and post-process the result using
the given lookup type. Since different levels of sugar were stripped,
it made the code hard to reason about and opened up edge cases, eg
if a DynamicSelfType or InOutType appears where we didn't expect it.

Since filtering out static/instance and mutating/nonmutating members
is done at higher levels, there's no reason for these name lookup
operations to accept anything other than nominal types, existentials
and archetypes.

Make this so with assertions, and deal with the fallout.
2017-01-04 01:40:19 -08:00
Slava Pestov
584f47d025 Sema: Fix crashes in CSDiag
- TypeMatchVisitor doesn't like seeing ErrorTypes -- stop if we have one.

- Common logic for replacing type parameters and variables with
  UnresolvedType.

- Fix crash in coerceToType() if one of the two types has an UnresolvedType
  in it, but not at the top level.

Fixes one compiler_crasher and some regressions with upcoming patches.
2017-01-04 01:40:19 -08:00
Slava Pestov
064fda52d2 AST: Remove Type::getCanonicalTypeOrNull()
Not sure why but this was another "toxic utility method".
Most of the usages fell into one of three categories:

- The base value was always non-null, so we could just call
  getCanonicalType() instead, making intent more explicit

- The result was being compared for equality, so we could
  skip canonicalization and call isEqual() instead, removing
  some boilerplate

- Utterly insane code that made no sense

There were only a couple of legitimate uses, and even there
open-coding the conditional null check made the code clearer.

Also while I'm at it, make the SIL open archetypes tracker
more typesafe by passing around ArchetypeType * instead of
Type and CanType.
2017-01-04 01:08:29 -08:00
Slava Pestov
f19cbef54d Sema: Try harder not to perform lookups into tuple types 2017-01-03 23:00:07 -08:00
Slava Pestov
7258861d73 Merge pull request #6515 from xedin/crasher-28588
[QoI] While merging equivalence classes don't forget to merge fixed types (if any).
2017-01-03 19:35:47 -08:00
Slava Pestov
a8da5b8d80 Merge pull request #6514 from xedin/SR_3506
[Diagnostics] When checking AssignExpr properly diagnose destination
2017-01-03 19:24:52 -08:00
Slava Pestov
5da7e10434 Merge pull request #6481 from xedin/diagnose-closure-return
[Diagnostics] Type-check return of the multi-statement closure without applying solutions
2017-01-03 18:55:27 -08:00