Skip to content
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

Dart and analyzer behaves in the different ways when call a raw non-function typedef constructor #45658

Closed
iarkh opened this issue Apr 12, 2021 · 2 comments
Assignees
Labels
area-front-end Use area-front-end for front end / CFE / kernel format related issues. front-end-missing-error

Comments

@iarkh
Copy link
Contributor

iarkh commented Apr 12, 2021

Dart SDK version: 2.13.0-216.0.dev (dev) (Wed Apr 7 15:12:05 2021 -0700) on "windows_x64"

Here is a source code example:

class C<X> {}
typedef A<X extends C<X>> = C<X>;

main() {
  A();
}

Analyzer throws a compile error here whereas dart silently passes.

Sample output is:

$> dart test.dart

$ dartanalyzer test.dart
Analyzing test.dart...
  error - Couldn't infer type parameter 'X'.

Tried to infer 'C<Object?>' for 'X' which doesn't work:
  Type parameter 'X' is declared to extend 'C<X>' producing 'C<C<Object?>>'.

Consider passing explicit type argument(s) to the generic.

 - test.dart:5:3 - could_not_infer
1 error found.

Please also note that both analyzer and dart don't throws a compile error for the following code:

class C<X> {}
typedef A<X extends C<X>> = C<X>;

main() {
  A a = throw "Error";
}
@eernstg eernstg added area-front-end Use area-front-end for front end / CFE / kernel format related issues. front-end-missing-error labels Apr 12, 2021
@chloestefantsova chloestefantsova self-assigned this Apr 12, 2021
@eernstg
Copy link
Member

eernstg commented Apr 12, 2021

The instance creation A() is an error because inference yields A<C<Object?>>(), and A<C<Object?>> is not a regular-bounded type (cf. this rule).

The analyzer reports the error correctly, but the front end does not report it.

@eernstg
Copy link
Member

eernstg commented Apr 12, 2021

Thanks, @stefantsov!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-front-end Use area-front-end for front end / CFE / kernel format related issues. front-end-missing-error
Projects
None yet
Development

No branches or pull requests

3 participants