Commit Graph

26 Commits

Author SHA1 Message Date
Kavon Farvardin
48beac231c Test: misc. test updates for NoncopyableGenerics 2024-03-14 23:10:44 -07:00
Kavon Farvardin
01864d9af4 Sema: replace legacy Copyable containment check
We can use part of the new infrastructure if we simply handle abstract
conformances to Copyable, which is what we'd get upon lookup for a
nominal in the old world. This means that we can merge diagnostics for
the containment test together, and fix differences with deinit
diagnostics.
2024-03-12 11:05:25 -07:00
Kavon Farvardin
f296d8e158 NCGenerics: mass XFAIL tests
It's easier to get a handle on regressions while working through
failures if the tests that are known to not pass are XFAIL'd for
NoncopyableGenerics.
2024-02-20 18:26:05 -05:00
Anthony Latsis
ff2a5e06f6 [NFC] test: Move unqualified init expression tests out of test/Parse 2024-01-02 16:27:57 +03:00
Anthony Latsis
d7b52e96c4 Move unqualified init diagnosis from Parse to Sema 2023-12-25 21:17:20 +03:00
Michael Gottesman
40449a6987 [move-only] Emit a clearer message around deinits.
Specifically:

1. Fix the error message so that when we say you can't have a deinit that a
deinit can be on a noncopyable type along side a class or an actor.

2. Even though we already error on @objc enums and say they cannot be
noncopyable, we did not emit an error on the deinit saying that @objc enums
cannot have a deinit. I put in a nice to have error just to make it even
clearer.

rdar://105855978
rdar://106566054
2023-03-12 14:47:34 -07:00
Anthony Latsis
ff7f117025 Gardening: Migrate test suite to GH issues: Parse 2022-09-02 01:44:24 +03:00
Doug Gregor
1b4197235f [Syntax] Use FunctionSignature for initializer declarations.
Initializer declarations were missing support for `async`, in part
because they deplicated most of the `FunctionSignature` production.
Instead, use `FunctionSignature` consistently and let the presence of a
result type be a semantic error.
2022-07-13 21:49:23 -07:00
Kavon Farvardin
c4fc99e71d update diagnostic since actors can have deinits 2022-02-28 16:24:55 -07:00
Slava Pestov
2ef101c815 Sema: Don't add local functions to TC.definedFunctions
Instead, check them and their error handling right away.

In addition to fixing the crash in the radar, this also causes
us to emit unused variable warnings in functions containing
local functions.

Eventually, TC.definedFunctions should go away altogether.

Fixes <rdar://problem/53956342>.
2019-08-07 00:37:21 -04:00
Jordan Rose
ec0719d3e0 Handle parsing deinitializers without bodies for .swiftinterfaces
The presence of a deinitializer will eventually indicate whether a
class's deinitializer is non-trivial for non-resilient modules.

Also improve recovery for normal source files for various bad ways
of declaring a deinitializer.
2018-08-16 15:48:13 -07:00
Slava Pestov
3454a54ee3 Sema: Move checkProtocolSelfRequirements() and checkReferencedGenericParams() to typeCheckDecl()
Checking these in a code path called from validateDecl() is overkill;
it's sufficient to perform these checks in declarations in primary files
only.
2018-07-31 02:08:37 -07:00
Graydon Hoare
08bb212967 [Diagnostics] s/may/must/ in 'may not have bodies' 2017-09-29 16:09:23 -04:00
Doug Gregor
81daa1f53b [Type checker] Be more tolerant of broken initializer declarations. 2017-02-07 15:22:50 -08:00
Matthew Carroll
7882ddcf40 [DiagnosticsQoI] SR-3600: Better recovery for trying to name an initializer, deinitializer, or subscript
Add a diagnostic to remove the name of an initializer, deinitializer, or subscript. The identifier token is consumed and skipped to prevent the parser from emitting additional error messages.

Add tests to verify that the name is removed from initializers, deinitializers, and subscripts declared with a name.
2017-01-17 17:21:56 -05:00
David Farler
b7d17b25ba Rename -parse flag to -typecheck
A parse-only option is needed for parse performance tracking and the
current option also includes semantic analysis.
2016-11-28 10:50:55 -08:00
Rintaro Ishizaki
2cac9c52ef [QoI] Improve fixit for missing parameter clause in initializer decl (#5042)
Fix `init {}` to `init() {}` instead of `init () {}`.
2016-09-29 11:02:33 +09:00
Rintaro Ishizaki
e6b38e32e8 [Parse][SR-2080] Improve fix-it for initializer delegation
Suggest inserting `super.` only if it's in designated *class* initializer,
otherwise `self.`.
2016-07-25 21:09:03 +09:00
Daniel Duan
ea0a2d3b8d [Parser][Qol] improve diagnostic with missing "self." in init
This improvement was reported in
[SR-852](https://bugs.swift.org/browse/SR-852).

before:

```
$ cat t.swift
class A {
    init(x: Int) {}

    convenience init() { init(x: 1) }
}

$ swiftc -c t.swift
t.swift:6:13: error: initializers may only be declared within a type
    init(x: 1)
        ^
t.swift:6:17: error: expected parameter type following ':'
    init(x: 1)
            ^
t.swift:6:17: error: expected ',' separator
    init(x: 1)
            ^
           ,
t.swift:6:17: error: expected parameter type following ':'
    init(x: 1)
            ^
t.swift:6:17: error: expected ',' separator
    init(x: 1)
            ^
                                                                                                                                                       ,
```

after:

```
t.swift:6:9: error: missing 'self.' at initializer invocation
    init(x: 1)
    ^
    self.
```
2016-03-03 00:11:21 -08:00
Chris Lattner
ada5487153 add fixit tests to random other tests.
Swift SVN r31006
2015-08-04 20:35:36 +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
Dmitri Hrybenko
3b04d1b013 tests: reorganize tests so that they actually use the target platform
Most tests were using %swift or similar substitutions, which did not
include the target triple and SDK.  The driver was defaulting to the
host OS.  Thus, we could not run the tests when the standard library was
not built for OS X.

Swift SVN r24504
2015-01-19 06:52:49 +00:00
Argyrios Kyrtzidis
628567bfe5 [Frontend] Make it erroneous if no frontend action is specified when invoking the frontend, and update tests.
Swift SVN r21584
2014-08-29 19:17:37 +00:00
Dave Abrahams
1676c8d59e Improve clarity/consistency of deinit diagnostics
The old message, "deinitializer does not have a parameter clause," was
confusing because it would be issued for a deinit that clearly *had* a
parameter clause.  Also, one out of three messages called deinitializers
"'deinitializer' functions."  Since "deinitializer" does not appear in
the program text, it doesn't make sense to quote it, either.

Swift SVN r21468
2014-08-27 00:01:15 +00:00
Ted Kremenek
fad874708e Adjust test cases.
Swift SVN r17964
2014-05-12 22:01:52 +00:00
Chris Lattner
d3df74d7a9 rename test
Swift SVN r17360
2014-05-04 04:25:37 +00:00