@@ -3884,40 +3884,51 @@ trait Typers extends Modes with Adaptations with Tags {
3884
3884
}
3885
3885
}
3886
3886
3887
- def typedBind (name : Name , body : Tree ) = {
3888
- var vble = tree.symbol
3889
- def typedBindType (name : TypeName ) = {
3890
- assert(body == EmptyTree , context.unit + " typedBind: " + name.debugString + " " + body + " " + body.getClass)
3891
- if (vble == NoSymbol )
3892
- vble =
3893
- if (isFullyDefined(pt))
3894
- context.owner.newAliasType(name, tree.pos) setInfo pt
3895
- else
3896
- context.owner.newAbstractType(name, tree.pos) setInfo TypeBounds .empty
3897
- val rawInfo = vble.rawInfo
3898
- vble = if (vble.name == tpnme.WILDCARD ) context.scope.enter(vble)
3899
- else namer.enterInScope(vble)
3900
- tree setSymbol vble setType vble.tpe
3901
- }
3902
- def typedBindTerm (name : TermName ) = {
3903
- if (vble == NoSymbol )
3904
- vble = context.owner.newValue(name, tree.pos)
3905
- if (vble.name.toTermName != nme.WILDCARD ) {
3906
- if ((mode & ALTmode ) != 0 )
3907
- VariableInPatternAlternativeError (tree)
3908
- vble = namer.enterInScope(vble)
3909
- }
3910
- val body1 = typed(body, mode, pt)
3911
- vble.setInfo(
3912
- if (treeInfo.isSequenceValued(body)) seqType(body1.tpe)
3913
- else body1.tpe)
3914
- treeCopy.Bind (tree, name, body1) setSymbol vble setType body1.tpe // burak, was: pt
3915
- }
3887
+ def typedBind (name : Name , body : Tree ) =
3916
3888
name match {
3917
- case x : TypeName => typedBindType(x)
3918
- case x : TermName => typedBindTerm(x)
3889
+ case name : TypeName => assert(body == EmptyTree , context.unit + " typedBind: " + name.debugString + " " + body + " " + body.getClass)
3890
+ val sym =
3891
+ if (tree.symbol != NoSymbol ) tree.symbol
3892
+ else {
3893
+ if (isFullyDefined(pt))
3894
+ context.owner.newAliasType(name, tree.pos) setInfo pt
3895
+ else
3896
+ context.owner.newAbstractType(name, tree.pos) setInfo TypeBounds .empty
3897
+ }
3898
+
3899
+ if (name != tpnme.WILDCARD ) namer.enterInScope(sym)
3900
+ else context.scope.enter(sym)
3901
+
3902
+ tree setSymbol sym setType sym.tpe
3903
+
3904
+ case name : TermName =>
3905
+ val sym =
3906
+ if (tree.symbol != NoSymbol ) tree.symbol
3907
+ else context.owner.newValue(name, tree.pos)
3908
+
3909
+ if (name != nme.WILDCARD ) {
3910
+ if ((mode & ALTmode ) != 0 ) VariableInPatternAlternativeError (tree)
3911
+ namer.enterInScope(sym)
3912
+ }
3913
+
3914
+ val body1 = typed(body, mode, pt)
3915
+ val symTp =
3916
+ if (treeInfo.isSequenceValued(body)) seqType(body1.tpe)
3917
+ else body1.tpe
3918
+ sym setInfo symTp
3919
+
3920
+ // have to imperatively set the symbol for this bind to keep it in sync with the symbols used in the body of a case
3921
+ // when type checking a case we imperatively update the symbols in the body of the case
3922
+ // those symbols are bound by the symbols in the Binds in the pattern of the case,
3923
+ // so, if we set the symbols in the case body, but not in the patterns,
3924
+ // then re-type check the casedef (for a second try in typedApply for example -- SI-1832),
3925
+ // we are no longer in sync: the body has symbols set that do not appear in the patterns
3926
+ // since body1 is not necessarily equal to body, we must return a copied tree,
3927
+ // but we must still mutate the original bind
3928
+ tree setSymbol sym
3929
+ treeCopy.Bind (tree, name, body1) setSymbol sym setType body1.tpe
3919
3930
}
3920
- }
3931
+
3921
3932
3922
3933
def typedArrayValue (elemtpt : Tree , elems : List [Tree ]) = {
3923
3934
val elemtpt1 = typedType(elemtpt, mode)
0 commit comments