Skip to content

Commit 3129c1c

Browse files
committed
Revert: Better error diagnostics for "not an extractor" errors.
No longer needed because we are going to allow dependent method types in extractors, and the unary requirement is kind of obvious.
1 parent ed8e2ba commit 3129c1c

File tree

2 files changed

+2
-44
lines changed

2 files changed

+2
-44
lines changed

src/dotty/tools/dotc/typer/Applications.scala

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -659,23 +659,8 @@ trait Applications extends Compatibility { self: Typer =>
659659
def typedUnApply(tree: untpd.Apply, selType: Type)(implicit ctx: Context): Tree = track("typedUnApply") {
660660
val Apply(qual, args) = tree
661661

662-
def notAnExtractor(unapplyFn: Tree) = {
663-
val methodStr = unapplyFn.symbol.name match {
664-
case nme.unapply => "unapply"
665-
case nme.unapplySeq => "unapplySeq"
666-
case _ => "unapply or unapplySeq"
667-
}
668-
val because = unapplyFn.tpe.widen match {
669-
case mt: MethodType =>
670-
i"its $methodStr method of type $mt" + (
671-
if (mt.isDependent) i" has a dependent type"
672-
else if (mt.paramTypes.length != 1) i" does not take a single parameter"
673-
else " is not eligible (this could be an internal compiler error)")
674-
case _ =>
675-
"it lacks a unapply or unapplySeq method"
676-
}
677-
errorTree(unapplyFn, s"${qual.show} cannot be used as an extractor in a pattern $because")
678-
}
662+
def notAnExtractor(tree: Tree) =
663+
errorTree(tree, s"${qual.show} cannot be used as an extractor in a pattern because it lacks an unapply or unapplySeq method")
679664

680665
/** If this is a term ref tree, try to typecheck with its type name.
681666
* If this refers to a type alias, follow the alias, and if

tests/neg/extractors.scala

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)