File tree 2 files changed +34
-2
lines changed
compiler/src/dotty/tools/dotc/typer 2 files changed +34
-2
lines changed Original file line number Diff line number Diff line change @@ -814,9 +814,11 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
814
814
def followTypeAlias (tree : untpd.Tree ): untpd.Tree = {
815
815
tree match {
816
816
case tree : untpd.RefTree =>
817
- val ttree = typedType(untpd.rename(tree, tree.name.toTypeName))
817
+ val nestedCtx = ctx.fresh.setNewTyperState
818
+ val ttree =
819
+ typedType(untpd.rename(tree, tree.name.toTypeName))(nestedCtx)
818
820
ttree.tpe match {
819
- case alias : TypeRef if alias.info.isAlias =>
821
+ case alias : TypeRef if alias.info.isAlias && ! nestedCtx.reporter.hasErrors =>
820
822
companionRef(alias) match {
821
823
case companion : TermRef => return untpd.ref(companion) withPos tree.pos
822
824
case _ =>
Original file line number Diff line number Diff line change
1
+ trait Cap
2
+
3
+ trait Toolbox {
4
+ type Tree
5
+
6
+ val tpd : TypedTrees
7
+ trait TypedTrees {
8
+ type Tree
9
+ }
10
+
11
+ val Apply : ApplyImpl
12
+
13
+ trait ApplyImpl {
14
+ def unapply (tree : Tree ): Option [(Tree , Seq [Tree ])]
15
+ def unapply (tree : tpd.Tree )(implicit c : Cap ): Option [(tpd.Tree , Seq [tpd.Tree ])]
16
+ }
17
+ }
18
+
19
+ class Test (val tb : Toolbox ) {
20
+ import tb ._
21
+ implicit val cap : Cap = null
22
+
23
+ def foo (tree : Tree ): Int = (tree : Any ) match {
24
+ case tb.Apply (fun, args) => 3 // error, but error message is wrong
25
+ }
26
+
27
+ def bar (tree : tpd.Tree ): Int = (tree : Any ) match {
28
+ case Apply (fun, args) => 3 // error, but error message is wrong
29
+ }
30
+ }
You can’t perform that action at this time.
0 commit comments