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

[Analyzer] Error when calculating upper bound of an extension type #53781

Closed
Tracked by #49732
sgrekhov opened this issue Oct 17, 2023 · 1 comment
Closed
Tracked by #49732

[Analyzer] Error when calculating upper bound of an extension type #53781

sgrekhov opened this issue Oct 17, 2023 · 1 comment
Assignees
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. feature-extension-types Implementation of the extension type feature P1 A high priority bug; for example, a single project is unusable or has many test failures

Comments

@sgrekhov
Copy link
Contributor

The following tests failing in analyzer (works in CFE)
https://github.com/dart-lang/co19/blob/master/LanguageFeatures/Extension-types/upper_bound_A01_t01.dart
https://github.com/dart-lang/co19/blob/master/LanguageFeatures/Extension-types/upper_bound_A01_t04.dart
https://github.com/dart-lang/co19/blob/master/LanguageFeatures/Extension-types/upper_bound_A01_t05.dart
https://github.com/dart-lang/co19/blob/master/LanguageFeatures/Extension-types/upper_bound_A01_t06.dart

Example:

// SharedOptions=--enable-experiment=inline-class

import '../../Utils/static_type_helper.dart';

extension type ET1(Object? o) {}
extension type ET2(Object o) {}

extension type ET3(Object? o) implements ET1 {}
extension type ET4(Object o) implements ET2 {}

main() {
  var v1 = 2 > 1 ? ET1(Object()) : ET2(Object());
  v1.expectStaticType<Exactly<Object?>>(); // Fails, actual type Object in the analyzer

  var v2 = 2 > 1 ? ET1(null) : ET2("String");
  v2.expectStaticType<Exactly<Object?>>();  // Fails, actual type Object in the analyzer

  var v3 = 2 > 1 ? ET1(Object()) : ET3(Object());
  v3.expectStaticType<Exactly<ET1>>();

  var v4 = 2 > 1 ? ET1(Object()) : ET4(Object());
  v4.expectStaticType<Exactly<Object?>>();  // Fails, actual type Object in the analyzer

  var v5 = 2 > 1 ? ET2(Object()) : ET4(Object());
  v5.expectStaticType<Exactly<ET2>>();
}

Tested on Dart SDK version: 3.3.0-edge.e4bb5b608b42b97012e968866866922ccf175eba (be) (Tue Oct 17 10:28:23 2023 +0000) on "linux_x64"

@sgrekhov sgrekhov added area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. cfe-feature-extension-types Implement extension types feature in the CFE labels Oct 17, 2023
@chloestefantsova chloestefantsova added feature-extension-types Implementation of the extension type feature and removed cfe-feature-extension-types Implement extension types feature in the CFE labels Oct 17, 2023
@scheglov scheglov self-assigned this Oct 17, 2023
@scheglov scheglov added the P1 A high priority bug; for example, a single project is unusable or has many test failures label Oct 17, 2023
@scheglov
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. feature-extension-types Implementation of the extension type feature P1 A high priority bug; for example, a single project is unusable or has many test failures
Projects
None yet
Development

No branches or pull requests

3 participants