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

Implicit lookup failure for type alias #4692

Closed
scabug opened this issue Jun 14, 2011 · 4 comments
Closed

Implicit lookup failure for type alias #4692

scabug opened this issue Jun 14, 2011 · 4 comments
Assignees
Labels

Comments

@scabug
Copy link

scabug commented Jun 14, 2011

implicit doesn't work in case of type-aliases:

class TypeAliasVsImplicitTest {

    class For[m[_], a](x: m[a]) {
       def map[b](y: a => b): m[b] = throw new Error
    }
    implicit def toFor[m[_], a](x: m[a]): For[m, a] = new For[m, a](x)

    trait MyList[A]

    def foo(xs: MyList[Int]) = xs.map(x => x) // compiles fine.

    type MyListOfInt = MyList[Int]
    def bar(xs: MyListOfInt) = xs.map(x => x) // doesn't compile: value map is not a member of TypeAliasVsImplicitTest.this.MyListOfInt
}
@scabug
Copy link
Author

scabug commented Jun 14, 2011

Imported From: https://issues.scala-lang.org/browse/SI-4692?orig=1
Reporter: @okomok
Affected Versions: 2.9.0

@scabug
Copy link
Author

scabug commented Jun 14, 2011

@paulp said:
Regression against 2.8.1.

@scabug
Copy link
Author

scabug commented Jun 15, 2011

@adriaanm said (edited on Jun 15, 2011 4:19:39 PM UTC):
finally we suffer from recklessly changing the search for implicit conversions to use the narrow type of the convertee (xs.type) rather than the widened one (MyListOfInt)!

the problem was that unification in type constructor inference wasn't set up to deal with types that need to be widened and dealiased

@scabug
Copy link
Author

scabug commented Jun 15, 2011

Commit Message Bot (anonymous) said:
(moors in r25092) closes #4692: unification in type constructor inference now widens and dealiases when necessary

in 2.8.1 implicit conversion search started with a widened type, so that combo never came up

no review

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

No branches or pull requests

2 participants