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

Type inference for objects doesn't work well for self types #1298

Open
jvasileff opened this issue May 14, 2015 · 2 comments
Open

Type inference for objects doesn't work well for self types #1298

jvasileff opened this issue May 14, 2015 · 2 comments

Comments

@jvasileff
Copy link
Member

I'm not sure if this type of thing is really meant to be supported, but I keep trying to skip the step of creating companion interfaces for objects now that objects have denotable types.

shared interface Self<Other> of Other
        given Other satisfies Self<Other> {}

shared object selfObject satisfies Self<\IselfObject> {}

shared void takesSelf<S>(S arg) given S satisfies Self<S> {}

shared void callTakesSelf() {
    takesSelf(selfObject);
    // Inferred type argument Basic&Self<selfObject> to
    // type parameter S of declaration takesSelf is
    // not assignable to upper bound
    // Self<Basic&Self<selfObject>> of S
}
@gavinking
Copy link
Member

Well it's still the rule that we never infer "anonymous" class types, so this is (inconveniently) correct and per-spec.

@RossTate
Copy link
Member

If y'all want, I think y'all could make any immutable reference a type and everything would still be decidable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants