Open lrhn opened 7 years ago
@munificent I don't think there's any work for the formatter, but it would be good to double check that.
About the need to adjust the formatter, and possibly other tools: The grammar had to be extended with support for a new construct, namely
constructorInvocation ::=
typeName typeArguments '.' identifier arguments
and that construct is then used in a couple of places. The point is that we can now have things like C<int>.someName(42)
, and the ability to have actual type arguments after the class name is new. So every tool that has a parser which hasn't already been updated to handle this will need an update.
Yep, but the formatter uses the analyzer parser, so I think it's probably fine.
Turns out there is one case the formatter needs to handle:
SomeGenericClass<int>.someNameConstructor();
I added support for that in https://github.com/dart-lang/dart_style/commit/b89b572673c30d6124d61bda69710ac4d25c2e56.
Actually, since this is the meta issue that has the spec as the long pole, moving to the Dart2 Stable milestone.
The formal spec bug is the only remaining issue, so closing this out.
Should this also work for factory constructors? I'm getting
NoSuchMethodError: No static method 'from' declared in class 'BigInt'.
when calling BigInt.from(5)
, f.e.
BigInt.from
is an external factory
constructor.
It should work for all constructors. How are you running the code?
@lrhn I have Dart v2 installed at /opt/dart-v2
and I run /opt/dart-v2/bin/pub run test
.
I could be that pub test
runs the dart
executable in PATH
instead of the one in the same directory.. Can I pass to pub which Dart executable to use?
@stevenroose perhaps https://github.com/dart-lang/pub/issues/1807
Re-opening to track Angular implementation + communication and validation.
Good news. AngularDart has verified, mostly thanks to @MichaelRFairhurst, that optional new/const works at the latest dev SDKs, including in metadata annotations. Here is a sample PR where we removed it from all example applications: https://github.com/dart-lang/angular/pull/1408.
great news indeed!
Atenciosamente,
Jonathan Rezende
Em 14 de jun de 2018, à(s) 23:59, Matan Lurey notifications@github.com escreveu:
Good news. AngularDart has verified, mostly thanks to @MichaelRFairhurst https://github.com/MichaelRFairhurst, that optional new/const works at the latest dev SDKs, including in metadata annotations. Here is a sample PR where we removed it from all example applications: dart-lang/angular#1408 https://github.com/dart-lang/angular/pull/1408.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/dart-lang/sdk/issues/30921#issuecomment-397499124, or mute the thread https://github.com/notifications/unsubscribe-auth/AF6Y3j2vYdc7pCbOXK-c1eKgRx-9YJKEks5t8yMegaJpZM4PnE6T.
@kwalrath is the docs part of this complete?
It depends on what you mean by "complete". The language tour has a note that new
is optional.
~I'm working on a PR to improve on that (making optional new
the default in the tour, and adding an example for optional const
).~ In the language tour, optional new
is (as of dart-lang/site-www#940) the default, and there's a new example for optional const
: www.dartlang.org/guides/language/language-tour#using-constructors
For the rest of the docs and examples, we're planning to wait until dartfmt --fix
is out.
Tracking issue: dart-lang/site-www#870
Nothing left here is blocking for Dart 2 here, I think. As soon as dartfmt --fix
is available for general use, we should announce this, and encourage people to migrate.
@munificent should we consider adding this to the dartfmt presubmit for the SDK now to start migrating and shaking out bugs? We probably really don't want to do that for tests though, so we'd need some way to exclude them. So maybe better to just start manually converting SDK code?
So maybe better to just start manually converting SDK code?
Yeah, I think running --fix
manually is a better first step.
Does the Dart VM read SDK code when you run with dart --no-preview-dart-2
?
Does dart2js read SDK code when you compile with dart2js --no-preview-dart-2
?
If so, dropping new
and const
from the SDK is blocked on removing those flags.
Does dart2js read SDK code when you compile with dart2js --no-preview-dart-2?
dart2js does - we use the CFE even in Dart1 mode, and the CFE will parse with the missing new/consts always (it is not hidden under a flag).
@lrhn what remains before we can close this as completed?
SDK and specification still missing. I guess communication is part of communicating Dart 2.0.
Should "Remove new and optional const from SDK code" still be part of this task? This meta issue was a planned feature for Dart 2.0, which has completed. AFAIK, no one intends to do this task any time soon. Especially with all of the work being done on the SDK libraries; this would cause a lot of churn if it landed any time in the next few months.
Close this meta issue?
@srawlins I would say keep it here as a means of tracking it. That doesn't mean it has to be prioritized higher than the current work on the SDK libraries.
Dart 2 will make
new
andconst
operators optional in some cases. The feature is described in https://github.com/dart-lang/sdk/blob/master/docs/language/informal/implicit-creation.md.This feature needs support from, at least, the common front-end. The kernel compiler can, and likely will, generate the same kernel code whether an optional
new
orconst
is present or not, so back-ends should be unaffected. Effectively, the kernel (or even the parser) can perform automatic "new/const" insertion on the program, as soon as it can recognize an invocation as referring to a constructor rather than a static method.The feature extends the grammar with syntax that wasn't previously valid, so the formatter likely needs to be prepared for it. The analyzer may need to be prepared for the different syntax as well.
We will not back-port this feature to non-kernel based backends.