From db6db4a075df7e5a80050b3611df69243b347618 Mon Sep 17 00:00:00 2001 From: Jon Hanna Date: Mon, 22 Jan 2018 20:35:20 +0000 Subject: Remove test for "wrong nested this" in Microsoft.CSharp (#26417) * Remove test for "wrong nested this" in Microsoft.CSharp Since we have dynamically found a member by examining a type or the type of an object, it can never not be nor be derived from the type the member was found on, unlike in the static binding when where lookup can include outer classes, (with CS0038 resulting if the member found isn't static). Remove the test, which involves removing ERR_WrongNestedThis, contributing to #22470 * Remove duplication in assertion. --- .../src/Microsoft/CSharp/RuntimeBinder/Errors/ErrorCode.cs | 1 - .../Microsoft/CSharp/RuntimeBinder/Errors/ErrorFacts.cs | 3 --- .../CSharp/RuntimeBinder/Semantics/ExpressionBinder.cs | 14 ++------------ src/Microsoft.CSharp/src/Resources/Strings.de.resx | 3 --- src/Microsoft.CSharp/src/Resources/Strings.es.resx | 3 --- src/Microsoft.CSharp/src/Resources/Strings.fr.resx | 3 --- src/Microsoft.CSharp/src/Resources/Strings.it.resx | 3 --- src/Microsoft.CSharp/src/Resources/Strings.ja.resx | 3 --- src/Microsoft.CSharp/src/Resources/Strings.ko.resx | 3 --- src/Microsoft.CSharp/src/Resources/Strings.resx | 3 --- src/Microsoft.CSharp/src/Resources/Strings.ru.resx | 3 --- src/Microsoft.CSharp/src/Resources/Strings.zh-Hans.resx | 3 --- src/Microsoft.CSharp/src/Resources/Strings.zh-Hant.resx | 3 --- 13 files changed, 2 insertions(+), 46 deletions(-) (limited to 'src') diff --git a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Errors/ErrorCode.cs b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Errors/ErrorCode.cs index c762ace62d..062b2f091b 100644 --- a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Errors/ErrorCode.cs +++ b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Errors/ErrorCode.cs @@ -16,7 +16,6 @@ namespace Microsoft.CSharp.RuntimeBinder.Errors ERR_AmbigBinaryOps = 34, ERR_AmbigUnaryOp = 35, ERR_ValueCantBeNull = 37, - ERR_WrongNestedThis = 38, ERR_NoSuchMember = 117, ERR_ObjectRequired = 120, ERR_AmbigCall = 121, diff --git a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Errors/ErrorFacts.cs b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Errors/ErrorFacts.cs index 81c4f736d2..f11188386c 100644 --- a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Errors/ErrorFacts.cs +++ b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Errors/ErrorFacts.cs @@ -44,9 +44,6 @@ namespace Microsoft.CSharp.RuntimeBinder.Errors case ErrorCode.ERR_ValueCantBeNull: codeStr = SR.ValueCantBeNull; break; - case ErrorCode.ERR_WrongNestedThis: - codeStr = SR.WrongNestedThis; - break; case ErrorCode.ERR_NoSuchMember: codeStr = SR.NoSuchMember; break; diff --git a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/ExpressionBinder.cs b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/ExpressionBinder.cs index 00ca1e2c6b..7834c8cc1f 100644 --- a/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/ExpressionBinder.cs +++ b/src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Semantics/ExpressionBinder.cs @@ -1150,18 +1150,8 @@ namespace Microsoft.CSharp.RuntimeBinder.Semantics pfConstrained = true; } - Expr objNew = tryConvert(pObject, swt.GetType(), CONVERTTYPE.NOUDC); - - // This check ensures that we do not bind to methods in an outer class - // which are visible, but whose this pointer is of an incorrect type... - // ... also handles case of calling an pObject method on a RefAny value. - // WE don't give a great message for this, but it'll do. - if (objNew == null) - { - throw ErrorContext.Error(ErrorCode.ERR_WrongNestedThis, swt.GetType(), pObject.Type); - } - - pObject = objNew; + pObject = tryConvert(pObject, swt.GetType(), CONVERTTYPE.NOUDC); + Debug.Assert(pObject != null); } return pObject; diff --git a/src/Microsoft.CSharp/src/Resources/Strings.de.resx b/src/Microsoft.CSharp/src/Resources/Strings.de.resx index 0b9a2ff9f1..38d09851f4 100644 --- a/src/Microsoft.CSharp/src/Resources/Strings.de.resx +++ b/src/Microsoft.CSharp/src/Resources/Strings.de.resx @@ -81,9 +81,6 @@ NULL kann nicht in {0} konvertiert werden, da dieser Werttyp nicht auf NULL festgelegt werden kann. - - Auf einen nicht statischen Member des äußeren {0}-Typs kann nicht über den geschachtelten {1}-Typ zugegriffen werden. - {0} enthält keine Definition für {1}. diff --git a/src/Microsoft.CSharp/src/Resources/Strings.es.resx b/src/Microsoft.CSharp/src/Resources/Strings.es.resx index b50227d36d..2ecf6454cb 100644 --- a/src/Microsoft.CSharp/src/Resources/Strings.es.resx +++ b/src/Microsoft.CSharp/src/Resources/Strings.es.resx @@ -81,9 +81,6 @@ No se puede convertir NULL en '{0}' porque es un tipo de valor que no acepta valores NULL. - - No se puede obtener acceso a un miembro no estático de tipo externo '{0}' mediante el tipo anidado '{1}'. - '{0}' no contiene una definición para '{1}'. diff --git a/src/Microsoft.CSharp/src/Resources/Strings.fr.resx b/src/Microsoft.CSharp/src/Resources/Strings.fr.resx index e31fb94aab..4879b314dc 100644 --- a/src/Microsoft.CSharp/src/Resources/Strings.fr.resx +++ b/src/Microsoft.CSharp/src/Resources/Strings.fr.resx @@ -81,9 +81,6 @@ Impossible de convertir null en '{0}', car il s'agit d'un type valeur qui n'autorise pas les valeurs null - - Impossible d'accéder à un membre non statique de type externe '{0}' par l'intermédiaire du type imbriqué '{1}' - '{0}' ne contient pas de définition pour '{1}' diff --git a/src/Microsoft.CSharp/src/Resources/Strings.it.resx b/src/Microsoft.CSharp/src/Resources/Strings.it.resx index 7ca475533f..4c215fcd65 100644 --- a/src/Microsoft.CSharp/src/Resources/Strings.it.resx +++ b/src/Microsoft.CSharp/src/Resources/Strings.it.resx @@ -81,9 +81,6 @@ Impossibile convertire Null in '{0}' perché è un tipo di valore non nullable - - Impossibile accedere a un membro non statico di tipo outer '{0}' tramite il tipo annidato '{1}' - '{0}' non contiene una definizione per '{1}' diff --git a/src/Microsoft.CSharp/src/Resources/Strings.ja.resx b/src/Microsoft.CSharp/src/Resources/Strings.ja.resx index 861002fe0a..3807dae995 100644 --- a/src/Microsoft.CSharp/src/Resources/Strings.ja.resx +++ b/src/Microsoft.CSharp/src/Resources/Strings.ja.resx @@ -81,9 +81,6 @@ Null 非許容の値型であるため、Null を '{0}' に変換できません - - 入れ子にされた型 '{1}' を経由して、外の型 '{0}' の静的でないメンバーにアクセスすることはできません - '{0}' に '{1}' の定義がありません diff --git a/src/Microsoft.CSharp/src/Resources/Strings.ko.resx b/src/Microsoft.CSharp/src/Resources/Strings.ko.resx index a2a6b1bf15..609342acc1 100644 --- a/src/Microsoft.CSharp/src/Resources/Strings.ko.resx +++ b/src/Microsoft.CSharp/src/Resources/Strings.ko.resx @@ -81,9 +81,6 @@ '{0}'은(는) null을 허용하지 않는 값 형식이므로 null을 이 형식으로 변환할 수 없습니다. - - 중첩 형식 '{1}'을(를) 통해 외부 형식 '{0}'의 static이 아닌 멤버에 액세스할 수 없습니다. - '{0}'에 '{1}'에 대한 정의가 없습니다. diff --git a/src/Microsoft.CSharp/src/Resources/Strings.resx b/src/Microsoft.CSharp/src/Resources/Strings.resx index 462e5c137e..1ffdac1c11 100644 --- a/src/Microsoft.CSharp/src/Resources/Strings.resx +++ b/src/Microsoft.CSharp/src/Resources/Strings.resx @@ -109,9 +109,6 @@ Cannot convert null to '{0}' because it is a non-nullable value type - - Cannot access a non-static member of outer type '{0}' via nested type '{1}' - '{0}' does not contain a definition for '{1}' diff --git a/src/Microsoft.CSharp/src/Resources/Strings.ru.resx b/src/Microsoft.CSharp/src/Resources/Strings.ru.resx index 9c982cc8df..78b66c55fb 100644 --- a/src/Microsoft.CSharp/src/Resources/Strings.ru.resx +++ b/src/Microsoft.CSharp/src/Resources/Strings.ru.resx @@ -81,9 +81,6 @@ Cannot convert null to "{0}" because it is a non-nullable value type - - Невозможно получить доступ к нестатическому члену внешнего типа "{0}" через вложенный тип "{1}" - "{0}" не содержит определения для "{1}" diff --git a/src/Microsoft.CSharp/src/Resources/Strings.zh-Hans.resx b/src/Microsoft.CSharp/src/Resources/Strings.zh-Hans.resx index c4f57cf06a..65ecb7fc02 100644 --- a/src/Microsoft.CSharp/src/Resources/Strings.zh-Hans.resx +++ b/src/Microsoft.CSharp/src/Resources/Strings.zh-Hans.resx @@ -81,9 +81,6 @@ 无法将 null 转换为“{0}”,因为后者是不可以为 null 的值类型 - - 无法通过嵌套类型“{1}”来访问外部类型“{0}”的非静态成员 - “{0}”未包含“{1}”的定义 diff --git a/src/Microsoft.CSharp/src/Resources/Strings.zh-Hant.resx b/src/Microsoft.CSharp/src/Resources/Strings.zh-Hant.resx index 55ec74b0d6..0517ad500e 100644 --- a/src/Microsoft.CSharp/src/Resources/Strings.zh-Hant.resx +++ b/src/Microsoft.CSharp/src/Resources/Strings.zh-Hant.resx @@ -81,9 +81,6 @@ 無法將 null 轉換成 '{0}',因為它是不可為 null 的實值型別 - - 無法透過巢狀型別 '{1}' 存取外部型別 '{0}' 的非靜態成員 - '{0}' 不包含 '{1}' 的定義 -- cgit v1.2.3