@@ -1802,8 +1802,15 @@ class Typer extends Namer
1802
1802
bindings1, expansion1)
1803
1803
}
1804
1804
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
+
1805
1812
def typedTypeTree (tree : untpd.TypeTree , pt : Type )(using Context ): Tree =
1806
- tree match {
1813
+ tree match
1807
1814
case tree : untpd.DerivedTypeTree =>
1808
1815
tree.ensureCompletions
1809
1816
tree.getAttachment(untpd.OriginalSymbol ) match {
@@ -1817,11 +1824,7 @@ class Typer extends Namer
1817
1824
errorTree(tree, " Something's wrong: missing original symbol for type tree" )
1818
1825
}
1819
1826
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)
1825
1828
1826
1829
def typedSingletonTypeTree (tree : untpd.SingletonTypeTree )(using Context ): SingletonTypeTree = {
1827
1830
val ref1 = typedExpr(tree.ref)
@@ -2736,7 +2739,7 @@ class Typer extends Namer
2736
2739
case tree : untpd.TypedSplice => typedTypedSplice(tree)
2737
2740
case tree : untpd.UnApply => typedUnApply(tree, pt)
2738
2741
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 )
2740
2743
case tree : untpd.InfixOp => typedInfixOp(tree, pt)
2741
2744
case tree : untpd.ParsedTry => typedTry(tree, pt)
2742
2745
case tree @ untpd.PostfixOp (qual, Ident (nme.WILDCARD )) => typedAsFunction(tree, pt)
0 commit comments