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

support dependent argument types for constructor parameter lists (in the same way as for methods) #5712

Open
scabug opened this Issue Apr 26, 2012 · 18 comments

Comments

@scabug
Copy link

scabug commented Apr 26, 2012

scala> import scala.tools.nsc._
import scala.tools.nsc._

scala> def mkReifier(global: Global)(typer: global.analyzer.Typer) = typer
mkReifier: (global: scala.tools.nsc.Global)(typer: global.analyzer.Typer)global.analyzer.Typer

scala> class Reifier(global: Global)(typer: global.analyzer.Typer) { }
<console>:10: error: not found: value global
      class Reifier(global: Global)(typer: global.analyzer.Typer) { }
                                           ^
@scabug

This comment has been minimized.

Copy link

scabug commented Apr 26, 2012

Imported From: https://issues.scala-lang.org/browse/SI-5712?orig=1
Reporter: @paulp
Affected Versions: 2.10.0, 2.11.6
See #5700

@scabug

This comment has been minimized.

Copy link

scabug commented May 20, 2012

@retronym said:
Just happened across this looking into #5070, it struck me that it might need to be expanded for dependent constructor types.

override def isImmediatelyDependent = (sym ne NoSymbol) && (sym.owner.isMethod && sym.isValueParameter)
@scabug

This comment has been minimized.

Copy link

scabug commented Jul 26, 2012

@adriaanm said (edited on Jul 26, 2012 9:37:36 AM UTC):
I wonder why we're using an outer namer for parameter accessors.
Commenting out these lines fixes the test case.

    def namerOf(sym: Symbol): Namer = {
      val usePrimary = sym.isTerm && (
//           (sym.isParamAccessor)
//        ||
        (sym.isParameter && sym.owner.isPrimaryConstructor)
      )

      if (usePrimary) createPrimaryConstructorParameterNamer
      else innerNamer
    }

Here's a self-contained test case that also makes sure the constructor's type parameters stay in scope.

class Global {
  class Typer[T]
}

class Reifier[T](global: Global)(typer: global.Typer[T])

object Test {
  def mkReifier[T](global: Global)(typer: global.Typer[T]) = typer
}
@scabug

This comment has been minimized.

Copy link

scabug commented Jul 26, 2012

@adriaanm said (edited on Jul 26, 2012 10:20:19 AM UTC):
Lukas explains: we shouldn't see fields in the constructor signature, but we should see the parameter accessors.

@scabug

This comment has been minimized.

Copy link

scabug commented Oct 15, 2013

@gkossakowski said:
Unassigning and rescheduling to M7 as previous deadline was missed.

@scabug

This comment has been minimized.

Copy link

scabug commented Jan 29, 2014

Eduardo Pareja Tobes (eparejatobes) said:
just curious, why is this no longer considered a bug but an improvement?

@scabug

This comment has been minimized.

Copy link

scabug commented Jan 29, 2014

@adriaanm said:
Dependent method types were an improvement as well. This is an improvement to support dependent constructor types, which were never implemented. So, technically, they can't be buggy :-)

@scabug

This comment has been minimized.

Copy link

scabug commented Jan 29, 2014

Eduardo Pareja Tobes (eparejatobes) said:
OK thanks :)

something about the decreased priority and the unassigned state?

@scabug

This comment has been minimized.

Copy link

scabug commented Jan 29, 2014

@adriaanm said:
Exactly.

@scabug

This comment has been minimized.

Copy link

scabug commented Jan 3, 2015

Alexander Bulaev (alexbool) said:
Any news on this?

@scabug

This comment has been minimized.

Copy link

scabug commented Jan 31, 2015

Andrei Pozolotin (andrei.pozolotin) said:
Please implement?

@scabug

This comment has been minimized.

Copy link

scabug commented Feb 19, 2015

Nathan M (nemccarthy) said:
+1

@scabug

This comment has been minimized.

Copy link

scabug commented Jun 19, 2015

Owen Healy (ellbur) said:
This would be really useful. Scala's type system is amazing in that it makes dependent types usable by mere humans, but gaps like this partially undo that.

@scabug

This comment has been minimized.

Copy link

scabug commented Feb 1, 2016

@manojo said:
+1, any timeline on this?

@scabug

This comment has been minimized.

Copy link

scabug commented Jun 20, 2016

Ruben (lqbweb) said:
+1

@scabug

This comment has been minimized.

Copy link

scabug commented Jun 20, 2016

@milessabin said (edited on Jun 20, 2016 5:28:08 PM UTC):
@adriaanm left a pretty strong hint above ... why not take a stab at it and claim the glory?

@scabug

This comment has been minimized.

Copy link

scabug commented Jun 23, 2016

Hamish Dickson (hamish.dickson-at-gmail.com) said:
I'm taking a look a this under scala/scala#5238

@soronpo

This comment has been minimized.

Copy link

soronpo commented Aug 1, 2017

Another simple example which fails to compile in scalac, but compiles fine in dotty:

trait Impl {
  type Out
}
object Impl {
  implicit def ev : Impl = new Impl {
    type Out = Int
  }
}

class Foo[T]
class Bar[T](implicit val impl: Impl) extends Foo[impl.Out] //ERROR=   not found: value impl

Workaround: use Aux pattern

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