Skip to content

Commit c62db94

Browse files
committed
Avoid creating a variable in the first place
1 parent 8daf2b7 commit c62db94

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,15 @@ trait TypeAssigner {
117117

118118
/** The type of the selection `tree`, where `qual1` is the typed qualifier part. */
119119
def selectionType(tree: untpd.RefTree, qual1: Tree)(using Context): Type =
120-
var qualType = qual1.tpe.widenIfUnstable
121-
if !qualType.isError then
122-
val prevQual = qualType
123-
if !qualType.hasSimpleKind && tree.name != nme.CONSTRUCTOR then
120+
val qualType0 = qual1.tpe.widenIfUnstable
121+
val qualType =
122+
if !qualType0.hasSimpleKind && tree.name != nme.CONSTRUCTOR then
124123
// constructors are selected on typeconstructor, type arguments are passed afterwards
125-
qualType = errorType(em"$prevQual takes type parameters", qual1.srcPos)
126-
else if !qualType.isInstanceOf[TermType] then
127-
qualType = errorType(em"$prevQual is illegal as a selection prefix", qual1.srcPos)
124+
errorType(em"$qualType0 takes type parameters", qual1.srcPos)
125+
else if !qualType0.isInstanceOf[TermType] && !qualType0.isError then
126+
errorType(em"$qualType0 is illegal as a selection prefix", qual1.srcPos)
127+
else
128+
qualType0
128129

129130
def arrayElemType = qual1.tpe.widen match
130131
case JavaArrayType(elemtp) => elemtp

0 commit comments

Comments
 (0)