Skip to content

Type promotion is confusing on type parameters #26439

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
vsmenon opened this issue May 10, 2016 · 3 comments
Closed

Type promotion is confusing on type parameters #26439

vsmenon opened this issue May 10, 2016 · 3 comments
Labels
legacy-area-analyzer Use area-devexp instead.

Comments

@vsmenon
Copy link
Member

vsmenon commented May 10, 2016

The following is showing a strong mode error in foo but not foo2.

void bar(List l) {
  print(l.length);
}

/*=T*/ foo/*<T>*/(/*=T*/ arg) {
  if (arg is List) {
    bar(arg);
  }
}

foo2(arg) {
  if (arg is List) {
    bar(arg);
  }
}

void main() {
  foo([1, 2, 3]);
}

The error is on the call to bar in foo:

[error] The argument type 'T' cannot be assigned to the parameter type 'List'.

@sigmundch was running into this

@jmesserly
Copy link

chatted with folks ( @leafpetersen @sigmundch ) but this is by design in the language right now.

@vsmenon vsmenon changed the title Type promotion is broken on type parameters Type promotion is confusing on type parameters May 10, 2016
@vsmenon
Copy link
Member Author

vsmenon commented May 10, 2016

Changed 'broken' to 'confusing'.

This is actually not a strong mode specific issue. Type promotion - by design - doesn't kick in because T and List are unrelated.

@vsmenon
Copy link
Member Author

vsmenon commented May 10, 2016

This is one of the issues already covered in #25565 - closing in favor of that.

@vsmenon vsmenon closed this as completed May 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
legacy-area-analyzer Use area-devexp instead.
Projects
None yet
Development

No branches or pull requests

2 participants