Commit Graph

1177 Commits

Author SHA1 Message Date
Greg Parker
e8475cc130 Revert "Use conditional conformances to implement Equatable for Optional, Array and Dictionary" 2017-11-15 14:17:22 -08:00
Doug Gregor
1f9b28a117 [Type checker diags] Check generic arguments for any generic function.
This includes functions without type parameters that are generic
because they are members of a generic context. This addresses a
diagnostics regression because the '==' operators for Optional, Array,
and Dictionary were made into members.

The resulting error message is a little ugly, but is more informative
(and much shorter) than what we had before.
2017-11-14 16:23:20 -08:00
Jordan Rose
ca1979c920 Improve diagnostics for setting a 'let' property in a delegating init 2017-11-09 18:08:01 -08:00
Slava Pestov
50fa92c8a7 Merge pull request #12567 from gregomni/diagnosis
[Sema] Better ambiguity diagnosis in overloaded function calls
2017-10-22 22:49:39 -07:00
gregomni
345c4a933d Save unresolved arg number from callee candidate info, use it to diagnose ambiguity sooner and
more specifically.
2017-10-22 10:32:11 -07:00
gregomni
18a113e584 We can produce better diagnostics for subscript candidates by noticing when the
subscript is on the destination side of an assignment and restricting matching
overload candidates to only the set-able members.

Also, if we are left with a single candidate, we can recheck unresolved index
expressions with better parameter info.
2017-10-21 14:02:58 -07:00
Greg Titus
bec95b2caa Merge pull request #12368 from gregomni/callee
[Sema] Some cleanup of CSDiag by splitting off the CalleeCandidateInfo class
2017-10-12 13:24:33 -07:00
gregomni
774dbdfa87 Some cleanup of CSDiag by splitting off the CalleeCandidateInfo class and
declaring a few formerly static methods that both files now need in a new
CSDiag.h.
2017-10-11 13:03:48 -07:00
Huon Wilson
ec6c83aa44 [Sema] Check conditional conformances for generic function calls early.
This allows for better (although not perfect) diagnostics, and more guarantees
of correctness.
2017-10-10 20:17:42 -07:00
Slava Pestov
6111a6a964 Sema: Replace a few mapTypeOutOfContext() calls with ArchetypeType::getInterfaceType() 2017-10-07 05:44:58 -07:00
Slava Pestov
6def545696 AST: Remove GenericEnvironment::containsPrimaryArchetype()
This is no longer necessary now that archetypes refer back to a
GenericEnvironment.
2017-10-07 04:46:37 -07:00
Slava Pestov
044af751f3 Sema: Fix a failure to emit a diagnostic
CSDiag was misinterpreting the result of checkGenericArguments().

A result of SubstitutionFailure does not mean a diagnostic was
emitted, only a result of Failure means that. This fixes a case
where we did not emit a diagnostic, result in a crash on invalid.

The diagnostic is still poor, but that's better than crashing.

Fixes <https://bugs.swift.org/browse/SR-5932>,
<rdar://problem/34522739>.
2017-09-27 16:39:06 -07:00
Pavel Yaskevich
9d9a6c6231 [Diagnostics] Restore inout ParamDecl types properly after type-check
We are currently in process of removing `InOutType`
so `VarDecl::get{Interface}Type` is going to wrap base
type into `InOutType` if its flag indicates that it's
an `inout` parameter declaration. But such type can't
be restored directly using `VarDecl::set{Interface}Type`
caller needs additional logic to extract base type.

Resolves: rdar://problem/33613329
2017-09-25 17:38:28 -07:00
Slava Pestov
55916fa128 Sema: Remove usages of getDeclaredTypeOfContext() 2017-09-19 22:12:29 -07:00
Kacper Harasim
3902688b04 [Diagnostics] Resolves: SR-5324 Improved diagnostic when instance member of outer type is referenced from nested type (#11609)
* [Diagnostics] Improved error diagnostics when inner type references instance member of outer type

Resolves: SR-5324.
2017-09-19 14:08:16 -07:00
Slava Pestov
a102341c9c Merge pull request #11640 from gibachan/fixit-nested-static-value
[Qol]Fixit nested static value
2017-09-14 22:56:19 -07:00
Slava Pestov
defb9cd5b6 AST: Add ASTContext::Id_ArrayLiteralElement 2017-09-11 21:48:01 -07:00
John McCall
2d3d6addc0 Delay the validaton of storage accessors until finalization.
The base mutability of storage is part of the signature, so be sure
to compute that during validation.  Also, serialize it as part of
the storage declaration, and fix some places that synthesize
declarations to set it correctly.
2017-09-10 04:56:02 -04:00
Robert Widmann
abce63a1b3 [NFC] Scale back more uses of InOutType 2017-09-05 21:56:58 -04:00
Mark Lacey
49351d11b4 [Constraint system] Emit a debug message when we enter salvage. 2017-09-01 14:00:06 -07:00
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