@@ -864,7 +864,7 @@ trait Checking {
864864 def javaFieldMethodPair =
865865 decl.is(JavaDefined ) && other.is(JavaDefined ) &&
866866 decl.is(Method ) != other.is(Method )
867- if (( decl.signature.clashes(other.signature) || decl. matches(other) ) && ! javaFieldMethodPair) {
867+ if (decl.matches(other) && ! javaFieldMethodPair) {
868868 def doubleDefError (decl : Symbol , other : Symbol ): Unit =
869869 if (! decl.info.isErroneous && ! other.info.isErroneous)
870870 ctx.error(DoubleDefinition (decl, other, cls), decl.sourcePos)
@@ -1124,6 +1124,21 @@ trait Checking {
11241124 case _ =>
11251125 }
11261126 }
1127+
1128+ /** Check that symbol's external name does not clash with symbols defined in the same scope */
1129+ def checkNoAlphaConflict (stats : List [Tree ])(implicit ctx : Context ): Unit = {
1130+ var seen = Set [Name ]()
1131+ for (stat <- stats) {
1132+ val sym = stat.symbol
1133+ val ename = sym.erasedName
1134+ if (ename != sym.name) {
1135+ val preExisting = ctx.effectiveScope.lookup(ename)
1136+ if (preExisting.exists || seen.contains(ename))
1137+ ctx.error(em " @alpha annotation ${'"' }$ename${'"' } clashes with other definition is same scope " , stat.sourcePos)
1138+ seen += ename
1139+ }
1140+ }
1141+ }
11271142}
11281143
11291144trait ReChecking extends Checking {
@@ -1144,7 +1159,7 @@ trait NoChecking extends ReChecking {
11441159 override def checkImplicitConversionUseOK (sym : Symbol , posd : Positioned )(implicit ctx : Context ): Unit = ()
11451160 override def checkFeasibleParent (tp : Type , pos : SourcePosition , where : => String = " " )(implicit ctx : Context ): Type = tp
11461161 override def checkInlineConformant (tree : Tree , isFinal : Boolean , what : => String )(implicit ctx : Context ): Unit = ()
1147- override def checkNoDoubleDeclaration ( cls : Symbol )(implicit ctx : Context ): Unit = ()
1162+ override def checkNoAlphaConflict ( stats : List [ Tree ] )(implicit ctx : Context ): Unit = ()
11481163 override def checkParentCall (call : Tree , caller : ClassSymbol )(implicit ctx : Context ): Unit = ()
11491164 override def checkSimpleKinded (tpt : Tree )(implicit ctx : Context ): Tree = tpt
11501165 override def checkDerivedValueClass (clazz : Symbol , stats : List [Tree ])(implicit ctx : Context ): Unit = ()
0 commit comments