Commit Graph

1357 Commits

Author SHA1 Message Date
Slava Pestov
c677d149bc Sema: Fix some unused variable warnings 2017-09-01 02:04:21 -07:00
swift-ci
45d971cb2a Merge pull request #11531 from mkchoi212/master 2017-08-29 12:18:03 -07:00
Jordan Rose
5f30eac288 Excise "Accessibility" from the compiler (1/3)
"Accessibility" has a different meaning for app developers, so we've
already deliberately excised it from our diagnostics in favor of terms
like "access control" and "access level". Do the same in the compiler
now that we aren't constantly pulling things into the release branch.

This commit changes the names of methods, fields, a few local
variables, and even a swift-ide-test flag. The full list is below.

accessibilityForDiagnostics -> accessLevelForDiagnostics
checkAccessibility -> checkAccess
checkGenericParamAccessibility -> checkGenericParamAccess
checkTypeAccessibility -> checkTypeAccess
checkWitnessAccessibility -> checkWitnessAccessibility
computeAccessibility -> computeAccessLevel
computeDefaultAccessibility -> computeDefaultAccessLevel
fixItAccessibility -> fixItAccess
getAccessibilityString -> getAccessLevelString
getAccessibilityStrictly -> getAccessLevelStrictly
getAccessibilityUID -> getAccessLevelUID
getActualAccessibility -> getActualAccessLevel
getDefaultAccessibility -> getDefaultAccessLevel
getMaxAccessibility -> getMaxAccessLevel
getOverridableAccessibility -> getOverridableAccessLevel
getRawStableAccessibility -> getRawStableAccessLevel
getSetterAccessibility -> getSetterFormalAccess
hasAccessibility -> hasAccess
hasDefaultAccessibility -> hasDefaultAccessLevel
inferAccessibility -> inferAccessLevel
inferDefaultAccessibility -> inferDefaultAccessLevel
inferSetterAccessibility -> inferSetterAccessLevel
overwriteAccessibility -> overwriteAccess
overwriteSetterAccessibility -> overwriteSetterAccess
printAccessibility -> printAccess
requiredAccessibilityForDiagnostics -> requiredAccessForDiagnostics
resolveAccessibility -> resolveAccessControl
setAccessibility -> setAccess
setSetterAccessibility -> setSetterAccess
setDefaultAndMaxAccessibility -> setDefaultAndMaxAccess
validateAccessibility -> validateAccessControl

Accessibility -> AccessLevel
AccessibilityFilter -> AccessFilter
IgnoreAccessibility -> IgnoreAccessControl
NL_IgnoreAccessibility -> NL_IgnoreAccessControl
PrintAccessibility -> PrintAccess
PrintInternalAccessibilityKeyword -> PrintInternalAccessKeyword
SetterAccessibility -> SetterAccessLevel

setterAccessibility -> setterAccess
storedPropertyAccessibility -> storedPropertyAccess

