Skip to content

[analyzer] Failure in language/constants_2018/constant_types_test/04 #47302

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
eernstg opened this issue Sep 28, 2021 · 7 comments
Closed

[analyzer] Failure in language/constants_2018/constant_types_test/04 #47302

eernstg opened this issue Sep 28, 2021 · 7 comments
Assignees
Labels
dart-model-analyzer-spec Issues with the analyzer's implementation of the language spec legacy-area-analyzer Use area-devexp instead. P2 A bug or feature request we're likely to work on

Comments

@eernstg
Copy link
Member

eernstg commented Sep 28, 2021

CL https://dart-review.googlesource.com/c/sdk/+/214644 changed said test such that it expects to use a type variable in the initializer list of a constant constructor as a type literal without error:

class C<X> {
  final t;
  const C(): t = X;
}

This used to be a compile-time error, but with dart-lang/language#1860 it is no longer an error (a type variable used as an expression is a potentially constant expression).

This is part of the constructor-tearoffs feature bundle and part of the work requested in #47150.

NB: Due to a glitch in Gerrit (which has been reported), the change does not cause any buildbots to turn red, and there will not be an approval for the failure. This issue would have been the one to mention in that approval.

@eernstg eernstg added legacy-area-analyzer Use area-devexp instead. dart-model-analyzer-spec Issues with the analyzer's implementation of the language spec labels Sep 28, 2021
@eernstg
Copy link
Member Author

eernstg commented Sep 28, 2021

/cc @scheglov.

@scheglov
Copy link
Contributor

Do we allow type variables only when constructor-tearoffs is enabled for the library? Or always?

@srawlins srawlins added the P2 A bug or feature request we're likely to work on label Sep 28, 2021
@eernstg
Copy link
Member Author

eernstg commented Sep 29, 2021

This is all part of the constructor-tearoffs feature bundle, so it should only be enabled there.

@scheglov scheglov self-assigned this Sep 29, 2021
@srawlins
Copy link
Member

tests/language/const/instantiated_function_constant_test.dart exercises this new rule too.

copybara-service bot pushed a commit that referenced this issue Sep 29, 2021
…nstants().

We need to check for more features now.

Bug: #47302
Change-Id: I601160aa4133e25695ead18d180f7efd2e410300
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215005
Reviewed-by: Brian Wilkerson <[email protected]>
Reviewed-by: Samuel Rawlins <[email protected]>
Commit-Queue: Konstantin Shcheglov <[email protected]>
@scheglov
Copy link
Contributor

It seems that type variables were already allowed as "potentially constant type expression" for null safety.
https://github.com/dart-lang/language/blob/master/accepted/2.12/nnbd/feature-specification.md#const-objects

So, my understanding is that now we enable them as "potentially constant expression" when constructor-tearoffs is enabled. This seems to fix the language test.

@scheglov
Copy link
Contributor

@eernstg
Copy link
Member Author

eernstg commented Sep 30, 2021

enable them as "potentially constant expression" when constructor-tearoffs is enabled

Exactly, thanks!

copybara-service bot pushed a commit that referenced this issue Sep 30, 2021
Bug: #47302
Change-Id: I95d1b94efe5cc2877d37bc5ac615869233395189
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215014
Reviewed-by: Samuel Rawlins <[email protected]>
Reviewed-by: Brian Wilkerson <[email protected]>
Commit-Queue: Konstantin Shcheglov <[email protected]>
copybara-service bot pushed a commit that referenced this issue Oct 6, 2021
Additionally, I see that _deferred types_ are not constant, and make
great examples of non-const function references, constructor references,
and type literals.

Fixes language/const/constant_type_variable_test

Bug: #46020,
     #47302
Change-Id: I9df3a9eb758d058888f7d374b76756ec1443c8d6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215860
Commit-Queue: Samuel Rawlins <[email protected]>
Reviewed-by: Konstantin Shcheglov <[email protected]>
Reviewed-by: Brian Wilkerson <[email protected]>
copybara-service bot pushed a commit that referenced this issue Oct 12, 2021
…bled.

This requires passing the runtime type arguments into the
InstanceCreationEvaluator, so that it can store them in a lexical scope
map.

Bug: #47302
Change-Id: I6b9d660f20b981d26810f29858784c034cc8abfd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215960
Commit-Queue: Samuel Rawlins <[email protected]>
Reviewed-by: Brian Wilkerson <[email protected]>
Reviewed-by: Konstantin Shcheglov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dart-model-analyzer-spec Issues with the analyzer's implementation of the language spec legacy-area-analyzer Use area-devexp instead. P2 A bug or feature request we're likely to work on
Projects
None yet
Development

No branches or pull requests

3 participants