Skip to content

Analyzer false-negative for invalid type arguments on dot-shorthand constructors #61978

@Pante

Description

@Pante

Dart version: 3.10.0

dart analyze does not flag the following code even though it fails to compile:

abstract class Foo<T> {
  factory Foo.a() = _Foo;

  Foo();
}

class _Foo<T> extends Foo<T> {
  _Foo();
}

Foo<T> bar<T>() => .a<T>();

The following error is emitted when the code is compiled:

Error: A dot shorthand constructor invocation can't have type arguments.
Try adding the class name and type arguments explicitly before the constructor name.
Foo<T> bar<T>() => .a<T>();
                              ^

Metadata

Metadata

Assignees

Labels

area-dart-modelFor issues related to conformance to the language spec in the parser, compilers or the CLI analyzer.feature-dot-shorthandsImplementation of the dot shorthands feature.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions