Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ internal enum ErrorCode
ERR_PredefinedTypeNotFound = 518,
ERR_BindToBogus = 570,
ERR_CantCallSpecialMethod = 571,
ERR_BogusType = 648,
ERR_MissingPredefinedMember = 656,
ERR_LiteralDoubleCast = 664,
ERR_ConvertToStaticClass = 716,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,6 @@ public static string GetMessage(ErrorCode code)
case ErrorCode.ERR_CantCallSpecialMethod:
codeStr = SR.CantCallSpecialMethod;
break;
case ErrorCode.ERR_BogusType:
codeStr = SR.BogusType;
break;
case ErrorCode.ERR_MissingPredefinedMember:
codeStr = SR.MissingPredefinedMember;
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,13 +236,13 @@ private void ErrAppendMethod(MethodSymbol meth, SubstContext pctx, bool fArgs)
ErrAppendSym(prop, pctx);

// add accessor name
if (prop.methGet == meth)
if (prop.GetterMethod == meth)
{
ErrAppendString(".get");
}
else
{
Debug.Assert(meth == prop.methSet);
Debug.Assert(meth == prop.SetterMethod);
ErrAppendString(".set");
}

Expand Down Expand Up @@ -347,14 +347,12 @@ private void ErrAppendMethod(MethodSymbol meth, SubstContext pctx, bool fArgs)
// append argument types
ErrAppendChar('(');

if (!meth.computeCurrentBogusState())
{
ErrAppendParamList(GetTypeManager().SubstTypeArray(meth.Params, pctx), meth.isVarargs, meth.isParamArray);
}
ErrAppendParamList(GetTypeManager().SubstTypeArray(meth.Params, pctx), meth.isVarargs, meth.isParamArray);

ErrAppendChar(')');
}
}

private void ErrAppendIndexer(IndexerSymbol indexer, SubstContext pctx)
{
ErrAppendString("this[");
Expand All @@ -373,15 +371,15 @@ private void ErrAppendProperty(PropertySymbol prop, SubstContext pctx)
{
if (prop.errExpImpl != null)
ErrAppendType(prop.errExpImpl, pctx, false);
if (prop.isIndexer())
if (prop is IndexerSymbol indexer)
{
ErrAppendChar('.');
ErrAppendIndexer(prop.AsIndexerSymbol(), pctx);
ErrAppendIndexer(indexer, pctx);
}
}
else if (prop.isIndexer())
else if (prop is IndexerSymbol indexer)
{
ErrAppendIndexer(prop.AsIndexerSymbol(), pctx);
ErrAppendIndexer(indexer, pctx);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ public static string GetIndexerName(this Type type)
private static string GetTypeIndexerName(Type type)
{
Debug.Assert(type != null);
string name = (type.GetCustomAttribute(typeof(DefaultMemberAttribute)) as DefaultMemberAttribute)?.MemberName;
string name = type.GetCustomAttribute<DefaultMemberAttribute>()?.MemberName;
if (name != null)
{
if (type.GetProperties(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1032,8 +1032,6 @@ private bool bindUserDefinedConversion(Expr exprSrc, CType typeSrc, CType typeDs

if (fImplicitOnly && !convCur.isImplicit())
continue;
if (GetSemanticChecker().CheckBogus(convCur))
continue;

// Get the substituted src and dst types.
typeFrom = GetTypes().SubstType(convCur.Params[0], atsCur);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ private Expr bindIndexer(Expr pObject, Expr args, BindingFlag bindFlags)
return rval;
}

Debug.Assert(mem.SymFirst() is PropertySymbol prop && prop.isIndexer());
Debug.Assert(mem.SymFirst() is IndexerSymbol);

ExprMemberGroup grp = GetExprFactory().CreateMemGroup((EXPRFLAG)mem.GetFlags(),
pName, BSYMMGR.EmptyTypeArray(), mem.SymFirst().getKind(), mem.GetSourceType(), null/*pMPS*/, mem.GetObject(), mem.GetResults());
Expand Down Expand Up @@ -796,9 +796,9 @@ internal Expr BindToProperty(Expr pObject, PropWithType pwt, BindingFlag bindFla
pwt.Sym is PropertySymbol &&
pwt.GetType() != null &&
pwt.Prop().getClass() == pwt.GetType().getAggregate());
Debug.Assert(pwt.Prop().Params.Count == 0 || pwt.Prop().isIndexer());
Debug.Assert(pwt.Prop().Params.Count == 0 || pwt.Prop() is IndexerSymbol);
Debug.Assert(pOtherType == null ||
!pwt.Prop().isIndexer() &&
!(pwt.Prop() is IndexerSymbol) &&
pOtherType.getAggregate() == pwt.Prop().RetType.getAggregate());

bool fConstrained;
Expand Down Expand Up @@ -1036,16 +1036,6 @@ internal Expr bindUDUnop(ExpressionKind ek, Expr arg)
return rval;
}

if (SemanticChecker.CheckBogus(pmethBest.mpwi.Meth()))
{
ErrorContext.ErrorRef(ErrorCode.ERR_BindToBogus, pmethBest.mpwi);

ExprMemberGroup pMemGroup = GetExprFactory().CreateMemGroup(null, pmethBest.mpwi);
ExprCall rval = GetExprFactory().CreateCall(0, null, arg, pMemGroup, null);
rval.SetError();
return rval;
}

ExprCall call;

if (pmethBest.ctypeLift != 0)
Expand Down Expand Up @@ -1457,18 +1447,18 @@ private void PostBindProperty(bool fBaseCall, PropWithType pwt, Expr pObject, ou
pmwtGet = new MethWithType();
pmwtSet = new MethWithType();
// Get the accessors.
if (pwt.Prop().methGet != null)
if (pwt.Prop().GetterMethod != null)
{
pmwtGet.Set(pwt.Prop().methGet, pwt.GetType());
pmwtGet.Set(pwt.Prop().GetterMethod, pwt.GetType());
}
else
{
pmwtGet.Clear();
}

if (pwt.Prop().methSet != null)
if (pwt.Prop().SetterMethod != null)
{
pmwtSet.Set(pwt.Prop().methSet, pwt.GetType());
pmwtSet.Set(pwt.Prop().SetterMethod, pwt.GetType());
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ private void LookForCandidates()
if (!bFoundExpanded)
{
lookedAtCandidates = true;
allCandidatesUnsupported &= _pCurrentSym.getBogus();
allCandidatesUnsupported &= CSemanticChecker.CheckBogus(_pCurrentSym);

// If we have the wrong number of arguments and still have room in our cache of 20,
// then store it in our cache and go to the next sym.
Expand Down Expand Up @@ -694,13 +694,13 @@ public static MethodOrPropertySymbol FindMostDerivedMethod(
if (!(pMethProp is MethodSymbol method))
{
PropertySymbol prop = (PropertySymbol)pMethProp;
method = prop.methGet ?? prop.methSet;
method = prop.GetterMethod ?? prop.SetterMethod;
if (method == null)
{
return null;
}

bIsIndexer = prop.isIndexer();
bIsIndexer = prop is IndexerSymbol;
}

if (!method.isVirtual || pType == null)
Expand Down Expand Up @@ -1512,10 +1512,7 @@ private void ReportErrorsForBestMatching(bool bUseDelegateErrors, Name nameErr)
if (ivar == 0 && sym is MethodSymbol meth && meth.IsExtension() && _pGroup.OptionalObject != null &&
!_pExprBinder.canConvertInstanceParamForExtension(_pGroup.OptionalObject, meth.Params[0]))
{
if (!_pGroup.OptionalObject.Type.getBogus())
{
GetErrorContext().Error(ErrorCode.ERR_BadInstanceArgType, _pGroup.OptionalObject.Type, var);
}
GetErrorContext().Error(ErrorCode.ERR_BadInstanceArgType, _pGroup.OptionalObject.Type, var);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ private void RecordType(AggregateType type, Symbol sym)
_swtFirst.Set(sym, type);
Debug.Assert(_csym == 1);
Debug.Assert(_prgtype[0] == type);
_fMulti = sym is MethodSymbol || sym is PropertySymbol prop && prop.isIndexer();
_fMulti = sym is MethodSymbol || sym is IndexerSymbol;
}
}

Expand Down Expand Up @@ -232,7 +232,7 @@ private bool SearchSingleType(AggregateType typeCur, out bool pfHideByName)
// Make sure that whether we're seeing a ctor, operator, or indexer is consistent with the flags.
if (((_flags & MemLookFlags.Ctor) == 0) != (meth == null || !meth.IsConstructor()) ||
((_flags & MemLookFlags.Operator) == 0) != (meth == null || !meth.isOperator) ||
((_flags & MemLookFlags.Indexer) == 0) != (prop == null || !prop.isIndexer()))
((_flags & MemLookFlags.Indexer) == 0) != !(prop is IndexerSymbol))
{
if (!_swtBad)
{
Expand All @@ -244,7 +244,7 @@ private bool SearchSingleType(AggregateType typeCur, out bool pfHideByName)
// We can't call CheckBogus on methods or indexers because if the method has the wrong
// number of parameters people don't think they should have to /r the assemblies containing
// the parameter types and they complain about the resulting CS0012 errors.
if (!(symCur is MethodSymbol) && (_flags & MemLookFlags.Indexer) == 0 && GetSemanticChecker().CheckBogus(symCur))
if (!(symCur is MethodSymbol) && (_flags & MemLookFlags.Indexer) == 0 && CSemanticChecker.CheckBogus(symCur))
{
// A bogus member - we can't use these, so only record them for error reporting.
if (!_swtBogus)
Expand Down Expand Up @@ -535,45 +535,22 @@ private bool LookupInInterfaces(AggregateType typeStart, TypeArray types)

private void ReportBogus(SymWithType swt)
{
Debug.Assert(swt.Sym.hasBogus() && swt.Sym.checkBogus());

switch (swt.Sym.getKind())
Debug.Assert(CSemanticChecker.CheckBogus(swt.Sym));
MethodSymbol meth1 = swt.Prop().GetterMethod;
MethodSymbol meth2 = swt.Prop().SetterMethod;
Debug.Assert((meth1 ?? meth2) != null);
if (meth1 == null | meth2 == null)
{
case SYMKIND.SK_PropertySymbol:
if (swt.Prop().useMethInstead)
{
MethodSymbol meth1 = swt.Prop().methGet;
MethodSymbol meth2 = swt.Prop().methSet;
ReportBogusForEventsAndProperties(swt, meth1, meth2);
return;
}
break;

case SYMKIND.SK_MethodSymbol:
if (swt.Meth().name == NameManager.GetPredefinedName(PredefinedName.PN_INVOKE) && swt.Meth().getClass().IsDelegate())
{
swt.Set(swt.Meth().getClass(), swt.GetType());
}
break;
GetErrorContext().Error(
ErrorCode.ERR_BindToBogusProp1, swt.Sym.name, new SymWithType(meth1 ?? meth2, swt.GetType()),
new ErrArgRefOnly(swt.Sym));
}

// Generic bogus error.
GetErrorContext().ErrorRef(ErrorCode.ERR_BindToBogus, swt);
}

private void ReportBogusForEventsAndProperties(SymWithType swt, MethodSymbol meth1, MethodSymbol meth2)
{
if (meth1 != null && meth2 != null)
{
GetErrorContext().Error(ErrorCode.ERR_BindToBogusProp2, swt.Sym.name, new SymWithType(meth1, swt.GetType()), new SymWithType(meth2, swt.GetType()), new ErrArgRefOnly(swt.Sym));
return;
}
if (meth1 != null || meth2 != null)
else
{
GetErrorContext().Error(ErrorCode.ERR_BindToBogusProp1, swt.Sym.name, new SymWithType(meth1 != null ? meth1 : meth2, swt.GetType()), new ErrArgRefOnly(swt.Sym));
return;
GetErrorContext().Error(
ErrorCode.ERR_BindToBogusProp2, swt.Sym.name, new SymWithType(meth1, swt.GetType()),
new SymWithType(meth2, swt.GetType()), new ErrArgRefOnly(swt.Sym));
}
throw Error.InternalCompilerError();
}

private bool IsDelegateType(CType pSrcType, AggregateType pAggType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public bool CanUseCurrentSymbol()
if (_mask == symbmask_t.MASK_MethodSymbol && (
0 == (_flags & EXPRFLAG.EXF_CTOR) != !((MethodSymbol)_pCurrentSym).IsConstructor() ||
0 == (_flags & EXPRFLAG.EXF_OPERATOR) != !((MethodSymbol)_pCurrentSym).isOperator) ||
_mask == symbmask_t.MASK_PropertySymbol && !((PropertySymbol)_pCurrentSym).isIndexer())
_mask == symbmask_t.MASK_PropertySymbol && !(_pCurrentSym is IndexerSymbol))
{
// Get the next symbol.
return false;
Expand Down Expand Up @@ -181,7 +181,7 @@ public bool CanUseCurrentSymbol()
}

// Check bogus.
if (GetSemanticChecker().CheckBogus(_pCurrentSym))
if (CSemanticChecker.CheckBogus(_pCurrentSym))
{
// Sym is bogus, but if we're allow it, then let it through and mark it.
if (_bAllowBogusAndInaccessible)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2758,16 +2758,6 @@ private ExprCall BindUDBinop(ExpressionKind ek, Expr arg1, Expr arg2, bool fDont
return rval;
}

if (GetSemanticChecker().CheckBogus(pmethBest.mpwi.Meth()))
{
GetErrorContext().ErrorRef(ErrorCode.ERR_BindToBogus, pmethBest.mpwi);

ExprMemberGroup pMemGroup = GetExprFactory().CreateMemGroup(null, pmethBest.mpwi);
ExprCall rval = GetExprFactory().CreateCall(0, null, GetExprFactory().CreateList(arg1, arg2), pMemGroup, null);
rval.SetError();
return rval;
}

ppmpwi = pmethBest.mpwi;

if (pmethBest.ctypeLift != 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,13 +353,10 @@ private PropertySymbol LoadProperty(
property = getter.getProperty();
Debug.Assert(property != null);

if (property.name != propertyName ||
(propertySetter != PREDEFMETH.PM_COUNT &&
(setter == null ||
!setter.isPropertyAccessor() ||
setter.getProperty() != property)) ||
property.getBogus())
if (property.name != propertyName || propertySetter != PREDEFMETH.PM_COUNT
&& (setter == null || !setter.isPropertyAccessor() || setter.getProperty() != property))
{
Debug.Assert(!property.Bogus);
property = null;
}
}
Expand Down Expand Up @@ -610,8 +607,7 @@ private MethodSymbol LookupMethodWhileLoading(AggregateSymbol type, int cMethodT
methsym.typeVars.Count == cMethodTyVars &&
GetTypeManager().SubstEqualTypes(methsym.RetType, returnType, null, methsym.typeVars, SubstTypeFlags.DenormMeth) &&
GetTypeManager().SubstEqualTypeArrays(methsym.Params, argumentTypes, (TypeArray)null,
methsym.typeVars, SubstTypeFlags.DenormMeth) &&
!methsym.getBogus())
methsym.typeVars, SubstTypeFlags.DenormMeth))
{
return methsym;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,48 +286,9 @@ typeThru is NullableType ||
return (atsThru == null) ? ACCESSERROR.ACCESSERROR_NOACCESS : ACCESSERROR.ACCESSERROR_NOACCESSTHRU;
}

public bool CheckBogus(Symbol sym)
public static bool CheckBogus(Symbol sym)
{
if (sym == null)
{
return false;
}

if (!sym.hasBogus())
{
bool fBogus = sym.computeCurrentBogusState();

if (fBogus)
{
// Only set this if everything is declared or
// at least 1 declared thing is bogus
sym.setBogus(fBogus);
}
}

return sym.hasBogus() && sym.checkBogus();
}

public bool CheckBogus(CType pType)
{
if (pType == null)
{
return false;
}

if (!pType.hasBogus())
{
bool fBogus = pType.computeCurrentBogusState();

if (fBogus)
{
// Only set this if everything is declared or
// at least 1 declared thing is bogus
pType.setBogus(fBogus);
}
}

return pType.hasBogus() && pType.checkBogus();
return (sym as PropertySymbol)?.Bogus ?? false;
}

public void ReportAccessError(SymWithType swtBad, Symbol symWhere, CType typeQual)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ internal abstract class MethodOrPropertySymbol : ParentSymbol

public new bool isStatic; // Static member?
public bool isOverride; // Overrides an inherited member. Only valid if isVirtual is set.
// false implies that a new vtable slot is required for this method.
public bool useMethInstead; // Only valid iff isBogus == TRUE && IsPropertySymbol().
// If this is true then tell the user to call the accessors directly.
// false implies that a new vtable slot is required for this method.
public bool isOperator; // a user defined operator (or default indexed property)
public bool isParamArray; // new style varargs
public bool isHideByName; // this property hides all below it regardless of signature
Expand Down
Loading