Skip to content

Compilation exception ("bad parameter reference") #11057

Closed
@hmf

Description

@hmf

Minimized code

May be (marginally) related to #11056.

  object data {

    trait OfType[T]
    case object IntT extends OfType[Int]
    case object DoubleT extends OfType[Double]
    case object FloatT extends OfType[Float]

    type DSeq[X] = scala.collection.immutable.AbstractSeq[X]

    case class ColumnName[T](n:String, t: OfType[T])
    case class Column[T,F[_]<:DSeq[_]](n:F[T], of: ColumnName[T])
  }
  
  def min4[T,F[_]<:data.DSeq[T]](col: data.Column[T,F])(using Ordering[T]): T = {
    col match {
      case c:data.Column[Int,_] => c.n.min[T](Ordering[T])
      case _:data.Column[Double,_] => ???
      case _:data.Column[Float,_] => ???

    }
  }

Output

splotly.compile dotty.tools.dotc.core.TypeError: bad parameter reference gg.Exp4ColumnOps.data.Column#F at pruneErasedDefs
the parameter is type F in class Column but the prefix gg.Exp4ColumnOps.data.Column
does not define any corresponding arguments.

Expectation

I expected compilation to succeed with a warning that run-time comparison cannot be done due to erasure or some other error.

Full stacktrace
splotly.compile dotty.tools.dotc.core.TypeError: bad parameter reference gg.Exp4ColumnOps.data.Column#F at pruneErasedDefs
the parameter is type F in class Column but the prefix gg.Exp4ColumnOps.data.Column
does not define any corresponding arguments.
    dotty.tools.dotc.core.Types$NamedType.argDenot(Types.scala:2201)
    dotty.tools.dotc.core.Types$NamedType.fromDesignator$1(Types.scala:2116)
    dotty.tools.dotc.core.Types$NamedType.computeDenot(Types.scala:2134)
    dotty.tools.dotc.core.Types$NamedType.denot(Types.scala:2089)
    dotty.tools.dotc.core.Types$NamedType.info(Types.scala:2077)
    dotty.tools.dotc.core.TypeApplications$.typeParams$extension(TypeApplications.scala:185)
    dotty.tools.dotc.core.TypeApplications$.appliedTo$extension(TypeApplications.scala:309)
    dotty.tools.dotc.core.Types$AppliedType.derivedAppliedType(Types.scala:4074)
    dotty.tools.dotc.core.Types$ApproximatingTypeMap.derivedAppliedType(Types.scala:5439)
    dotty.tools.dotc.core.Types$TypeMap.mapOver(Types.scala:5120)
    dotty.tools.dotc.core.TypeOps$AsSeenFromMap.apply(TypeOps.scala:110)
    dotty.tools.dotc.core.Types$TypeMap.mapOver(Types.scala:5139)
    dotty.tools.dotc.core.TypeOps$AsSeenFromMap.apply(TypeOps.scala:110)
    dotty.tools.dotc.core.TypeOps$.asSeenFrom(TypeOps.scala:55)
    dotty.tools.dotc.core.Types$Type.asSeenFrom(Types.scala:975)
    dotty.tools.dotc.core.Denotations$SingleDenotation.derived$1(Denotations.scala:1063)
    dotty.tools.dotc.core.Denotations$SingleDenotation.computeAsSeenFrom(Denotations.scala:1067)
    dotty.tools.dotc.core.Denotations$SingleDenotation.computeAsSeenFrom(Denotations.scala:1039)
    dotty.tools.dotc.core.Denotations$PreDenotation.asSeenFrom(Denotations.scala:135)
    dotty.tools.dotc.core.SymDenotations$ClassDenotation.findMember(SymDenotations.scala:1931)
    dotty.tools.dotc.core.Types$Type.go$1(Types.scala:635)
    dotty.tools.dotc.core.Types$Type.findMember(Types.scala:823)
    dotty.tools.dotc.core.Types$Type.memberBasedOnFlags(Types.scala:618)
    dotty.tools.dotc.core.Types$Type.member(Types.scala:602)
    dotty.tools.dotc.typer.Applications$.extractorMember(Applications.scala:45)
    dotty.tools.dotc.typer.Applications$.extractorMemberType(Applications.scala:48)
    dotty.tools.dotc.typer.Applications$.tupleSelectors$1(Applications.scala:115)
    dotty.tools.dotc.typer.Applications$.genTupleSelectors$1(Applications.scala:124)
    dotty.tools.dotc.typer.Applications$.productSelectorTypes(Applications.scala:126)
    dotty.tools.dotc.core.TypeComparer.typeparamCorrespondsToField(TypeComparer.scala:2371)
    dotty.tools.dotc.core.TypeComparer.covariantDisjoint$1(TypeComparer.scala:2459)
    dotty.tools.dotc.core.TypeComparer.invariantDisjoint$1(TypeComparer.scala:2471)
    dotty.tools.dotc.core.TypeComparer.provablyDisjoint$$anonfun$3(TypeComparer.scala:2497)
    scala.collection.LazyZip3.exists(LazyZipOps.scala:235)
    dotty.tools.dotc.core.TypeComparer.provablyDisjoint(TypeComparer.scala:2497)
    dotty.tools.dotc.core.TypeComparer$.provablyDisjoint(TypeComparer.scala:2654)
    dotty.tools.dotc.transform.patmat.SpaceEngine.intersectUnrelatedAtomicTypes(Space.scala:355)
    dotty.tools.dotc.transform.patmat.SpaceLogic.intersect(Space.scala:211)
    dotty.tools.dotc.transform.patmat.SpaceLogic.intersect$(Space.scala:78)
    dotty.tools.dotc.transform.patmat.SpaceEngine.intersect(Space.scala:323)
    dotty.tools.dotc.transform.patmat.SpaceLogic.intersect$$anonfun$1(Space.scala:204)
    scala.collection.immutable.List.map(List.scala:246)
    dotty.tools.dotc.transform.patmat.SpaceLogic.intersect(Space.scala:204)
    dotty.tools.dotc.transform.patmat.SpaceLogic.intersect$(Space.scala:78)
    dotty.tools.dotc.transform.patmat.SpaceEngine.intersect(Space.scala:323)
    dotty.tools.dotc.transform.patmat.SpaceEngine.checkRedundancy$$anonfun$1(Space.scala:890)
    scala.runtime.function.JFunction1$mcVI$sp.apply(JFunction1$mcVI$sp.java:12)
    scala.collection.immutable.Range.foreach(Range.scala:190)
    dotty.tools.dotc.transform.patmat.SpaceEngine.checkRedundancy(Space.scala:911)
    dotty.tools.dotc.transform.PatternMatcher.transformMatch(PatternMatcher.scala:46)
    dotty.tools.dotc.transform.MegaPhase.goMatch(MegaPhase.scala:779)
    dotty.tools.dotc.transform.MegaPhase.transformUnnamed$1(MegaPhase.scala:369)
    dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:429)
    dotty.tools.dotc.transform.MegaPhase.transformUnnamed$1(MegaPhase.scala:300)
    dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:429)
    dotty.tools.dotc.transform.MegaPhase.mapDefDef$1(MegaPhase.scala:249)
    dotty.tools.dotc.transform.MegaPhase.transformNamed$1(MegaPhase.scala:252)
    dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:427)
    dotty.tools.dotc.transform.MegaPhase.transformStat$2(MegaPhase.scala:437)
    dotty.tools.dotc.transform.MegaPhase.recur$1(MegaPhase.scala:442)
    dotty.tools.dotc.transform.MegaPhase.recur$1(MegaPhase.scala:442)
    dotty.tools.dotc.transform.MegaPhase.recur$1(MegaPhase.scala:442)
    dotty.tools.dotc.transform.MegaPhase.recur$1(MegaPhase.scala:442)
    dotty.tools.dotc.transform.MegaPhase.recur$1(MegaPhase.scala:442)
    dotty.tools.dotc.transform.MegaPhase.recur$1(MegaPhase.scala:442)
    dotty.tools.dotc.transform.MegaPhase.recur$1(MegaPhase.scala:442)
    dotty.tools.dotc.transform.MegaPhase.recur$1(MegaPhase.scala:442)
    dotty.tools.dotc.transform.MegaPhase.transformStats(MegaPhase.scala:442)
    dotty.tools.dotc.transform.MegaPhase.transformUnnamed$1(MegaPhase.scala:362)
    dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:429)
    dotty.tools.dotc.transform.MegaPhase.transformNamed$1(MegaPhase.scala:256)
    dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:427)
    dotty.tools.dotc.transform.MegaPhase.transformStat$2(MegaPhase.scala:437)
    dotty.tools.dotc.transform.MegaPhase.recur$1(MegaPhase.scala:442)
    dotty.tools.dotc.transform.MegaPhase.recur$1(MegaPhase.scala:442)
    dotty.tools.dotc.transform.MegaPhase.transformStats(MegaPhase.scala:442)
    dotty.tools.dotc.transform.MegaPhase.mapPackage$1(MegaPhase.scala:382)
    dotty.tools.dotc.transform.MegaPhase.transformUnnamed$1(MegaPhase.scala:385)
    dotty.tools.dotc.transform.MegaPhase.transformTree(MegaPhase.scala:429)
    dotty.tools.dotc.transform.MegaPhase.transformUnit(MegaPhase.scala:448)
    dotty.tools.dotc.transform.MegaPhase.run(MegaPhase.scala:460)
    dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:296)
    scala.collection.immutable.List.map(List.scala:246)
    dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:297)
    dotty.tools.dotc.Run.runPhases$4$$anonfun$4(Run.scala:185)
    scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
    scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
    scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1323)
    dotty.tools.dotc.Run.runPhases$5(Run.scala:195)
    dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:203)
    scala.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
    dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:67)
    dotty.tools.dotc.Run.compileUnits(Run.scala:210)
    dotty.tools.dotc.Run.compileSources(Run.scala:146)
    dotty.tools.dotc.Run.compile(Run.scala:130)
    dotty.tools.dotc.Driver.doCompile(Driver.scala:39)
    dotty.tools.dotc.Driver.process(Driver.scala:186)
    dotty.tools.dotc.Main.process(Main.scala)
    xsbt.CachedCompilerImpl.run(CachedCompilerImpl.java:64)
    xsbt.CompilerInterface.run(CompilerInterface.java:45)
    jdk.internal.reflect.GeneratedMethodAccessor7.invoke(Unknown Source)
    java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    java.base/java.lang.reflect.Method.invoke(Method.java:566)
    sbt.internal.inc.AnalyzingCompiler.call(AnalyzingCompiler.scala:248)
    sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:122)
    sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:95)
    sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4(MixedAnalyzingCompiler.scala:91)
    scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)

<\details>

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions