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

Application of a method with a dependent type (wrong argument used by typechecker) #1569

Closed
scabug opened this issue Dec 8, 2008 · 3 comments
Assignees
Labels

Comments

@scabug
Copy link

scabug commented Dec 8, 2008

The following code includes a method with a dependent type. It should normally typecheck (when using the option -Xexperimental of the Scala compiler).

object Bug {
  class C { type T }
  def foo(x: Int)(y: C)(z: y.T) {}
  foo(3)(new C { type T = String })("hello")
}

However the compiler (version 2.7.2.final) signals the following
error.

bug.scala:4: error: type mismatch;
 found   : java.lang.String("hello")
 required: Int(3)#T
  foo(3)(new C { type T = String })("hello")
                                    ^

In the application of the method foo, when determining the expected type of the third argument (which, according to the method signature, refers to the second argument), the typechecher wrongly uses the first argument, of type Int.

@scabug
Copy link
Author

scabug commented Dec 8, 2008

Imported From: https://issues.scala-lang.org/browse/SI-1569?orig=1
Reporter: cremet

@scabug
Copy link
Author

scabug commented Aug 9, 2010

@lrytz said:
this is an old one which was floating around in the scala_devteam bucket.

@scabug
Copy link
Author

scabug commented Sep 16, 2010

@adriaanm said:
(In r23010) closes #1569, #3731: refactored dependent method types to get rid of debruijn indices and use singleton types instead.

this is the core of the dependent types refactoring, no implicit or inference changes

(one baffling discovery: resultType should drop annotations that don't subclass TypeConstraint, even in the trivial case... wow -- thanks to Tiark for helping me figure it out on a terrace in Barcelona
TODO: probably need a more principled approach to the propagation of plugin type-annotations)

review by odersky

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