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

Scala 2.10.0-M4 gives a compiler error instead of applying an implicit conversion that involves structural types #5928

Closed
scabug opened this issue Jun 15, 2012 · 2 comments

Comments

@scabug
Copy link

scabug commented Jun 15, 2012

Consider, if you will, the following code example:

object M4Prob extends App {

abstract class LengthWrapper {
def length: Long
}

implicit def convertGetLengthFieldToLongLengthWrapper(o: { val getLength: Long }): LengthWrapper =
new LengthWrapper {
def length = o.getLength
}

implicit def convertHasLongGetLengthFieldToLengthShouldWrapper[T <: AnyRef { val getLength: Long}](o: T): LengthShouldWrapper[T] = new LengthShouldWrapperT

final class LengthShouldWrapper[A <: AnyRef <% LengthWrapper](left: A) {

def should(o: Any) {
  println("Length was: " + left.length)
}

}

class Lengthy {
def getLength: Long = 99L
}

(new Lengthy) should "howdy"
}

Under 2.9.1 and 2.10.0-M3, it compiles and when you run it, it correctly prints:

Length was: 99

Under 2.10.0-M4, it fails to compile with this error message:

M4Prob.scala:26: error: value should is not a member of M4Prob.Lengthy
(new Lengthy) should "howdy"
^
one error found

@scabug
Copy link
Author

scabug commented Jun 15, 2012

Imported From: https://issues.scala-lang.org/browse/SI-5928?orig=1
Reporter: @bvenners
See #963

@scabug
Copy link
Author

scabug commented Jun 15, 2012

@retronym said:
[T <: {def getLength: Long}] is required now to admit Lengthy.

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

No branches or pull requests

1 participant