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

CFE: Improperly failed inference with promoted type parameters #35800

Open
MichaelRFairhurst opened this issue Jan 29, 2019 · 1 comment
Open
Labels
area-front-end Use area-front-end for front end / CFE / kernel format related issues. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@MichaelRFairhurst
Copy link
Contributor

Here, the call to f should be valid and inferrable as Cloneable<T>.

class Clonable<T> {}                                                                             
class SubClonable<T> extends Clonable<T> {
  T m(T t) => t;  
} 

void f<T extends Clonable<T>>(T object) {
  if (object is SubClonable<T>) {
    f(object);
  }     
}

However it fails in analyzer and CFE. This is the CFE ticket for this issue. (analyzer is #35799)

I can't speak to the CFE's architecture, but in the analyzer codebase object is promoted to type T' extends SubCloneable<T>. So if the analyzer attempts to infer SubClonable<T> for T in f(object), then that will fail. However, it should be possible to infer Clonable, which in fact works when typed explicitly.

May be related to #35100

@MichaelRFairhurst MichaelRFairhurst added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) area-front-end Use area-front-end for front end / CFE / kernel format related issues. labels Jan 29, 2019
@bwilkerson
Copy link
Member

analyzer's technique of replacing the bounds came up in a discussion yesterday with @leafpetersen.

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. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

2 participants