Skip to content

Commit beabf5a

Browse files
committed
Fix #2950: prefer inner error
The inner error is supposed to be more informative thus should be preferred.
1 parent df8f79f commit beabf5a

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -940,7 +940,9 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
940940
def typedUnApply(tree: untpd.Apply, selType: Type)(implicit ctx: Context): Tree = track("typedUnApply") {
941941
val Apply(qual, args) = tree
942942

943-
def notAnExtractor(tree: Tree) = errorTree(tree, NotAnExtractor(qual))
943+
def notAnExtractor(tree: Tree) =
944+
if (tree.tpe.isErroneous) tree
945+
else errorTree(tree, NotAnExtractor(qual))
944946

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

tests/neg/i2950.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class T1 {
2+
case class Foo(x: Int, xs1: List[String], xs2: List[String])
3+
}
4+
5+
object T2 {
6+
val foo: T1#Foo = ???
7+
8+
val Foo(x1, xs1, xs2) = foo // error
9+
}

0 commit comments

Comments
 (0)