The BodyBuilder now operates on TypeBuilders instead of DartType.
This
* enables better error messages, and
* paves the way for removing the dependency on OutlineBuilder from BodyBuilder.
Change-Id: I2fb5e61a4d30c11f01d04cc0150d5352b4fb6999
Reviewed-on: https://dart-review.googlesource.com/74064
Reviewed-by: Jens Johansen <jensj@google.com>
With this change, analyzer error codes can be generated from messages.yaml
and those error codes easily translated from the corresponding fasta error.
Each fasta error code in messages.yaml that has an "index:" field
(see prior CL https://dart-review.googlesource.com/c/sdk/+/74040)
now has an Analyzer error code automatically generated
with the information in messages.yaml. In addition
a list of all indexed errors is generated so that a fasta error
code can be quickly translated into an Analyzer error code.
Change-Id: I2d534b7349590ddd54996f564db786c6ffe259b3
Reviewed-on: https://dart-review.googlesource.com/74240
Commit-Queue: Dan Rubel <danrubel@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This allows dartdevk to be used in the context of an existing build
system based on Analyzer summary files. This will ease migration of
existing dartdevc users over to dartdevk.
Change-Id: I8413f906e384f3f33c98e450adc0860f6fa7bc53
Reviewed-on: https://dart-review.googlesource.com/65641
Reviewed-by: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Vijay Menon <vsm@google.com>
Commit-Queue: Jenny Messerly <jmesserly@google.com>
In Fasta's outline builder, parse mixin declarations as if they were
the corresponding class declaration:
mixin M<T0,...,Ti> on S0,S1,...,Sj implement I0,...,Ik {...}
is parsed as if it were:
class M<T0,...,Ti> extends S0 with S1,...,Sj implements I0,...,Ik {
...
}
This supports the syntax and should automatically provide an
implementation of the runtime semantics on the VM. Not all of the
required static checks are implemented in the front end.
Change-Id: Ice65e93446222484272f8f7db0de2d18c352f56b
Reviewed-on: https://dart-review.googlesource.com/73760
Reviewed-by: Dan Rubel <danrubel@google.com>
The type inferrer is no longer used (and wasn't necessary to begin
with, it should have been exposed via the helper object instead).
Also some other tweaks that should help me avoid merge conflicts.
Change-Id: I1f2aade93f9c836cc02dac6c002f48156caf2c76
Reviewed-on: https://dart-review.googlesource.com/74063
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Peter von der Ahé <ahe@google.com>
This replaces the begin/endMixinApplication events which were used in both
```
class A = B with M;
```
and
```
class A extends B with M { }
``
with different events for each of the above situations.
This change facilitates properly handling class declarations of the form
```
class A with M { }
```
Removed event:
* beginMixinApplication
* endMixinApplication
Added events:
* handleNamedMixinApplicationWithClause
* handleClassWithClause
* handleClassNoWithClause
Change-Id: Ifa0ecfd7ff8c408087ad78036ad35ba4a00728c6
Reviewed-on: https://dart-review.googlesource.com/73940
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
This removes the code the generates an error when a `with` clause
is used without an `extends` clause as in
```
class C with M { }
```
This is the first of several CLs to update the parser
as this CL only prevents the error from being generated.
Change-Id: I1d5c8577902e253a4c83cda2f6a1d4ab98319903
Reviewed-on: https://dart-review.googlesource.com/73687
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
We had implemented the rule for invalid returns in asynchronous
non-generator functions with return type T and a return expression
with static type S:
is an error if flatten(T) is void and flatten(S) is not void,
dynamic, or Null
and the actual rule should be:
is an error if T is void and flatten(S) is not void, dynamic, or
Null
which requires T to be exactly void and so signals fewer errors.
Change-Id: I296bb8a607d6e5ad862017674091eafe0f6016da
Reviewed-on: https://dart-review.googlesource.com/73740
Commit-Queue: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
The analyzer can't tell that `unhandled` is guaranteed not to return,
so it thinks that `flattenName` might exit without returning a value.
An easy workaround is to return the result of calling `unhandled`.
This is needed to roll kernel into the internal Google codebase, in
which the "missing_return" warning causes build failures.
Change-Id: I38133db0c2058d687c2f408cc8c8dbf224551408
Reviewed-on: https://dart-review.googlesource.com/73560
Reviewed-by: Kevin Millikin <kmillikin@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Replace most methods with names containing CompileTimeError with corresponding
Problem methods.
Also make Severity.error the default severity.
Change-Id: I4f47bf71dec02347407f2ce4ccfdb04730daf51b
Reviewed-on: https://dart-review.googlesource.com/73221
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Peter von der Ahé <ahe@google.com>
Commit-Queue: Peter von der Ahé <ahe@google.com>
This CL addresses one of the issues in https://github.com/dart-lang/sdk/issues/34041
by fixing an AstBuilder crash and improving recovery of super constructor calls
in a constructor initializer list.
In addition, this adds a TestDescriptor adjustValidUnitBeforeComparison field
to support the new recovery tests.
Change-Id: I9e687aed34ea293700bd45d7c13ce36e83a00a05
Reviewed-on: https://dart-review.googlesource.com/73286
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
This reverts commit f872c17a85.
Reason for revert: After the CQ was green someone else made changes which this CL is not compatible with. The CQ lands if the tests passed
and doesn't rebase before doing so.
Original change's description:
> Remove addCompileTimeError in favor of addProblem
>
> Replace most methods with names containing CompileTimeError with corresponding
> Problem methods.
>
> Also make Severity.error the default severity.
>
> Change-Id: I85a340168848cd3b4375b3f53cb0361251ed6e5d
> Reviewed-on: https://dart-review.googlesource.com/73100
> Commit-Queue: Peter von der Ahé <ahe@google.com>
> Reviewed-by: Jens Johansen <jensj@google.com>
TBR=ahe@google.com,jensj@google.com
Change-Id: I3ea736a9752805adb3bacc8b67e8eb1435c1bf69
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/73181
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
Previously we could get something like this:
```
regress_32660_test_06.dart:9:7: Context: 'foo' is defined here.
class I extends G implements H {
^^^
```
because a SyntheticForwarder was added with a file location of the
class.
It now instead goes to the forwarding stub target and says
```
regress_32660_test_06.dart:6:3: Context: 'foo' is defined here.
foo(int x, {int y}) => y;
^^^
```
Change-Id: I6fb1b958f58635c9afffa8e58cd49eb69df28afd
Reviewed-on: https://dart-review.googlesource.com/72680
Reviewed-by: Peter von der Ahé <ahe@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Replace most methods with names containing CompileTimeError with corresponding
Problem methods.
Also make Severity.error the default severity.
Change-Id: I85a340168848cd3b4375b3f53cb0361251ed6e5d
Reviewed-on: https://dart-review.googlesource.com/73100
Commit-Queue: Peter von der Ahé <ahe@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
The analyzer can't tell that `unhandled` is guaranteed not to return,
so it thinks that `isValidImplementation` might exit without returning
a value. An easy workaround is to turn the call to `unhandled` into a
`throw`.
This is needed to roll kernel into the internal Google codebase, in
which the "missing_return" warning causes build failures.
Change-Id: Ia88b6cdef3693ab4646470616c7f868c5bad0502
Reviewed-on: https://dart-review.googlesource.com/72900
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
Implement the feature spec for checking returns against inferred
function return types:
https://github.com/dart-lang/sdk/blob/master/docs/language/informal/invalid_returns.md
with the change that an invalid return without a subexpression is
a warning, not an error. This is because it is a warning in the
analyzer and it would be a breaking change to turn it into an
error.
The check for valid returns is moved to exactly where we handle
returns, rather than in ensureAssignable which is used as a
helper in a lot of places. A bug in type inference was fixed: we
would use `void` for the type of return without a subexpression
instead of `null`. To accommodate that we would use a
non-standard subtyping relation for returns. This could lead to
us inferring a return type of `void` in cases where we should
not.
Change-Id: Iee9ece9c722f47efa305f49490d3022d0bbb9f44
Reviewed-on: https://dart-review.googlesource.com/72403
Commit-Queue: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
The below code is not okay, even if we add a noSuchMethod to C.
```
class B {
foo(int x) => x;
}
class C extends B {
foo(int x, {int y});
}
```
Issue #32660.
Change-Id: I1ace4443c3732fdd5faefa50e0d2cb68023e97c4
Reviewed-on: https://dart-review.googlesource.com/72106
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Peter von der Ahé <ahe@google.com>
E.g. `new Map<String>` is now reported as an error.
Note that this does not add a check for whether correct types are given,
so e.g.
```
class Foo<X extends num> {}
main() {
new Foo<String>();
}
```
is not caught by this fix.
Fixes#32972, #32281.
Change-Id: I57513b5c13865a828890775c8e14f7433d00bdbe
Reviewed-on: https://dart-review.googlesource.com/72382
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Peter von der Ahé <ahe@google.com>
Revert "Store named types resolution during outline building."
This reverts commit 82947cccc9.
Revert "Store reference/type for invalid types."
This reverts commit 9fb6c09015.
Revert "Clear ShadowX references that are not required after compilation."
This reverts commit 6c39bc38f3.
Revert "Store constructor field initializera when the target is not a field."
This reverts commit 12326c10e1.
Revert "Don't rewrite error Severity for special cases of front-end testing."
This reverts commit 4bb3fb6cae.
Revert "Translate ConstructorElement(s) of parameterized InterfaceType(s) to ConstructorMember(s)."
This reverts commit 62a2752b96.
Revert "Store resolution for out of range integer literals."
This reverts commit 8df84c0a00.
Revert "Infer original expression in SyntheticExpressionJudgment."
This reverts commit cec29e4aa8.
Revert "Resolve invalid 'as' constant expression."
This reverts commit 77202bf2b0.
Revert "Resolve invalid return from constructor."
This reverts commit 737e546939.
Revert "Store import prefix offset into metadata and resynthesize."
This reverts commit c30af508a4.
Revert "Get documentation comments before metadata as well."
This reverts commit 29401573d5.
Revert "Put fileEndOffset into ArgumentsJudgment and use to report argument errors."
This reverts commit d69a354026.
Revert "Return SourceSpan with actual length from _CompilationMessage."
This reverts commit ac973e5ba7.
Revert "Store codeOffset / codeLength for classes."
This reverts commit 28583df3ee.
Revert "Store and resynthesize codeOffset/codeLength for functions and methods."
This reverts commit 5a2a13c8bf.
Revert "Fix analyzer/FE integration of invalid assignments to classes."
This reverts commit a814614cf4.
Revert "Fix analyzer/FE integration of assignments to non-l-values."
This reverts commit d10204f3a0.
Revert "Fix analyzer/FE integration of assignments to ambiguous types."
This reverts commit e87efdffb4.
Revert "Fix analyzer/FE integration of assignments to ambiguous types."
This reverts commit 1b5d273fd7.
Revert "Fix analyzer/FE integration of assignment with synthetic LHS."
This reverts commit 55aa031404.
Revert "Revert "Fix analyzer/FE integration of assignments to ambiguous types.""
This reverts commit 9f795883f1.
Revert "Store code range for constructors."
This reverts commit 675b296d49.
Revert "Store codeOffset/length code fields and top-level variables."
This reverts commit 9ef53bde19.
Revert "Re-land "Fix analyzer/FE integration of assignments to ambiguous types.""
This reverts commit 40d72aec8c.
Revert "Resolve metadata for part-of directives."
This reverts commit cf1cd3eba0.
Revert "Fix analyzer/FE integration of assignment with synthetic LHS, inside class method."
This reverts commit 43a8f1d0d6.
Revert "Fix analyzer/FE integration of prefix/postfix increment of non-l-values."
This reverts commit e2aceb692e.
Revert "Fix analyzer/FE integration of postfix-of-postfix and prefix-of-prefix increments."
This reverts commit ad6f89f13b.
Revert "Fix analyzer/FE integration of some obscure invalid assignment cases."
This reverts commit f074f3c120.
Revert "Resolve namespace combinators."
This reverts commit 7e39d07916.
Revert "Fix analyzer/CFE integration of some more obscure invalid assignment cases."
This reverts commit a94e43af7c.
Revert "Refactor duplicate code in ContextAwareGenerator."
This reverts commit 1f82d37124.
Revert "Resolve required arguments after named."
This reverts commit b255f0fab6.
Change-Id: I44616db9b8ef037a2580a1ab35050da7e72ff7d8
Reviewed-on: https://dart-review.googlesource.com/72642
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Peter von der Ahé <ahe@google.com>
When invoking an expression whose static type is not a function type,
signal an error. However, allow invocations of expressions with
static type `dynamic` or `Function`. Fixes#32975.
Change-Id: Ia54d8df650076ad5c9c9c3a2c6f79ea31acbbbfe
Reviewed-on: https://dart-review.googlesource.com/72082
Commit-Queue: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Daniel Hillerström <hillerstrom@google.com>
Along with the new recovery, there are two new error codes
and their corresponding CFE counterparts:
* ParserErrorCode.IMPLEMENTS_BEFORE_ON
* ParserErrorCode.MULTIPLE_ON_CLAUSES
* ImplementsBeforeOn
* MultipleOnClauses
Change-Id: If9055c9ffa5d56495acf00889236a3a8f6d741ca
Reviewed-on: https://dart-review.googlesource.com/72123
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
This reverts commit 03c7184cca.
Reason for revert: Flutter doesn't build with after this CL because the following (kind of) program
abstract class RenderObject {
String toString({int minLevel}) => "foo";
}
abstract class ContainerRenderObjectMixin extends RenderObject {}
abstract class RenderBoxContainerDefaultsMixin implements
ContainerRenderObjectMixin {}
is wrongfully rejected. In patching this, I stumbled upon what seems to be bug in Fasta where some concrete classes arising from mixed in applications are marked as abstract, which causes the patch to produce false-positives. This needs some more investigation.
Original change's description:
> Enables arity check for overridden methods inherited from a mixin.
>
> The return type and parameter types checks are still disabled for
> mixins as there is an issue with type parameters being uninstantiated
> in mixin applications which causes the two checks to produce
> false-positives. As a result the SDK fails to compile with the two
> checks enabled because the libraries (such as collections) makes
> extensive use of mixin application with generic types. I've opened a
> separate ticket to track this issue [c.f. https://github.com/dart-lang/sdk/issues/34285].
>
> Furthermore this CL abstracts the arity check, return type check, and
> method parameter type check in checkMethodOverride to make it easier
> to understand the logic of the method.
>
> Closes https://github.com/dart-lang/sdk/issues/34235 and closes https://github.com/dart-lang/sdk/issues/32014
>
> Change-Id: Iae224926c2e99e6e89ccc3c19ec4bc7919ee48a5
> Reviewed-on: https://dart-review.googlesource.com/71781
> Commit-Queue: Daniel Hillerström <hillerstrom@google.com>
> Reviewed-by: Aske Simon Christensen <askesc@google.com>
TBR=askesc@google.com,hillerstrom@google.com
Change-Id: Idee6f53c2d6a17ea8a4103872b1183c01e4d30ce
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/72108
Reviewed-by: Daniel Hillerström <hillerstrom@google.com>
Commit-Queue: Daniel Hillerström <hillerstrom@google.com>
The return type and parameter types checks are still disabled for
mixins as there is an issue with type parameters being uninstantiated
in mixin applications which causes the two checks to produce
false-positives. As a result the SDK fails to compile with the two
checks enabled because the libraries (such as collections) makes
extensive use of mixin application with generic types. I've opened a
separate ticket to track this issue [c.f. https://github.com/dart-lang/sdk/issues/34285].
Furthermore this CL abstracts the arity check, return type check, and
method parameter type check in checkMethodOverride to make it easier
to understand the logic of the method.
Closes https://github.com/dart-lang/sdk/issues/34235 and closes https://github.com/dart-lang/sdk/issues/32014
Change-Id: Iae224926c2e99e6e89ccc3c19ec4bc7919ee48a5
Reviewed-on: https://dart-review.googlesource.com/71781
Commit-Queue: Daniel Hillerström <hillerstrom@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>