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

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

Open
scabug opened this issue Apr 26, 2012 · 22 comments
Labels
dependent types depmet enhancement fixed in Scala 3 This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/) has PR minimized should compile typelevel typer
Milestone

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
Copy link
Author

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
Copy link
Author

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
Copy link
Author

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
Copy link
Author

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
Copy link
Author

scabug commented Oct 15, 2013

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

@scabug
Copy link
Author

scabug commented Jan 29, 2014

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

@scabug
Copy link
Author

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
Copy link
Author

scabug commented Jan 29, 2014

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

something about the decreased priority and the unassigned state?

@scabug
Copy link
Author

scabug commented Jan 29, 2014

@adriaanm said:
Exactly.

@scabug
Copy link
Author

scabug commented Jan 3, 2015

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

@scabug
Copy link
Author

scabug commented Jan 31, 2015

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

@scabug
Copy link
Author

scabug commented Feb 19, 2015

Nathan M (nemccarthy) said:
+1

@scabug
Copy link
Author

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
Copy link
Author

scabug commented Feb 1, 2016

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

@scabug
Copy link
Author

scabug commented Jun 20, 2016

Ruben (lqbweb) said:
+1

@scabug
Copy link
Author

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
Copy link
Author

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
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

@milessabin milessabin self-assigned this Mar 12, 2018
@NthPortal NthPortal added the fixed in Scala 3 This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/) label Nov 26, 2019
@Sciss
Copy link

Sciss commented Sep 21, 2020

Cross-building against Scala 2.13 and Dotty would be greatly simplified if this was fixed for Scala 2.13.

@milessabin milessabin removed their assignment Sep 21, 2020
@milessabin
Copy link

I hadn't realized this was still assigned to me. I agree it would be extremely helpful, but unfortunately I don't have time to work on it.

@som-snytt
Copy link

Still DNC. Maybe Miles didn't have time to work on it.

@milessabin
Copy link

I didn't.

arcabucero pushed a commit to NeoflexConsulting/fluminous that referenced this issue Aug 6, 2021
Sciss added a commit to Sciss/HistoricalCode that referenced this issue Sep 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependent types depmet enhancement fixed in Scala 3 This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/) has PR minimized should compile typelevel typer
Projects
None yet
Development

No branches or pull requests

6 participants