Commit Graph

760 Commits

Author SHA1 Message Date
Luciano Almeida
041051e1ed [CSDiagnostics] Tailor diagnostic for define missing member when involves array literal and unresolved member 2020-04-28 12:35:28 -03:00
Slava Pestov
742bd98402 Sema: Remove ConformanceCheckOptions::SkipConditionalRequirements
All callers can trivially be refactored to use ModuleDecl::lookupConformance()
instead. Since this was the last flag in ConformanceCheckOptions, we can remove
that, too.
2020-04-25 00:14:24 -04:00
Joe Groff
b4c7a7e85d Merge pull request #31224 from AnthonyLatsis/rename-getfullname-2
AST: Rename getFullName -> getName on ValueDecl & MissingMemberDecl
2020-04-24 12:51:28 -07:00
Robert Widmann
09db2902d2 Strip TypeExpr of its TypeLoc
Remove duplication in the modeling of TypeExpr. The type of a TypeExpr
node is always a metatype corresponding to the contextual
type of the type it's referencing. For some reason, the instance type
was also stored in this TypeLoc at random points in semantic analysis.

Under the assumption that this instance type is always going to be the
instance type of the contextual type of the expression, introduce
a number of simplifications:

1) Explicit TypeExpr nodes must be created with a TypeRepr node
2) Implicit TypeExpr nodes must be created with a contextual type
3) The typing rules for implicit TypeExpr simply opens this type
2020-04-23 17:04:38 -07:00
Pavel Yaskevich
9f02f782f3 [Diagnostics] NFC: Switch dyn_cast/get of anchor to either castToExpr or getAsExpr 2020-04-23 01:13:13 -07:00
Pavel Yaskevich
4b1aa29149 [ConstraintSystem] NFC: Adjust all uses of locator anchors to work with TypedNode 2020-04-23 01:13:13 -07:00
Pavel Yaskevich
398f37842a [ConstraintSystem] Elevate TypedNode access helpers up to the namespace
Originally such accessors were only useful for `FailureDiagnostic` but
now since `ConstraintLocator` is anchored with `TypedNode` it makes sense
to make them universally accessible.
2020-04-23 01:13:13 -07:00
Pavel Yaskevich
288e286efd Merge pull request #31192 from LucianoPAlmeida/SR-12425-diagnostics
[SR-12425] Improving diagnostics for key path application on non-convertible root type
2020-04-23 00:17:49 -07:00
Luciano Almeida
721dd7780d [NFC] Minor comment adjustments 2020-04-22 23:55:58 -03:00
Anthony Latsis
74252028ca AST: Rename getFullName -> getName on ValueDecl & MissingMemberDecl 2020-04-23 05:16:55 +03:00
Luciano Almeida
094ffd6b25 [CSDiagnostics] Adjusting KeyPathRootTypeMismatchFailure implementation and message 2020-04-22 20:30:54 -03:00
Robert Widmann
78e07c1d41 Merge pull request #31159 from CodaFi/track-star
Remove Fallback Infrastructure For Evaluator-Based Dependencies
2020-04-22 15:37:48 -07:00
Luciano Almeida
6e5be5b7d4 [CSDiagnostics] Create KeyPathRootTypeMismatchFailure to diagnose key path root fail on key path application 2020-04-21 17:38:06 -03:00
Robert Widmann
48a5432cb7 [NFC] Remove ConformanceCheckFlags::InExpression
The last read of this bit was removed when the legacy referenced name tracker was deleted in the last commit.
2020-04-20 10:22:58 -07:00
Pavel Yaskevich
967b3a3c8d [Diagnostics] Adjust getCallInfo to accept TypedNode instead of expression 2020-04-17 13:28:06 -07:00
Pavel Yaskevich
4ea7f3bbb1 [Diagnostics] Add helper functions to work with anchors - {castTo, getAs, is}Expr 2020-04-17 13:15:12 -07:00
Pavel Yaskevich
6335a4f2ef [Diagnostics] Resolve const-ness problems introduced by TypedNode
Since `TypedNode` elements are all marked as `const` diagnostics
need to get some of the APIs adjusted to support passing `const Expr *`.
2020-04-17 11:43:09 -07:00
Pavel Yaskevich
08e09fc685 [Diagnostics] Switch getType to use TypedNode 2020-04-17 11:43:09 -07:00
Pavel Yaskevich
66a07bab95 [Diagnostics] Switch getContextualType* to use TypedNode 2020-04-17 11:43:09 -07:00
Pavel Yaskevich
71ab19bdce [Diagnostics] Switch getConstraintLocator variants to accept TypedNode 2020-04-17 11:43:09 -07:00
Pavel Yaskevich
f5714bf50d [Diagnostics] Switch get{Raw}Anchor to return TypedNode
In preparation to anchor `ConstraintLocator` from `TypedNode`
let's refactor diagnostics (which is the biggest user of locators)
to support `TypedNode` instead of `Expr *`.
2020-04-17 11:43:09 -07:00
Pavel Yaskevich
4ed3665f86 [Diagnostics] Provide anchors on demand instead of storing in FailureDiagnostic
This decouples `FailureDiagnostic` from expression.
2020-04-17 11:43:09 -07:00
Pavel Yaskevich
ce324d35bf [Diagnostics] Missing member diagnostic associated with module should point to name 2020-04-14 13:53:49 -07:00
Pavel Yaskevich
b7489201ff [Diagnostic] Non-ephemeral pointer init diagnostic should point to .init if present 2020-04-14 13:01:57 -07:00
Pavel Yaskevich
cdee9a1ce3 [Diagnostics] Use new getLoc and getSourceRange methods
Split `emitDiagnostic` into `emitDiagnostic` and `emitDiagnosticAt`.

