Skip to content

extractors broken: "not enough arguments for method body%1" #3136

Closed
@scabug

Description

@scabug

Related to #2883, which was fixed by avoiding the use of extractors. Now I really need them in refactoring some stuff in the compiler, though...

class Type
class Symbol
case class PolyType(tps: List[Symbol], res: Type) extends Type

object NullaryMethodType {
  /** Creator for nullary method types.

    @note: for now, this returns a PolyType with an empty type-parameter list, 
       but this will eventually change to a NullaryMethodType
  */
  def apply(resTpe: Type): Type = PolyType(List(), resTpe)
    
  /** Extractor for nullary method types.

     @note: to ease transition to NullaryMethodType (instead of PolyType with empty tparam list)
   */
  def unapply(tp: Type): Option[(Type)] = tp match {
    case PolyType(List(), restpe) => Some((restpe))
    case _ => None
  }
}

object Test {
  def apply(tp: Type): Type = 
    tp match {
      case PolyType(params, PolyType(tparams, restpe @ PolyType(_, _))) => tp // couldn't find a simpler version that still crashes
      case NullaryMethodType(restpe) => tp
    }
}

/* error:
not enough arguments for method body%1: (val restpe: Type)Type.
Unspecified value parameter restpe.
*/

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions