@@ -1802,8 +1802,15 @@ class Typer extends Namer
18021802 bindings1, expansion1)
18031803 }
18041804
1805+ def completeTypeTree (tree : untpd.TypeTree , pt : Type , original : untpd.Tree )(using Context ): TypeTree =
1806+ tree.withSpan(original.span).withAttachmentsFrom(original)
1807+ .withType(
1808+ if isFullyDefined(pt, ForceDegree .flipBottom) then pt
1809+ else if ctx.reporter.errorsReported then UnspecifiedErrorType
1810+ else errorType(i " cannot infer type; expected type $pt is not fully defined " , tree.srcPos))
1811+
18051812 def typedTypeTree (tree : untpd.TypeTree , pt : Type )(using Context ): Tree =
1806- tree match {
1813+ tree match
18071814 case tree : untpd.DerivedTypeTree =>
18081815 tree.ensureCompletions
18091816 tree.getAttachment(untpd.OriginalSymbol ) match {
@@ -1817,11 +1824,7 @@ class Typer extends Namer
18171824 errorTree(tree, " Something's wrong: missing original symbol for type tree" )
18181825 }
18191826 case _ =>
1820- tree.withType(
1821- if (isFullyDefined(pt, ForceDegree .flipBottom)) pt
1822- else if (ctx.reporter.errorsReported) UnspecifiedErrorType
1823- else errorType(i " cannot infer type; expected type $pt is not fully defined " , tree.srcPos))
1824- }
1827+ completeTypeTree(InferredTypeTree (), pt, tree)
18251828
18261829 def typedSingletonTypeTree (tree : untpd.SingletonTypeTree )(using Context ): SingletonTypeTree = {
18271830 val ref1 = typedExpr(tree.ref)
@@ -2736,7 +2739,7 @@ class Typer extends Namer
27362739 case tree : untpd.TypedSplice => typedTypedSplice(tree)
27372740 case tree : untpd.UnApply => typedUnApply(tree, pt)
27382741 case tree : untpd.Tuple => typedTuple(tree, pt)
2739- case tree : untpd.DependentTypeTree => typed (untpd.TypeTree ().withSpan(tree.span) , pt)
2742+ case tree : untpd.DependentTypeTree => completeTypeTree (untpd.TypeTree (), pt, tree )
27402743 case tree : untpd.InfixOp => typedInfixOp(tree, pt)
27412744 case tree : untpd.ParsedTry => typedTry(tree, pt)
27422745 case tree @ untpd.PostfixOp (qual, Ident (nme.WILDCARD )) => typedAsFunction(tree, pt)
0 commit comments