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 constructor inference works for method call but fails for constructor invocation #4018

Closed
scabug opened this issue Nov 21, 2010 · 5 comments
Closed
Assignees

Comments

@scabug
Copy link

@scabug scabug commented Nov 21, 2010

= problem =

Type Constructor inference doesn't behave consistently across method calls and constructor invocations.

trait M[V[_]]

class Cls[V[_]](c: M[V])

object Cls{
  def apply[V[_]](c: M[V]): Cls[V] = new Cls[V](c)
}

object test {
  val c: M[Option] = new M[Option] {}
  new Cls(c)         // does not infer.
  new Cls[Option](c) // okay
  Cls(c)             // okay
}

Tested with Scala 2.8.1

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Nov 21, 2010

Imported From: https://issues.scala-lang.org/browse/SI-4018?orig=1
Reporter: @retronym
Attachments:

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Nov 22, 2010

@Sciss said:
this gets really nasty also with method invocations which do perfect inference until you introduce higher-kinded type arguments.

in the attached file you can see that for the first-order case this works:

def test( implicit sys: KSys, c: KCtx ) {
   val p = Factory.test( "Test" )
}

in the second-order case, the implicits are not found. if i add them explicitly, the compiler complains:

<console>:38: error: no type parameters for method test: (implicit sys: Sys[A,B],implicit c: A)Proc[A,B] exist so that it can be applied to arguments (KSys, KCtx)
 --- because ---
argument expression's type is not compatible with formal parameter type;
 found   : KSys
 required: Sys[?A,?B]
          val p = Factory.test( "Test" )( sys, c )
                              ^

so i need to annotate all types. this is a real show stopper for a larger generified library.

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Nov 22, 2010

@Sciss said:
Example where method calls must be annotated

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Mar 17, 2011

@retronym said:
See more examples in #4347

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Jun 19, 2011

@paulp said:
Fixed in r25110.

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

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.