Skip to content

Commit 7d15bd6

Browse files
committed
Avoid double typechecking of ValOrDefDef.tpt
1 parent 1f7fd16 commit 7d15bd6

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/compiler/scala/tools/nsc/typechecker/Namers.scala

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,7 +1285,11 @@ trait Namers extends MethodSynthesis {
12851285

12861286
val resTpGiven =
12871287
if (tpt.isEmpty) WildcardType
1288-
else typer.typedType(tpt).tpe
1288+
else {
1289+
val tp = typer.typedType(tpt).tpe
1290+
ddef.tpt setType tp
1291+
tp
1292+
}
12891293

12901294

12911295
// ignore missing types unless we can look to overridden method to recover the missing information
@@ -1412,7 +1416,9 @@ trait Namers extends MethodSynthesis {
14121416
// trait T { def f: A }; class C extends T { implicit def b2a(t: B): A = ???; def f = new B }
14131417
val resTpComputedUnlessGiven =
14141418
if (tpt.isEmpty) assignTypeToTree(ddef, typer, resTpFromOverride)
1415-
else resTpGiven
1419+
else {
1420+
resTpGiven
1421+
}
14161422

14171423
// #2382: return type of default getters are always @uncheckedVariance
14181424
if (meth.hasDefault) resTpComputedUnlessGiven.withAnnotation(AnnotationInfo(uncheckedVarianceClass.tpe, List(), List()))
@@ -1636,7 +1642,11 @@ trait Namers extends MethodSynthesis {
16361642

16371643
tptFromRhsUnderPt
16381644
}
1639-
} else typer.typedType(tpt).tpe
1645+
} else {
1646+
val tp = typer.typedType(tpt).tpe
1647+
vdef.tpt setType tp
1648+
tp
1649+
}
16401650

16411651
// println(s"val: $result / ${vdef.tpt.tpe} / ")
16421652

0 commit comments

Comments
 (0)