-print-accessibility -> -print-access
2017-08-28 11:11:57 -07:00
Mike JS. Choi
3745d6b896 [Diagnostics] Provide contextual type when diagnosing invalid if-exp
Resolves [SR-910](https://bugs.swift.org/browse/SR-910).
2017-08-27 17:18:47 -05:00
gibachan
46a2ea6e2b Use getSelfInterfaceType()
getDeclaredInterfaceType() is invalid for protocol. getSelfInterfaceType() is good for both concrete types and protocol.
2017-08-27 19:05:10 +09:00
gibachan
8b3d36df1b [Qol]Use complete declaration 2017-08-27 07:36:41 +09:00
Slava Pestov
39d7ee2d46 Sema: Fix diagnostics when 'self' in a convenience init has DynamicSelfType
We don't want to print 'Self' here; the actual concrete type
is more useful.

NFC for now, but becomes important once a subsequent patch gives
'self' a DynamicSelfType in convenience initializers.
2017-08-25 23:51:18 -07:00
Robert Widmann
5458fe15a0 Walk into the closure of a CaptureListExpr
Previously, the failure diagnosis visitor would
default to the generic expr walk which would wind
up type checking the closure body and calling it a day.
Walk into the closure of a capture list expression to
emit better diagnostics.

A regression test for SR-5747 is added.
2017-08-23 01:28:43 -07:00
Pavel Yaskevich
47353c25e2 [ConstraintSolver] Skip performance hacks in presence of unavailable overloads
Limit the scope of the performance hacks which currently exist in the
solver even further by disallowing it to skip generic overlaods or stop
in case when previous solutions involve unavailable overloads, which
otherwise might lead to producing incorrect overall solutions.
2017-08-21 14:55:17 -07:00
Pavel Yaskevich
5e7d9bf155 [Diagnostics] NFC: Extract argument<->parameter matcher from diagnoseSingleCandidateFailures 2017-08-16 13:40:20 -07:00
David Zarzycki
5a6a1f565c [Diags] Remove dead code already handled by diagnoseSimpleErrors() 2017-08-09 20:25:30 -04:00
David Zarzycki
78298c8d2a [Sema] Remove vestigial member lookup path
The normal lookup path can handle all constructors just fine.
2017-08-09 20:25:09 -04:00
Arnold Schwaighofer
8146104b7e Revert "Simplify performMemberLookup()" 2017-08-09 10:56:38 -07:00
David Zarzycki
8b544de6c4 [Diags] Remove dead code already handled by diagnoseSimpleErrors() 2017-08-08 21:26:55 -04:00
David Zarzycki
823e3e16c0 [Sema] Remove vestigial member lookup path
The normal lookup path can handle all constructors just fine.
2017-08-08 21:26:55 -04:00
Slava Pestov
1975b107f9 Sema: Fix recently-introduced crash with diagnostics of inout parameters
Recently TupleTypeElt was changed to add an inout bit. It is no
longer valid to construct tuple types whose elements have InOutType,
and instead the flag on the element must be set instead.

Update diagnoseImplicitSelfErrors() for the new convention.

Fixes the only remaining crash in the test case from <rdar://19569255>,
but the original issue were fixed long ago.
2017-08-06 00:43:23 -07:00
Slava Pestov
bf2ca1ab94 Sema/AST: Don't crash when stdlib declarations are missing
I don't have reduced test cases. The original test cases
were a series of frontend invocations in -parse-stdlib
mode.

While the original bugs seem to have been fixed, while
verifying I found a few places where we weren't checking
for null decls property in the ASTContext.

Probably not too useful to check this in, but I don't see it
causing any harm, either.
2017-08-06 00:43:23 -07:00
Pavel Yaskevich
80408d6b82 [QoI] Prevent a crash during diagnostics of ternary/if statements
While trying to diagnose problems with ternary/if statements don't
allow clauses, when type-checked separately, to have unresolved type
variables because that doesn't help to find errors.
2017-08-03 12:16:53 -07:00
Pavel Yaskevich
e8744af283 [QoI] Improve diagnostics for assignment expression
Currently `visitAssignExpr` always attempts to use type
derived from destination as a contextual type for assignment
source type-checking, which doesn't always lead to better
results.

Resolves: SR-5081
2017-08-02 18:17:49 -07:00
swift-ci
995a0e77b6 Merge pull request #11281 from xedin/rdar-24329052 2017-08-01 12:56:29 -07:00
Pavel Yaskevich
bfbbcc1c91 [QoI] Improve diagnostics for misaligned archetypes with the same name in calls
Resolves: rdar://problem/24329052.
2017-08-01 12:17:16 -07:00
Alex Hoppen
ebd701c4b7 Represent the name of destructors by a special DeclBaseName
No longer use the known identifier `deinit` for destructors. This allows
classes to have functions called `deinit`.
2017-07-28 19:20:02 +02:00
Slava Pestov
b316dfc676 Sema: Fix constructor diagnostics
Noticed by inspection. I don't have a test case.
2017-07-27 22:04:39 -07:00
swift-ci
18c8dc58ab Merge pull request #11223 from xedin/rdar-33477726 2017-07-27 15:47:11 -07:00
Pavel Yaskevich
242006706e [QoI] Improve diagnostics of unsatisfied generic requirements
Fixes a problem related to presence of InOutType in function parameters
which diagnostics related to generic parameter requirements didn't handle
correctly, and improves diagnostics for unsatisfied generic requirements
in operator applications, which we didn't attempt to diagnose at all.

Resolves: rdar://problem/33477726
2017-07-27 15:06:12 -07:00
John McCall
0730a27f5b Compute the expression range correctly for substring-to-string fixits.
rdar://33474838
2017-07-26 19:10:55 -04:00
Robert Widmann
04e4c8c9ce Update CSDiag to use the proper InOutType convention 2017-07-26 13:15:19 -07:00
David Zarzycki
1504c2ede7 [QoI] Ignore implicit conversions during mutation diagnostics
This change helps diagnoseSubElementFailure() avoid the unknown error
path in more scenarios.
2017-07-21 10:09:47 +01:00
Joe Groff
6e9f4dcd62 Sema: Avoid asking for the SecondType of Constraints that don't have them.
Assertions tripped while trying to reproduce SR-5513.
2017-07-20 16:04:30 -07:00
Robert Widmann
fd7c1f8bc0 Merge pull request #10889 from CodaFi/the-bit-ter-pill
Consistently Pass Parameter Flags
2017-07-19 13:14:50 -07:00
Robert Widmann
2968b03312 Merge pull request #11048 from CodaFi/optional-illusion
[NFC] Adjust return type of getTypeOfExpressionWithoutApplying
2017-07-19 10:45:27 -07:00
Robert Widmann
5dfe3364a2 Redo a hack in CSDiag
Turns out keeping the "mutability classifier" only affects one diagnostic.
2017-07-19 09:49:32 -07:00
Robert Widmann
8cdddef2f8 Refactor Params to use flags
Also, begin to pass around base types instead of raw InOutType types.  Ideally, only Sema needs to deal with them, but this means that a bunch of callers need to unwrap any inouts that might still be lying around before forming these types.

Multiple parts of the compiler were slicing, dicing, or just dropping these flags.  Because I intend to use them for the new function type representation, I need them to be preserved all across the compiler.  As a first pass, this stubs in what will eventually be structural rules as asserts and tracks down all callers of consequence to conform to the new invariants.

This is temporary.
2017-07-19 09:49:32 -07:00
Slava Pestov
707e6de9a4 Merge pull request #10436 from slavapestov/gut-resolve-type-in-context
Remove DeclContext walk from resolveTypeInContext()
2017-07-19 01:10:55 -07:00
Pavel Yaskevich
4d2ace6ff0 Merge pull request #11049 from xedin/rdar-32431736-fix
[QoI] Fix position of the fix-it related to raw representable conversion
2017-07-18 23:12:37 -07:00
Pavel Yaskevich
2bec75e069 [QoI] Fix position of the fix-it related to raw representable conversion
Part of the fix-it for conversion from optional to raw representable
was inserted at the incorrect position which produces invalid expression.

Resolves: rdar://problem/32431736
2017-07-18 22:13:20 -07:00
Slava Pestov
83684eb08a Sema: Remove LookupResult::Entry in favor of AST's LookupResultEntry
Both types store a base declaration and a result declaration;
we can remove one. Soon, it will change to store a base
declaration context, instead.
2017-07-18 22:09:19 -07:00
Robert Widmann
c42f4eabc6 Remove a latent Optional<Type> from independent expr checking 2017-07-18 19:35:28 -07:00
Robert Widmann
ebfb3e8fd5 [NFC] Merge ExprCleaner and ExprCleanser
The distinction was made between these two because of rdar://25341015,
wherein we needed a diagnostic that could detect the shadowing of
global functions by calls in protocols that don't match any
of the protocol's members.

This used to function by hoping that we had an argument tuple type lying
around after type checking.  The expr cleaner would re-write that
type into the AST and we would look up based on it.  Now that we write
Type() into the AST on failure, we must instead type check the
component parts of the argument themselves to form a tuple
type to make the lookup.
2017-07-18 18:15:37 -07:00
Mark Lacey
96ff76cf83 [CS] Use the type map in eraseOpenedExistentials. 2017-07-17 14:18:49 -07:00
Mark Lacey
3d387dd906 Change typeCheckExpression() to Type.
Doing this allows us to return ErrorType in some circumstances where we
want to communicate that we don't have a usable type rather than writing
ErrorType directly into the type of the expression root, avoiding a
mutation of the expression tree in a failure case.
2017-07-16 23:43:13 -07:00
Mark Lacey
9e4523a463 [CS] Use ConstraintSystem::getType. 2017-07-16 12:19:52 -07:00
Mark Lacey
fff29b1bb6 Update CSDiag to hold ConstraintSystems by reference. 2017-07-16 00:18:27 -07:00
Slava Pestov
a39b5eb53b Sema: Move preCheckExpression() out of solveForExpression()
There are two "RAII cleaners" here:

- CleanupIllFormedExpressionRAII cleans up the Expr in its final state
- ExprCleanser walks the Expr before it is mutated and collects
  sub-expressions, then cleans those up after

The subtle difference comes into play if we started to apply the
solution (which can fail, leaving the AST in an inconsistent state)
or if preCheckExpression() modified the AST.

The latter case was causing an ASan failure because we were not
cleaning up type variables in new nodes introduced by
preCheckExpression().

Fix this by moving the preCheckExpression() call out of
solveForExpression(), so that if solveForExpression() is called
with TypeCheckExprFlags::SkipApplyingSolution, we don't mutate the
AST at all.

Sigh...

Fixes <rdar://problem/33277279>.
2017-07-14 16:46:51 -07:00
Alex Hoppen
f8c2692f79 Introduce special decl names
Special DeclNames represent names that do not have an identifier in the
surface language. This implies serializing the information about whether
a name is special together with its identifier (if it is not special)
in both the module file and the swift lookup table.
2017-07-11 19:04:13 +02:00
Mark Lacey
916ce8994b [Constraint system] Update type map code for recursion through salvage().
When we track which expressions we're already in the middle of type
checking, we need to ensure that we also track the constraint system
which has the types for that expression, and then transfer those types
into our current constraint system so that we do not fail to look them up.
2017-07-09 12:11:31 -07:00
Robert Widmann
9a4fb8c2f0 Merge pull request #10790 from CodaFi/disjunction-junction
[Gardening] Rename getInOutOrLValueObjectType to getWithoutSpecifierType
2017-07-06 11:28:21 -07:00
Pavel Yaskevich
be204f27d2 Merge pull request #10779 from xedin/rdar-33135487
[QoI] Don't try to lookup members on incorrect type while diagnosing keypath components
2017-07-06 10:04:42 -07:00
Robert Widmann
957d633185 Rename getInOutOrLValueObjectType to getWithoutSpecifierType
Prepares the AST for a future in which more than just inout and
@lvalue need to be stripped off of ephemeral types.
2017-07-06 09:35:04 -07:00
Alex Hoppen
ff6747de77 Merge pull request #10745 from ahoppen/diagnostics-adjustments-declname
[Diag] Change function diagnostics to take a DeclName parameter
2017-07-06 13:26:56 +02:00