Refactor existing diagnostics to use new methods and avoid passing
location when possible.
2020-04-14 11:30:11 -07:00
Pavel Yaskevich
5dbced972f [Diagnostics] Allow failure diagnostic implementation to extend getAnchor
Some of the diagnostics have special rules about anchor location,
let's make `getAnchor` virtual and allow sub-class to override
default implementation.
2020-04-14 11:30:11 -07:00
Hamish Knight
a61223a255 [CS] Visit all fixed bindings for constraint re-activation (#30886)
[CS] Visit all fixed bindings for constraint re-activation
2020-04-10 12:27:47 -07:00
Hamish Knight
d69a42d656 [CS] Preserve compatibility for collection coercions
Previously we could allow some invalid coercions to
sneak past Sema. In most cases these would either
cause crashes later down the pipeline or
miscompiles. However, for coercions between
collections, we emitted somewhat reasonable code
that performed a force cast.

This commit aims to preserve compatibility with
those collection coercions that previously
compiled, and emits a warning telling the user to
use either 'as?' or 'as!' instead.
2020-04-10 10:16:07 -07:00
Pavel Yaskevich
42bdfc9bc6 [Diagnostics] Remove unsafe getRestrictionFor method 2020-04-09 15:35:14 -07:00
Pavel Yaskevich
6f2af1f433 [Diagnostics] Replace getChoiceFor with getCalleeOverloadChoiceIfAvailable
New name is more consistent with existing `getOverloadChoiceIfAvailable`
and allows us to clean up a couple of places where `getCalleeLocator` was
used directly before.
2020-04-09 12:44:16 -07:00
Pavel Yaskevich
6f83c08aae [Diagnostics] Remove obsolete getResolvedMemberRef 2020-04-08 16:09:08 -07:00
Pavel Yaskevich
a84e0b70fc [Diagnostics] Obsolete and remove HasComplexLocator field from diagnostic
This was useful when CSDiag was still in play but since everything
has been ported this is no longer useful.
2020-04-08 15:03:42 -07:00
Luciano Almeida
08904ffe3f [SR-12242] Apply to Arg involving ConstraintLocator::GenericArgument diagnostics improvement (#30814)
* [CSDiagnostics] Handle arg to param generic when locator points to ConstraintLocator::GenericArgument

* [test] Add SR-12242 test case

* [CSDiagnostics] Handle arg to param on Generic mismatch as a fallback diagnostic

* [CSDiagnostics] Make assign diagnostics in GenericMismatchFailure handle more cases

* [test] Adding test cases for assign expr in GenericMismatch diagnostics

* [CSDiagnostics] Improving inout to pointer argument conversions with optionals diagnostics
2020-04-06 10:25:02 -07:00
Robert Widmann
630d0f631a Merge pull request #30606 from AnthonyLatsis/rename-getfullname
[NFC] Preparations to address the «Rename to getName?» TODO on ValueDecl::getFullName
2020-04-01 09:00:04 -07:00
Pavel Yaskevich
f95cabb745 [ConstraintSystem] Allow sequence element mismatch fix to produce new holes
Type on the right-hand side of the element conversion/pattern match
should be allowed to have holes to be able to diagnose failures with
structurally incompatible types.

Resolves: rdar://problem/60832876
2020-03-30 17:48:46 -07:00
Anthony Latsis
c63b737e92 Collapse all indirect equivalents to ValueDecl::getBaseIdentifier 2020-03-29 00:36:01 +03:00
Anthony Latsis
d0ae3ee580 [AST] Replace FuncDecl::getName & EnumElementDecl::getName with ValueDecl::getBaseIdentifier 2020-03-29 00:35:51 +03:00
Holly Borla
da715f87c5 [Diagnostics] Support diagnosing references to operators without argument
application in MissingConformanceFailure::diagnoseAsAmbiguousOperatorRef
2020-03-26 08:40:32 -07:00
Pavel Yaskevich
972de2e657 Merge pull request #30627 from LucianoPAlmeida/SR-12382-improve-pointer-conversion-mismatch-diag
[SR-12382] Improve optional pointer conversion mismatch diagnostics
2020-03-25 02:22:59 -07:00
Luciano Almeida
829152bdb4 [CSDiagnostics] Handle optional Inout to typed pointer conversion diagnostics on generic mismatch 2020-03-25 01:51:30 -03:00
Anthony Latsis
667bec0f21 Merge pull request #30578 from AnthonyLatsis/memb-fail-qoi
[DiagQoI] Improve fallback fixits for static member on instance errors
2020-03-23 19:31:10 +03:00
Anthony Latsis
572f0544a2 [DiagQoI] Improve fallback fixits for static member on instance error 2020-03-23 08:27:55 +03:00
Pavel Yaskevich
89933c67da [ConstraintSystem] Don't allow explicit closure result to be implicitly converted to Void
It's allowed to convert a single statement closure from `(...) -> T` to `(...) -> Void`
_only_ if there is no explicit `return` in the body.

Resolves: [SR-12277](https://bugs.swift.org/browse/SR-12277)
Resolves: rdar://problem/52204414
2020-03-19 16:59:17 -07:00
Dmitri Gribenko
841eeb05b0 Merge pull request #30403 from MForster/forster/string-fixes
Cherry-pick StringRef->std::string conversion fixes into `master`
2020-03-17 12:09:36 +01:00
Pavel Yaskevich
7800a04de3 [Diagnostics] Adjust "missing arguments" diagnostic to store parameter indices directly
This helps to avoid allocating new type variables (which shouldn't be done regardless)
to store parameter indices when `missing arguments` diagnostic is used by other diagnostics.
2020-03-13 16:55:37 -07:00
Pavel Yaskevich
3ab8710329 [Diagnostics] Cleanup use of constraint system by ConstraintFix/FailureDiagnostic 2020-03-13 15:02:10 -07:00
Pavel Yaskevich
52cf60122b [Diagnostics] Switch isMisplacedMissingArgument to use a solution 2020-03-13 12:46:38 -07:00
Pavel Yaskevich
0fc9d1b84a [Diagnostics] Move getFunctionArgApplyInfo to Solution
Instead of relying on constraint system having solution applied
let's pass a solution directly to `getFunctionArgApplyInfo`.
2020-03-13 12:46:25 -07:00
Fred Riss
259d78a350 Adapt to llvm.org StringRef API change 2020-03-13 19:08:22 +01:00
Pavel Yaskevich
af4afe3fbc [Diagnostics] Switch FailureDiagnostic to use a solution
Make diagnostics stateless by providing them with a solution
instead of applying a solution back to constraint system and
using constraint system. Latter doesn't work well when there
is an ambiguity and multiple solutions are available instead
of one.
2020-03-13 10:37:23 -07:00