Skip to content

Commit a5a62f4

Browse files
committed
Revert suspicious widening of getter's result type
1 parent 279e785 commit a5a62f4

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -395,12 +395,13 @@ trait MethodSynthesis {
395395
// starts compiling (instead of failing like it's supposed to) because the typer
396396
// expects to be able to identify escaping locals in typedDefDef, and fails to
397397
// spot that brand of them. In other words it's an artifact of the implementation.
398-
val tpt = derivedSym.tpe_*.finalResultType.widen match {
398+
val getterTp = derivedSym.tpe_*.finalResultType
399+
val tpt = getterTp.widen match {
399400
// Range position errors ensue if we don't duplicate this in some
400401
// circumstances (at least: concrete vals with existential types.)
401-
case ExistentialType(_, _) => TypeTree() setOriginal (tree.tpt.duplicate setPos tree.tpt.pos.focus)
402-
case _ if isDeferred => TypeTree() setOriginal tree.tpt // keep type tree of original abstract field
403-
case tp => TypeTree(tp)
402+
case _: ExistentialType => TypeTree() setOriginal (tree.tpt.duplicate setPos tree.tpt.pos.focus)
403+
case _ if isDeferred => TypeTree() setOriginal tree.tpt // keep type tree of original abstract field
404+
case _ => TypeTree(getterTp)
404405
}
405406
tpt setPos tree.tpt.pos.focus
406407
}

0 commit comments

Comments
 (0)