diff --git a/src/Compilers/CSharp/Portable/Binder/Binder_Expressions.cs b/src/Compilers/CSharp/Portable/Binder/Binder_Expressions.cs index 15776dae68dca..456580dc858d4 100644 --- a/src/Compilers/CSharp/Portable/Binder/Binder_Expressions.cs +++ b/src/Compilers/CSharp/Portable/Binder/Binder_Expressions.cs @@ -6207,9 +6207,9 @@ private BoundExpression BindInstanceMemberAccess( lookupResult, flags); - if (!boundMethodGroup.HasErrors && boundMethodGroup.ResultKind == LookupResultKind.Empty && typeArgumentsSyntax.Any(SyntaxKind.OmittedTypeArgument)) + if (!boundMethodGroup.HasErrors && typeArgumentsSyntax.Any(SyntaxKind.OmittedTypeArgument)) { - Error(diagnostics, ErrorCode.ERR_BadArity, node, rightName, MessageID.IDS_MethodGroup.Localize(), typeArgumentsSyntax.Count); + Error(diagnostics, ErrorCode.ERR_OmittedTypeArgument, node); } return boundMethodGroup; diff --git a/src/Compilers/CSharp/Portable/CSharpResources.resx b/src/Compilers/CSharp/Portable/CSharpResources.resx index d0f8c18de2bf6..e38175ee924cd 100644 --- a/src/Compilers/CSharp/Portable/CSharpResources.resx +++ b/src/Compilers/CSharp/Portable/CSharpResources.resx @@ -471,6 +471,9 @@ Keyword 'this' is not available in the current context + + Omitting the type argument is not allowed in the current context + '{0}' has the wrong signature to be an entry point diff --git a/src/Compilers/CSharp/Portable/Errors/ErrorCode.cs b/src/Compilers/CSharp/Portable/Errors/ErrorCode.cs index 0d319758d6705..bb266a9c44ecc 100644 --- a/src/Compilers/CSharp/Portable/Errors/ErrorCode.cs +++ b/src/Compilers/CSharp/Portable/Errors/ErrorCode.cs @@ -1581,6 +1581,7 @@ internal enum ErrorCode WRN_TypeParameterSameAsOuterMethodTypeParameter = 8387, ERR_OutVariableCannotBeByRef = 8388, + ERR_OmittedTypeArgument = 8389, #region diagnostics introduced for C# 8.0 ERR_FeatureNotAvailableInVersion8 = 8400, diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf index c39bf3a0595e1..08fc6d0b5e9c8 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf @@ -522,6 +522,11 @@ Parametr typu s možnou hodnotou null musí být známou hodnotou nebo musí jít o typ odkazu, který nemůže mít hodnotu null. Zvažte přidání 'class', 'struct' nebo omezení typu. + + Omitting the type argument is not allowed in the current context + Omitting the type argument is not allowed in the current context + + An out variable cannot be declared as a ref local Výstupní proměnná nemůže být deklarovaná jako lokální proměnná podle odkazu. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf index b810fd96d826a..0f5d10480c6d0 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf @@ -522,6 +522,11 @@ Ein Nullable-Typparameter muss als Werttyp oder als Non-Nullable-Verweistyp bekannt sein. Sie sollten eine class-, struct- oder eine Typeinschränkung hinzufügen. + + Omitting the type argument is not allowed in the current context + Omitting the type argument is not allowed in the current context + + An out variable cannot be declared as a ref local Eine out-Variable kann nicht als lokales ref-Element deklariert werden. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf index 9c4dfff940905..516e4c57a12da 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf @@ -522,6 +522,11 @@ Debe saberse si un parámetro de tipo que acepta valores NULL es un tipo de valor o un tipo de referencia que no admite valores NULL. Considere agregar "class", "struct" o una restricción de tipo. + + Omitting the type argument is not allowed in the current context + Omitting the type argument is not allowed in the current context + + An out variable cannot be declared as a ref local Una variable out no se puede declarar como ref local diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf index 636f2cbeccac3..2eb58be273ff2 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf @@ -522,6 +522,11 @@ Un paramètre de type nullable doit être connu pour pouvoir être un type valeur ou un type référence non-nullable. Ajoutez une contrainte 'class', 'struct' ou une contrainte de type. + + Omitting the type argument is not allowed in the current context + Omitting the type argument is not allowed in the current context + + An out variable cannot be declared as a ref local Impossible de déclarer une variable out en tant que variable locale ref diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf index bd12bad29c429..de5534b1d1769 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf @@ -522,6 +522,11 @@ Un parametro di tipo che ammette i valori Null deve essere noto per essere un tipo valore o un tipo riferimento che non ammette i valori Null. Provare ad aggiungere un vincolo di tipo, 'class' o 'struct'. + + Omitting the type argument is not allowed in the current context + Omitting the type argument is not allowed in the current context + + An out variable cannot be declared as a ref local Non è possibile dichiarare una variabile out come variabile locale ref diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf index eb87b224cf146..0c90a72a7cd92 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf @@ -522,6 +522,11 @@ Null 許容型パラメーターは、値の型または Null 非許容参照型として既知である必要があります。'class'、'struct'、型制約を追加することをご検討ください。 + + Omitting the type argument is not allowed in the current context + Omitting the type argument is not allowed in the current context + + An out variable cannot be declared as a ref local out 変数を ref ローカルと宣言することはできません diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf index 6fdc509ff6f67..199b92ecbc1d5 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf @@ -522,6 +522,11 @@ 값 형식 또는 null을 허용하지 않는 참조 형식이 되려면 nullable 형식 매개 변수를 알려야 합니다. 'class', 'struct' 또는 형식 제약 조건 추가를 고려하세요. + + Omitting the type argument is not allowed in the current context + Omitting the type argument is not allowed in the current context + + An out variable cannot be declared as a ref local 출력 변수는 참조 로컬로 선언할 수 없습니다. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf index 4a53f3e9c344b..a9c4d8a52c3ef 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf @@ -522,6 +522,11 @@ Nullowalny parametr typumusi być typem wartości lub nienullowalnym typem referencyjnym. Rozważ dodanie elementu „class”, „struct” lub ograniczenia typu. + + Omitting the type argument is not allowed in the current context + Omitting the type argument is not allowed in the current context + + An out variable cannot be declared as a ref local Zmiennej out nie można zadeklarować jako lokalnej zmiennej ref diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf index 13a55d0ec0f4f..6e2c28a47b4c4 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf @@ -522,6 +522,11 @@ Um parâmetro de tipo que permite valor nulo precisa ser um tipo de valor ou um tipo de referência não anulável. Considere a possibilidade de adicionar 'class', 'struct' ou restrição de tipo. + + Omitting the type argument is not allowed in the current context + Omitting the type argument is not allowed in the current context + + An out variable cannot be declared as a ref local Uma variável out não pode ser declarada como uma referência local diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf index 734f1f2665d0f..75ecbf0b9a868 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf @@ -522,6 +522,11 @@ Параметр типа, допускающего значение NULL, должен быть известен как тип значения или ссылочный тип, не допускающий значение NULL. Рекомендуется добавить "class", "struct" или ограничение типа. + + Omitting the type argument is not allowed in the current context + Omitting the type argument is not allowed in the current context + + An out variable cannot be declared as a ref local Выходная переменная не может быть объявлена как локальная переменная ref diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf index 461fe2e2b32ee..c60c2a87e2c6e 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf @@ -522,6 +522,11 @@ Boş değer atanabilir bir tür parametresi bilinen bir değer türü veya boş değer atanamayan bir başvuru türü olmalıdır. Bir 'class', 'struct' veya tür kısıtlaması eklemeyi düşünün. + + Omitting the type argument is not allowed in the current context + Omitting the type argument is not allowed in the current context + + An out variable cannot be declared as a ref local Bir out değişkeni ref yerel değeri olarak bildirilemez diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf index ad479c03ac475..6b564653b4a91 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf @@ -522,6 +522,11 @@ 可为 null 的类型参数必须已知为值类型或不可为 null 引用类型。请考虑添加一个 “class”、“struct” 或类型约束。 + + Omitting the type argument is not allowed in the current context + Omitting the type argument is not allowed in the current context + + An out variable cannot be declared as a ref local out 变量无法声明为 ref 局部变量 diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf index 1f1a6c94f3ab4..38c0b1775599c 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf @@ -522,6 +522,11 @@ 可為 Null 的型別參數必須已知為實值型別或不可為 Null 的參考型別。建議新增 'class'、'struct' 或型別條件約束。 + + Omitting the type argument is not allowed in the current context + Omitting the type argument is not allowed in the current context + + An out variable cannot be declared as a ref local out 變數不可宣告為 ref local diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/BindingTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/BindingTests.cs index 367e5b24d1d6b..2f33afac51fba 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/BindingTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/BindingTests.cs @@ -3516,81 +3516,81 @@ public void Test() var compilation = CreateCompilationWithMscorlib40AndSystemCore(source); compilation.VerifyDiagnostics( - // (13,27): error CS0305: Using the generic method group 'ExtensionMethod0' requires 1 type arguments - // var omittedArg0 = "string literal".ExtensionMethod0<>(); - Diagnostic(ErrorCode.ERR_BadArity, @"""string literal"".ExtensionMethod0<>").WithArguments("ExtensionMethod0", "method group", "1").WithLocation(13, 27), - // (13,44): error CS1061: 'string' does not contain a definition for 'ExtensionMethod0' and no extension method 'ExtensionMethod0' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?) - // var omittedArg0 = "string literal".ExtensionMethod0<>(); - Diagnostic(ErrorCode.ERR_NoSuchMemberOrExtension, "ExtensionMethod0<>").WithArguments("string", "ExtensionMethod0").WithLocation(13, 44), - // (14,27): error CS0305: Using the generic method group 'ExtensionMethod1' requires 1 type arguments - // var omittedArg1 = "string literal".ExtensionMethod1<>(); - Diagnostic(ErrorCode.ERR_BadArity, @"""string literal"".ExtensionMethod1<>").WithArguments("ExtensionMethod1", "method group", "1").WithLocation(14, 27), - // (15,27): error CS0305: Using the generic method group 'ExtensionMethod2' requires 1 type arguments - // var omittedArg2 = "string literal".ExtensionMethod2<>(); - Diagnostic(ErrorCode.ERR_BadArity, @"""string literal"".ExtensionMethod2<>").WithArguments("ExtensionMethod2", "method group", "1").WithLocation(15, 27), - // (15,44): error CS1061: 'string' does not contain a definition for 'ExtensionMethod2' and no extension method 'ExtensionMethod2' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?) - // var omittedArg2 = "string literal".ExtensionMethod2<>(); - Diagnostic(ErrorCode.ERR_NoSuchMemberOrExtension, "ExtensionMethod2<>").WithArguments("string", "ExtensionMethod2").WithLocation(15, 44), - // (17,31): error CS0305: Using the generic method group 'ExtensionMethod0' requires 1 type arguments - // var omittedArgFunc0 = "string literal".ExtensionMethod0<>; - Diagnostic(ErrorCode.ERR_BadArity, @"""string literal"".ExtensionMethod0<>").WithArguments("ExtensionMethod0", "method group", "1").WithLocation(17, 31), - // (17,48): error CS1061: 'string' does not contain a definition for 'ExtensionMethod0' and no extension method 'ExtensionMethod0' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?) - // var omittedArgFunc0 = "string literal".ExtensionMethod0<>; - Diagnostic(ErrorCode.ERR_NoSuchMemberOrExtension, "ExtensionMethod0<>").WithArguments("string", "ExtensionMethod0").WithLocation(17, 48), - // (18,31): error CS0305: Using the generic method group 'ExtensionMethod1' requires 1 type arguments - // var omittedArgFunc1 = "string literal".ExtensionMethod1<>; - Diagnostic(ErrorCode.ERR_BadArity, @"""string literal"".ExtensionMethod1<>").WithArguments("ExtensionMethod1", "method group", "1").WithLocation(18, 31), - // (18,13): error CS0815: Cannot assign method group to an implicitly-typed variable - // var omittedArgFunc1 = "string literal".ExtensionMethod1<>; - Diagnostic(ErrorCode.ERR_ImplicitlyTypedVariableAssignedBadValue, @"omittedArgFunc1 = ""string literal"".ExtensionMethod1<>").WithArguments("method group").WithLocation(18, 13), - // (19,31): error CS0305: Using the generic method group 'ExtensionMethod2' requires 1 type arguments - // var omittedArgFunc2 = "string literal".ExtensionMethod2<>; - Diagnostic(ErrorCode.ERR_BadArity, @"""string literal"".ExtensionMethod2<>").WithArguments("ExtensionMethod2", "method group", "1").WithLocation(19, 31), - // (19,48): error CS1061: 'string' does not contain a definition for 'ExtensionMethod2' and no extension method 'ExtensionMethod2' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?) - // var omittedArgFunc2 = "string literal".ExtensionMethod2<>; - Diagnostic(ErrorCode.ERR_NoSuchMemberOrExtension, "ExtensionMethod2<>").WithArguments("string", "ExtensionMethod2").WithLocation(19, 48), - // (21,42): error CS1061: 'string' does not contain a definition for 'ExtensionMethod0' and no extension method 'ExtensionMethod0' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?) - // var moreArgs0 = "string literal".ExtensionMethod0(); - Diagnostic(ErrorCode.ERR_NoSuchMemberOrExtension, "ExtensionMethod0").WithArguments("string", "ExtensionMethod0").WithLocation(21, 42), - // (22,42): error CS1061: 'string' does not contain a definition for 'ExtensionMethod1' and no extension method 'ExtensionMethod1' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?) - // var moreArgs1 = "string literal".ExtensionMethod1(); - Diagnostic(ErrorCode.ERR_NoSuchMemberOrExtension, "ExtensionMethod1").WithArguments("string", "ExtensionMethod1").WithLocation(22, 42), - // (23,42): error CS1061: 'string' does not contain a definition for 'ExtensionMethod2' and no extension method 'ExtensionMethod2' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?) - // var moreArgs2 = "string literal".ExtensionMethod2(); - Diagnostic(ErrorCode.ERR_NoSuchMemberOrExtension, "ExtensionMethod2").WithArguments("string", "ExtensionMethod2").WithLocation(23, 42), - // (25,42): error CS0411: The type arguments for method 'FooExtensions.ExtensionMethod1(object)' cannot be inferred from the usage. Try specifying the type arguments explicitly. - // var lessArgs1 = "string literal".ExtensionMethod1(); - Diagnostic(ErrorCode.ERR_CantInferMethTypeArgs, "ExtensionMethod1").WithArguments("FooExtensions.ExtensionMethod1(object)").WithLocation(25, 42), - // (26,42): error CS1061: 'string' does not contain a definition for 'ExtensionMethod2' and no extension method 'ExtensionMethod2' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?) - // var lessArgs2 = "string literal".ExtensionMethod2(); - Diagnostic(ErrorCode.ERR_NoSuchMemberOrExtension, "ExtensionMethod2").WithArguments("string", "ExtensionMethod2").WithLocation(26, 42), - // (28,51): error CS1061: 'string' does not contain a definition for 'ExtensionMethodNotFound0' and no extension method 'ExtensionMethodNotFound0' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?) - // var nonExistingMethod0 = "string literal".ExtensionMethodNotFound0(); - Diagnostic(ErrorCode.ERR_NoSuchMemberOrExtension, "ExtensionMethodNotFound0").WithArguments("string", "ExtensionMethodNotFound0").WithLocation(28, 51), - // (29,51): error CS1061: 'string' does not contain a definition for 'ExtensionMethodNotFound1' and no extension method 'ExtensionMethodNotFound1' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?) - // var nonExistingMethod1 = "string literal".ExtensionMethodNotFound1(); - Diagnostic(ErrorCode.ERR_NoSuchMemberOrExtension, "ExtensionMethodNotFound1").WithArguments("string", "ExtensionMethodNotFound1").WithLocation(29, 51), - // (30,51): error CS1061: 'string' does not contain a definition for 'ExtensionMethodNotFound2' and no extension method 'ExtensionMethodNotFound2' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?) - // var nonExistingMethod2 = "string literal".ExtensionMethodNotFound2(); - Diagnostic(ErrorCode.ERR_NoSuchMemberOrExtension, "ExtensionMethodNotFound2").WithArguments("string", "ExtensionMethodNotFound2").WithLocation(30, 51), - // (32,51): error CS0305: Using the generic method group 'ExtensionMethod0' requires 1 type arguments - // System.Func delegateConversion0 = "string literal".ExtensionMethod0<>; - Diagnostic(ErrorCode.ERR_BadArity, @"""string literal"".ExtensionMethod0<>").WithArguments("ExtensionMethod0", "method group", "1").WithLocation(32, 51), - // (32,68): error CS1061: 'string' does not contain a definition for 'ExtensionMethod0' and no extension method 'ExtensionMethod0' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?) - // System.Func delegateConversion0 = "string literal".ExtensionMethod0<>; - Diagnostic(ErrorCode.ERR_NoSuchMemberOrExtension, "ExtensionMethod0<>").WithArguments("string", "ExtensionMethod0").WithLocation(32, 68), - // (33,51): error CS0305: Using the generic method group 'ExtensionMethod1' requires 1 type arguments - // System.Func delegateConversion1 = "string literal".ExtensionMethod1<>; - Diagnostic(ErrorCode.ERR_BadArity, @"""string literal"".ExtensionMethod1<>").WithArguments("ExtensionMethod1", "method group", "1").WithLocation(33, 51), - // (33,51): error CS0407: '? FooExtensions.ExtensionMethod1(object)' has the wrong return type - // System.Func delegateConversion1 = "string literal".ExtensionMethod1<>; - Diagnostic(ErrorCode.ERR_BadRetType, @"""string literal"".ExtensionMethod1<>").WithArguments("FooExtensions.ExtensionMethod1(object)", "?").WithLocation(33, 51), - // (34,51): error CS0305: Using the generic method group 'ExtensionMethod2' requires 1 type arguments - // System.Func delegateConversion2 = "string literal".ExtensionMethod2<>; - Diagnostic(ErrorCode.ERR_BadArity, @"""string literal"".ExtensionMethod2<>").WithArguments("ExtensionMethod2", "method group", "1").WithLocation(34, 51), - // (34,68): error CS1061: 'string' does not contain a definition for 'ExtensionMethod2' and no extension method 'ExtensionMethod2' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?) - // System.Func delegateConversion2 = "string literal".ExtensionMethod2<>; - Diagnostic(ErrorCode.ERR_NoSuchMemberOrExtension, "ExtensionMethod2<>").WithArguments("string", "ExtensionMethod2").WithLocation(34, 68)); + // (13,27): error CS8389: Omitting the type argument is not allowed in the current context + // var omittedArg0 = "string literal".ExtensionMethod0<>(); + Diagnostic(ErrorCode.ERR_OmittedTypeArgument, @"""string literal"".ExtensionMethod0<>").WithLocation(13, 27), + // (13,44): error CS1061: 'string' does not contain a definition for 'ExtensionMethod0' and no accessible extension method 'ExtensionMethod0' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?) + // var omittedArg0 = "string literal".ExtensionMethod0<>(); + Diagnostic(ErrorCode.ERR_NoSuchMemberOrExtension, "ExtensionMethod0<>").WithArguments("string", "ExtensionMethod0").WithLocation(13, 44), + // (14,27): error CS8389: Omitting the type argument is not allowed in the current context + // var omittedArg1 = "string literal".ExtensionMethod1<>(); + Diagnostic(ErrorCode.ERR_OmittedTypeArgument, @"""string literal"".ExtensionMethod1<>").WithLocation(14, 27), + // (15,27): error CS8389: Omitting the type argument is not allowed in the current context + // var omittedArg2 = "string literal".ExtensionMethod2<>(); + Diagnostic(ErrorCode.ERR_OmittedTypeArgument, @"""string literal"".ExtensionMethod2<>").WithLocation(15, 27), + // (15,44): error CS1061: 'string' does not contain a definition for 'ExtensionMethod2' and no accessible extension method 'ExtensionMethod2' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?) + // var omittedArg2 = "string literal".ExtensionMethod2<>(); + Diagnostic(ErrorCode.ERR_NoSuchMemberOrExtension, "ExtensionMethod2<>").WithArguments("string", "ExtensionMethod2").WithLocation(15, 44), + // (17,31): error CS8389: Omitting the type argument is not allowed in the current context + // var omittedArgFunc0 = "string literal".ExtensionMethod0<>; + Diagnostic(ErrorCode.ERR_OmittedTypeArgument, @"""string literal"".ExtensionMethod0<>").WithLocation(17, 31), + // (17,48): error CS1061: 'string' does not contain a definition for 'ExtensionMethod0' and no accessible extension method 'ExtensionMethod0' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?) + // var omittedArgFunc0 = "string literal".ExtensionMethod0<>; + Diagnostic(ErrorCode.ERR_NoSuchMemberOrExtension, "ExtensionMethod0<>").WithArguments("string", "ExtensionMethod0").WithLocation(17, 48), + // (18,31): error CS8389: Omitting the type argument is not allowed in the current context + // var omittedArgFunc1 = "string literal".ExtensionMethod1<>; + Diagnostic(ErrorCode.ERR_OmittedTypeArgument, @"""string literal"".ExtensionMethod1<>").WithLocation(18, 31), + // (18,13): error CS0815: Cannot assign method group to an implicitly-typed variable + // var omittedArgFunc1 = "string literal".ExtensionMethod1<>; + Diagnostic(ErrorCode.ERR_ImplicitlyTypedVariableAssignedBadValue, @"omittedArgFunc1 = ""string literal"".ExtensionMethod1<>").WithArguments("method group").WithLocation(18, 13), + // (19,31): error CS8389: Omitting the type argument is not allowed in the current context + // var omittedArgFunc2 = "string literal".ExtensionMethod2<>; + Diagnostic(ErrorCode.ERR_OmittedTypeArgument, @"""string literal"".ExtensionMethod2<>").WithLocation(19, 31), + // (19,48): error CS1061: 'string' does not contain a definition for 'ExtensionMethod2' and no accessible extension method 'ExtensionMethod2' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?) + // var omittedArgFunc2 = "string literal".ExtensionMethod2<>; + Diagnostic(ErrorCode.ERR_NoSuchMemberOrExtension, "ExtensionMethod2<>").WithArguments("string", "ExtensionMethod2").WithLocation(19, 48), + // (21,42): error CS1061: 'string' does not contain a definition for 'ExtensionMethod0' and no accessible extension method 'ExtensionMethod0' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?) + // var moreArgs0 = "string literal".ExtensionMethod0(); + Diagnostic(ErrorCode.ERR_NoSuchMemberOrExtension, "ExtensionMethod0").WithArguments("string", "ExtensionMethod0").WithLocation(21, 42), + // (22,42): error CS1061: 'string' does not contain a definition for 'ExtensionMethod1' and no accessible extension method 'ExtensionMethod1' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?) + // var moreArgs1 = "string literal".ExtensionMethod1(); + Diagnostic(ErrorCode.ERR_NoSuchMemberOrExtension, "ExtensionMethod1").WithArguments("string", "ExtensionMethod1").WithLocation(22, 42), + // (23,42): error CS1061: 'string' does not contain a definition for 'ExtensionMethod2' and no accessible extension method 'ExtensionMethod2' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?) + // var moreArgs2 = "string literal".ExtensionMethod2(); + Diagnostic(ErrorCode.ERR_NoSuchMemberOrExtension, "ExtensionMethod2").WithArguments("string", "ExtensionMethod2").WithLocation(23, 42), + // (25,42): error CS0411: The type arguments for method 'FooExtensions.ExtensionMethod1(object)' cannot be inferred from the usage. Try specifying the type arguments explicitly. + // var lessArgs1 = "string literal".ExtensionMethod1(); + Diagnostic(ErrorCode.ERR_CantInferMethTypeArgs, "ExtensionMethod1").WithArguments("FooExtensions.ExtensionMethod1(object)").WithLocation(25, 42), + // (26,42): error CS1061: 'string' does not contain a definition for 'ExtensionMethod2' and no accessible extension method 'ExtensionMethod2' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?) + // var lessArgs2 = "string literal".ExtensionMethod2(); + Diagnostic(ErrorCode.ERR_NoSuchMemberOrExtension, "ExtensionMethod2").WithArguments("string", "ExtensionMethod2").WithLocation(26, 42), + // (28,51): error CS1061: 'string' does not contain a definition for 'ExtensionMethodNotFound0' and no accessible extension method 'ExtensionMethodNotFound0' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?) + // var nonExistingMethod0 = "string literal".ExtensionMethodNotFound0(); + Diagnostic(ErrorCode.ERR_NoSuchMemberOrExtension, "ExtensionMethodNotFound0").WithArguments("string", "ExtensionMethodNotFound0").WithLocation(28, 51), + // (29,51): error CS1061: 'string' does not contain a definition for 'ExtensionMethodNotFound1' and no accessible extension method 'ExtensionMethodNotFound1' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?) + // var nonExistingMethod1 = "string literal".ExtensionMethodNotFound1(); + Diagnostic(ErrorCode.ERR_NoSuchMemberOrExtension, "ExtensionMethodNotFound1").WithArguments("string", "ExtensionMethodNotFound1").WithLocation(29, 51), + // (30,51): error CS1061: 'string' does not contain a definition for 'ExtensionMethodNotFound2' and no accessible extension method 'ExtensionMethodNotFound2' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?) + // var nonExistingMethod2 = "string literal".ExtensionMethodNotFound2(); + Diagnostic(ErrorCode.ERR_NoSuchMemberOrExtension, "ExtensionMethodNotFound2").WithArguments("string", "ExtensionMethodNotFound2").WithLocation(30, 51), + // (32,51): error CS8389: Omitting the type argument is not allowed in the current context + // System.Func delegateConversion0 = "string literal".ExtensionMethod0<>; + Diagnostic(ErrorCode.ERR_OmittedTypeArgument, @"""string literal"".ExtensionMethod0<>").WithLocation(32, 51), + // (32,68): error CS1061: 'string' does not contain a definition for 'ExtensionMethod0' and no accessible extension method 'ExtensionMethod0' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?) + // System.Func delegateConversion0 = "string literal".ExtensionMethod0<>; + Diagnostic(ErrorCode.ERR_NoSuchMemberOrExtension, "ExtensionMethod0<>").WithArguments("string", "ExtensionMethod0").WithLocation(32, 68), + // (33,51): error CS8389: Omitting the type argument is not allowed in the current context + // System.Func delegateConversion1 = "string literal".ExtensionMethod1<>; + Diagnostic(ErrorCode.ERR_OmittedTypeArgument, @"""string literal"".ExtensionMethod1<>").WithLocation(33, 51), + // (33,51): error CS0407: '? FooExtensions.ExtensionMethod1(object)' has the wrong return type + // System.Func delegateConversion1 = "string literal".ExtensionMethod1<>; + Diagnostic(ErrorCode.ERR_BadRetType, @"""string literal"".ExtensionMethod1<>").WithArguments("FooExtensions.ExtensionMethod1(object)", "?").WithLocation(33, 51), + // (34,51): error CS8389: Omitting the type argument is not allowed in the current context + // System.Func delegateConversion2 = "string literal".ExtensionMethod2<>; + Diagnostic(ErrorCode.ERR_OmittedTypeArgument, @"""string literal"".ExtensionMethod2<>").WithLocation(34, 51), + // (34,68): error CS1061: 'string' does not contain a definition for 'ExtensionMethod2' and no accessible extension method 'ExtensionMethod2' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?) + // System.Func delegateConversion2 = "string literal".ExtensionMethod2<>; + Diagnostic(ErrorCode.ERR_NoSuchMemberOrExtension, "ExtensionMethod2<>").WithArguments("string", "ExtensionMethod2").WithLocation(34, 68)); } [WorkItem(22757, "https://github.com/dotnet/roslyn/issues/22757")] diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/NameOfTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/NameOfTests.cs index cd828e08d82c6..b81f7d7e7f04f 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/NameOfTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/NameOfTests.cs @@ -295,7 +295,7 @@ class Test // (28,20): error CS0103: The name 'List2' does not exist in the current context // s = nameof(List2<>.Add); Diagnostic(ErrorCode.ERR_NameNotInContext, "List2<>").WithArguments("List2").WithLocation(28, 20), - // (31,20): error CS8149: An alias-qualified name is not an expression. + // (31,20): error CS8083: An alias-qualified name is not an expression. // s = nameof(global::Program); // not an expression Diagnostic(ErrorCode.ERR_AliasQualifiedNameNotAnExpression, "global::Program").WithLocation(31, 20), // (32,20): error CS0305: Using the generic type 'Test' requires 1 type arguments @@ -307,7 +307,7 @@ class Test // (33,20): error CS0841: Cannot use local variable 'b' before it is declared // s = nameof(b); // cannot use before declaration Diagnostic(ErrorCode.ERR_VariableUsedBeforeDeclaration, "b").WithArguments("b").WithLocation(33, 20), - // (35,20): error CS8150: Type parameters are not allowed on a method group as an argument to 'nameof'. + // (35,20): error CS8084: Type parameters are not allowed on a method group as an argument to 'nameof'. // s = nameof(System.Linq.Enumerable.Select); // type parameters not allowed on method group in nameof Diagnostic(ErrorCode.ERR_NameofMethodGroupWithTypeParameters, "System.Linq.Enumerable.Select").WithLocation(35, 20), // (43,13): error CS0103: The name 'nameof' does not exist in the current context diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/SemanticErrorTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/SemanticErrorTests.cs index a2778d5abe676..ae559e9ecf2e8 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/SemanticErrorTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/SemanticErrorTests.cs @@ -22799,76 +22799,123 @@ void Test(object p) "; CreateCompilation(text).VerifyDiagnostics( // (16,14): error CS0307: The variable 'l' cannot be used with type arguments - Diagnostic(ErrorCode.ERR_TypeArgsNotAllowed, "l<>").WithArguments("l", "variable"), + // Test(l<>); + Diagnostic(ErrorCode.ERR_TypeArgsNotAllowed, "l<>").WithArguments("l", "variable").WithLocation(16, 14), // (17,14): error CS0307: The variable 'object' cannot be used with type arguments - Diagnostic(ErrorCode.ERR_TypeArgsNotAllowed, "p<>").WithArguments("object", "variable"), + // Test(p<>); + Diagnostic(ErrorCode.ERR_TypeArgsNotAllowed, "p<>").WithArguments("object", "variable").WithLocation(17, 14), // (19,14): error CS0307: The field 'Program.f' cannot be used with type arguments - Diagnostic(ErrorCode.ERR_TypeArgsNotAllowed, "f<>").WithArguments("Program.f", "field"), + // Test(f<>); + Diagnostic(ErrorCode.ERR_TypeArgsNotAllowed, "f<>").WithArguments("Program.f", "field").WithLocation(19, 14), // (20,14): error CS0307: The property 'Program.P' cannot be used with type arguments - Diagnostic(ErrorCode.ERR_TypeArgsNotAllowed, "P<>").WithArguments("Program.P", "property"), + // Test(P<>); + Diagnostic(ErrorCode.ERR_TypeArgsNotAllowed, "P<>").WithArguments("Program.P", "property").WithLocation(20, 14), // (21,14): error CS0308: The non-generic method 'Program.M()' cannot be used with type arguments - Diagnostic(ErrorCode.ERR_HasNoTypeVars, "M<>").WithArguments("Program.M()", "method"), + // Test(M<>()); + Diagnostic(ErrorCode.ERR_HasNoTypeVars, "M<>").WithArguments("Program.M()", "method").WithLocation(21, 14), + // (23,14): error CS8389: Omitting the type argument is not allowed in the current context + // Test(this.f<>); + Diagnostic(ErrorCode.ERR_OmittedTypeArgument, "this.f<>").WithLocation(23, 14), // (23,19): error CS0307: The field 'Program.f' cannot be used with type arguments - Diagnostic(ErrorCode.ERR_TypeArgsNotAllowed, "f<>").WithArguments("Program.f", "field"), + // Test(this.f<>); + Diagnostic(ErrorCode.ERR_TypeArgsNotAllowed, "f<>").WithArguments("Program.f", "field").WithLocation(23, 19), + // (24,14): error CS8389: Omitting the type argument is not allowed in the current context + // Test(this.P<>); + Diagnostic(ErrorCode.ERR_OmittedTypeArgument, "this.P<>").WithLocation(24, 14), // (24,19): error CS0307: The property 'Program.P' cannot be used with type arguments - Diagnostic(ErrorCode.ERR_TypeArgsNotAllowed, "P<>").WithArguments("Program.P", "property"), + // Test(this.P<>); + Diagnostic(ErrorCode.ERR_TypeArgsNotAllowed, "P<>").WithArguments("Program.P", "property").WithLocation(24, 19), + // (25,14): error CS8389: Omitting the type argument is not allowed in the current context + // Test(this.M<>()); + Diagnostic(ErrorCode.ERR_OmittedTypeArgument, "this.M<>").WithLocation(25, 14), // (25,19): error CS0308: The non-generic method 'Program.M()' cannot be used with type arguments - Diagnostic(ErrorCode.ERR_HasNoTypeVars, "M<>").WithArguments("Program.M()", "method"), + // Test(this.M<>()); + Diagnostic(ErrorCode.ERR_HasNoTypeVars, "M<>").WithArguments("Program.M()", "method").WithLocation(25, 19), // (29,13): error CS0308: The non-generic method 'Program.M()' cannot be used with type arguments - Diagnostic(ErrorCode.ERR_HasNoTypeVars, "M<>").WithArguments("Program.M()", "method"), + // m = M<>; + Diagnostic(ErrorCode.ERR_HasNoTypeVars, "M<>").WithArguments("Program.M()", "method").WithLocation(29, 13), + // (30,13): error CS8389: Omitting the type argument is not allowed in the current context + // m = this.M<>; + Diagnostic(ErrorCode.ERR_OmittedTypeArgument, "this.M<>").WithLocation(30, 13), // (30,18): error CS0308: The non-generic method 'Program.M()' cannot be used with type arguments - Diagnostic(ErrorCode.ERR_HasNoTypeVars, "M<>").WithArguments("Program.M()", "method"), + // m = this.M<>; + Diagnostic(ErrorCode.ERR_HasNoTypeVars, "M<>").WithArguments("Program.M()", "method").WithLocation(30, 18), // (32,9): error CS0308: The non-generic type 'Program.I' cannot be used with type arguments - Diagnostic(ErrorCode.ERR_HasNoTypeVars, "I<>").WithArguments("Program.I", "type"), + // I<> i1 = null; + Diagnostic(ErrorCode.ERR_HasNoTypeVars, "I<>").WithArguments("Program.I", "type").WithLocation(32, 9), // (33,9): error CS0308: The non-generic type 'Program.C' cannot be used with type arguments - Diagnostic(ErrorCode.ERR_HasNoTypeVars, "C<>").WithArguments("Program.C", "type"), + // C<> c1 = new C(); + Diagnostic(ErrorCode.ERR_HasNoTypeVars, "C<>").WithArguments("Program.C", "type").WithLocation(33, 9), // (34,20): error CS0308: The non-generic type 'Program.C' cannot be used with type arguments - Diagnostic(ErrorCode.ERR_HasNoTypeVars, "C<>").WithArguments("Program.C", "type"), + // C c2 = new C<>(); + Diagnostic(ErrorCode.ERR_HasNoTypeVars, "C<>").WithArguments("Program.C", "type").WithLocation(34, 20), // (35,9): error CS0308: The non-generic type 'Program.S' cannot be used with type arguments - Diagnostic(ErrorCode.ERR_HasNoTypeVars, "S<>").WithArguments("Program.S", "type"), + // S<> s1 = new S(); + Diagnostic(ErrorCode.ERR_HasNoTypeVars, "S<>").WithArguments("Program.S", "type").WithLocation(35, 9), // (36,20): error CS0308: The non-generic type 'Program.S' cannot be used with type arguments - Diagnostic(ErrorCode.ERR_HasNoTypeVars, "S<>").WithArguments("Program.S", "type"), + // S s2 = new S<>(); + Diagnostic(ErrorCode.ERR_HasNoTypeVars, "S<>").WithArguments("Program.S", "type").WithLocation(36, 20), // (37,9): error CS0308: The non-generic type 'Program.D' cannot be used with type arguments - Diagnostic(ErrorCode.ERR_HasNoTypeVars, "D<>").WithArguments("Program.D", "type"), + // D<> d1 = null; + Diagnostic(ErrorCode.ERR_HasNoTypeVars, "D<>").WithArguments("Program.D", "type").WithLocation(37, 9), // (39,17): error CS0308: The non-generic type 'Program.I' cannot be used with type arguments - Diagnostic(ErrorCode.ERR_HasNoTypeVars, "I<>").WithArguments("Program.I", "type"), + // Program.I<> i2 = null; + Diagnostic(ErrorCode.ERR_HasNoTypeVars, "I<>").WithArguments("Program.I", "type").WithLocation(39, 17), // (40,17): error CS0308: The non-generic type 'Program.C' cannot be used with type arguments - Diagnostic(ErrorCode.ERR_HasNoTypeVars, "C<>").WithArguments("Program.C", "type"), + // Program.C<> c3 = new Program.C(); + Diagnostic(ErrorCode.ERR_HasNoTypeVars, "C<>").WithArguments("Program.C", "type").WithLocation(40, 17), // (41,36): error CS0308: The non-generic type 'Program.C' cannot be used with type arguments - Diagnostic(ErrorCode.ERR_HasNoTypeVars, "C<>").WithArguments("Program.C", "type"), + // Program.C c4 = new Program.C<>(); + Diagnostic(ErrorCode.ERR_HasNoTypeVars, "C<>").WithArguments("Program.C", "type").WithLocation(41, 36), // (42,17): error CS0308: The non-generic type 'Program.S' cannot be used with type arguments - Diagnostic(ErrorCode.ERR_HasNoTypeVars, "S<>").WithArguments("Program.S", "type"), + // Program.S<> s3 = new Program.S(); + Diagnostic(ErrorCode.ERR_HasNoTypeVars, "S<>").WithArguments("Program.S", "type").WithLocation(42, 17), // (43,36): error CS0308: The non-generic type 'Program.S' cannot be used with type arguments - Diagnostic(ErrorCode.ERR_HasNoTypeVars, "S<>").WithArguments("Program.S", "type"), + // Program.S s4 = new Program.S<>(); + Diagnostic(ErrorCode.ERR_HasNoTypeVars, "S<>").WithArguments("Program.S", "type").WithLocation(43, 36), // (44,17): error CS0308: The non-generic type 'Program.D' cannot be used with type arguments - Diagnostic(ErrorCode.ERR_HasNoTypeVars, "D<>").WithArguments("Program.D", "type"), + // Program.D<> d2 = null; + Diagnostic(ErrorCode.ERR_HasNoTypeVars, "D<>").WithArguments("Program.D", "type").WithLocation(44, 17), // (46,22): error CS0308: The non-generic type 'Program.I' cannot be used with type arguments - Diagnostic(ErrorCode.ERR_HasNoTypeVars, "I<>").WithArguments("Program.I", "type"), + // Test(default(I<>)); + Diagnostic(ErrorCode.ERR_HasNoTypeVars, "I<>").WithArguments("Program.I", "type").WithLocation(46, 22), // (47,22): error CS0308: The non-generic type 'Program.C' cannot be used with type arguments - Diagnostic(ErrorCode.ERR_HasNoTypeVars, "C<>").WithArguments("Program.C", "type"), + // Test(default(C<>)); + Diagnostic(ErrorCode.ERR_HasNoTypeVars, "C<>").WithArguments("Program.C", "type").WithLocation(47, 22), // (48,22): error CS0308: The non-generic type 'Program.S' cannot be used with type arguments - Diagnostic(ErrorCode.ERR_HasNoTypeVars, "S<>").WithArguments("Program.S", "type"), + // Test(default(S<>)); + Diagnostic(ErrorCode.ERR_HasNoTypeVars, "S<>").WithArguments("Program.S", "type").WithLocation(48, 22), // (50,30): error CS0308: The non-generic type 'Program.I' cannot be used with type arguments - Diagnostic(ErrorCode.ERR_HasNoTypeVars, "I<>").WithArguments("Program.I", "type"), + // Test(default(Program.I<>)); + Diagnostic(ErrorCode.ERR_HasNoTypeVars, "I<>").WithArguments("Program.I", "type").WithLocation(50, 30), // (51,30): error CS0308: The non-generic type 'Program.C' cannot be used with type arguments - Diagnostic(ErrorCode.ERR_HasNoTypeVars, "C<>").WithArguments("Program.C", "type"), + // Test(default(Program.C<>)); + Diagnostic(ErrorCode.ERR_HasNoTypeVars, "C<>").WithArguments("Program.C", "type").WithLocation(51, 30), // (52,30): error CS0308: The non-generic type 'Program.S' cannot be used with type arguments - Diagnostic(ErrorCode.ERR_HasNoTypeVars, "S<>").WithArguments("Program.S", "type"), + // Test(default(Program.S<>)); + Diagnostic(ErrorCode.ERR_HasNoTypeVars, "S<>").WithArguments("Program.S", "type").WithLocation(52, 30), // (56,20): error CS0308: The non-generic type 'Program.I' cannot be used with type arguments - Diagnostic(ErrorCode.ERR_HasNoTypeVars, "I<>").WithArguments("Program.I", "type"), + // s = typeof(I<>).Name; + Diagnostic(ErrorCode.ERR_HasNoTypeVars, "I<>").WithArguments("Program.I", "type").WithLocation(56, 20), // (57,20): error CS0308: The non-generic type 'Program.C' cannot be used with type arguments - Diagnostic(ErrorCode.ERR_HasNoTypeVars, "C<>").WithArguments("Program.C", "type"), + // s = typeof(C<>).Name; + Diagnostic(ErrorCode.ERR_HasNoTypeVars, "C<>").WithArguments("Program.C", "type").WithLocation(57, 20), // (58,20): error CS0308: The non-generic type 'Program.S' cannot be used with type arguments - Diagnostic(ErrorCode.ERR_HasNoTypeVars, "S<>").WithArguments("Program.S", "type"), + // s = typeof(S<>).Name; + Diagnostic(ErrorCode.ERR_HasNoTypeVars, "S<>").WithArguments("Program.S", "type").WithLocation(58, 20), // (60,28): error CS0308: The non-generic type 'Program.I' cannot be used with type arguments - Diagnostic(ErrorCode.ERR_HasNoTypeVars, "I<>").WithArguments("Program.I", "type"), + // s = typeof(Program.I<>).Name; + Diagnostic(ErrorCode.ERR_HasNoTypeVars, "I<>").WithArguments("Program.I", "type").WithLocation(60, 28), // (61,28): error CS0308: The non-generic type 'Program.C' cannot be used with type arguments - Diagnostic(ErrorCode.ERR_HasNoTypeVars, "C<>").WithArguments("Program.C", "type"), + // s = typeof(Program.C<>).Name; + Diagnostic(ErrorCode.ERR_HasNoTypeVars, "C<>").WithArguments("Program.C", "type").WithLocation(61, 28), // (62,28): error CS0308: The non-generic type 'Program.S' cannot be used with type arguments - Diagnostic(ErrorCode.ERR_HasNoTypeVars, "S<>").WithArguments("Program.S", "type"), + // s = typeof(Program.S<>).Name; + Diagnostic(ErrorCode.ERR_HasNoTypeVars, "S<>").WithArguments("Program.S", "type").WithLocation(62, 28), // (4,9): warning CS0649: Field 'Program.f' is never assigned to, and will always have its default value 0 - Diagnostic(ErrorCode.WRN_UnassignedInternalField, "f").WithArguments("Program.f", "0") - ); + // int f; + Diagnostic(ErrorCode.WRN_UnassignedInternalField, "f").WithArguments("Program.f", "0").WithLocation(4, 9) + ); } [WorkItem(542419, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/542419")] @@ -22898,32 +22945,47 @@ void Test(T p) // Parser // (12,11): error CS1525: Invalid expression term '>' - Diagnostic(ErrorCode.ERR_InvalidExprTerm, ">").WithArguments(">"), + // E<> += null; //parse error + Diagnostic(ErrorCode.ERR_InvalidExprTerm, ">").WithArguments(">").WithLocation(12, 11), // (12,13): error CS1525: Invalid expression term '+=' - Diagnostic(ErrorCode.ERR_InvalidExprTerm, "+=").WithArguments("+="), + // E<> += null; //parse error + Diagnostic(ErrorCode.ERR_InvalidExprTerm, "+=").WithArguments("+=").WithLocation(12, 13), // (13,11): error CS1525: Invalid expression term '>' - Diagnostic(ErrorCode.ERR_InvalidExprTerm, ">").WithArguments(">"), + // F<> += null; //parse error + Diagnostic(ErrorCode.ERR_InvalidExprTerm, ">").WithArguments(">").WithLocation(13, 11), // (13,13): error CS1525: Invalid expression term '+=' - Diagnostic(ErrorCode.ERR_InvalidExprTerm, "+=").WithArguments("+="), + // F<> += null; //parse error + Diagnostic(ErrorCode.ERR_InvalidExprTerm, "+=").WithArguments("+=").WithLocation(13, 13), // (15,16): error CS1525: Invalid expression term '>' - Diagnostic(ErrorCode.ERR_InvalidExprTerm, ">").WithArguments(">"), + // this.E<> += null; //parse error + Diagnostic(ErrorCode.ERR_InvalidExprTerm, ">").WithArguments(">").WithLocation(15, 16), // (15,18): error CS1525: Invalid expression term '+=' - Diagnostic(ErrorCode.ERR_InvalidExprTerm, "+=").WithArguments("+="), + // this.E<> += null; //parse error + Diagnostic(ErrorCode.ERR_InvalidExprTerm, "+=").WithArguments("+=").WithLocation(15, 18), // (16,16): error CS1525: Invalid expression term '>' - Diagnostic(ErrorCode.ERR_InvalidExprTerm, ">").WithArguments(">"), + // this.F<> += null; //parse error + Diagnostic(ErrorCode.ERR_InvalidExprTerm, ">").WithArguments(">").WithLocation(16, 16), + // (16,18): error CS1525: Invalid expression term '+=' + // this.F<> += null; //parse error + Diagnostic(ErrorCode.ERR_InvalidExprTerm, "+=").WithArguments("+=").WithLocation(16, 18), // Binder - // (16,18): error CS1525: Invalid expression term '+=' - Diagnostic(ErrorCode.ERR_InvalidExprTerm, "+=").WithArguments("+="), // (9,14): error CS0307: The event 'Program.E' cannot be used with type arguments - Diagnostic(ErrorCode.ERR_TypeArgsNotAllowed, "E<>").WithArguments("Program.E", "event"), + // Test(E<>); + Diagnostic(ErrorCode.ERR_TypeArgsNotAllowed, "E<>").WithArguments("Program.E", "event").WithLocation(9, 14), + // (10,14): error CS8389: Omitting the type argument is not allowed in the current context + // Test(this.E<>); + Diagnostic(ErrorCode.ERR_OmittedTypeArgument, "this.E<>").WithLocation(10, 14), // (10,19): error CS0307: The event 'Program.E' cannot be used with type arguments - Diagnostic(ErrorCode.ERR_TypeArgsNotAllowed, "E<>").WithArguments("Program.E", "event"), + // Test(this.E<>); + Diagnostic(ErrorCode.ERR_TypeArgsNotAllowed, "E<>").WithArguments("Program.E", "event").WithLocation(10, 19), // (13,9): error CS0079: The event 'Program.F' can only appear on the left hand side of += or -= - Diagnostic(ErrorCode.ERR_BadEventUsageNoField, "F").WithArguments("Program.F"), + // F<> += null; //parse error + Diagnostic(ErrorCode.ERR_BadEventUsageNoField, "F").WithArguments("Program.F").WithLocation(13, 9), // (16,14): error CS0079: The event 'Program.F' can only appear on the left hand side of += or -= - Diagnostic(ErrorCode.ERR_BadEventUsageNoField, "F").WithArguments("Program.F")); + // this.F<> += null; //parse error + Diagnostic(ErrorCode.ERR_BadEventUsageNoField, "F").WithArguments("Program.F").WithLocation(16, 14)); } [WorkItem(542419, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/542419")] diff --git a/src/Compilers/CSharp/Test/Symbol/Symbols/GenericConstraintTests.cs b/src/Compilers/CSharp/Test/Symbol/Symbols/GenericConstraintTests.cs index b2d2f85c503d8..aa83369014805 100644 --- a/src/Compilers/CSharp/Test/Symbol/Symbols/GenericConstraintTests.cs +++ b/src/Compilers/CSharp/Test/Symbol/Symbols/GenericConstraintTests.cs @@ -6862,5 +6862,259 @@ static void Main(string[] args) Diagnostic(ErrorCode.ERR_BadTypeArgument, "R2").WithArguments("int*").WithLocation(6, 7) ); } + + [Fact] + [WorkItem(41779, "https://github.com/dotnet/roslyn/issues/41779")] + public void Bug41779_Original() + { + var source = +@"interface I +{ + object GetService(); +} + +static class Program +{ + static T GetService(this I obj) => default; + + static void M(I provider) + { + provider.GetService<>(); + provider.GetService<>().ToString(); + provider.GetService<>(); + } +}"; + CreateCompilation(source).VerifyDiagnostics( + // (12,9): error CS8389: Omitting the type argument is not allowed in the current context + // provider.GetService<>(); + Diagnostic(ErrorCode.ERR_OmittedTypeArgument, "provider.GetService<>").WithLocation(12, 9), + // (13,9): error CS8389: Omitting the type argument is not allowed in the current context + // provider.GetService<>().ToString(); + Diagnostic(ErrorCode.ERR_OmittedTypeArgument, "provider.GetService<>").WithLocation(13, 9), + // (14,9): error CS8389: Omitting the type argument is not allowed in the current context + // provider.GetService<>(); + Diagnostic(ErrorCode.ERR_OmittedTypeArgument, "provider.GetService<>").WithLocation(14, 9) + ); + } + + [Fact] + [WorkItem(41779, "https://github.com/dotnet/roslyn/issues/41779")] + public void Bug41779_DoubleTypeArg() + { + var source = +@"interface I +{ + object GetService(); +} + +static class Program +{ + static T1 GetService(this I obj) => default; + + static void M(I provider) + { + provider.GetService<>(); + provider.GetService<>().ToString(); + provider.GetService<>(); + } +}"; + CreateCompilation(source).VerifyDiagnostics( + // (12,9): error CS8389: Omitting the type argument is not allowed in the current context + // provider.GetService<>(); + Diagnostic(ErrorCode.ERR_OmittedTypeArgument, "provider.GetService<>").WithLocation(12, 9), + // (12,18): error CS0308: The non-generic method 'I.GetService()' cannot be used with type arguments + // provider.GetService<>(); + Diagnostic(ErrorCode.ERR_HasNoTypeVars, "GetService<>").WithArguments("I.GetService()", "method").WithLocation(12, 18), + // (13,9): error CS8389: Omitting the type argument is not allowed in the current context + // provider.GetService<>().ToString(); + Diagnostic(ErrorCode.ERR_OmittedTypeArgument, "provider.GetService<>").WithLocation(13, 9), + // (13,18): error CS0308: The non-generic method 'I.GetService()' cannot be used with type arguments + // provider.GetService<>().ToString(); + Diagnostic(ErrorCode.ERR_HasNoTypeVars, "GetService<>").WithArguments("I.GetService()", "method").WithLocation(13, 18), + // (14,9): error CS8389: Omitting the type argument is not allowed in the current context + // provider.GetService<>(); + Diagnostic(ErrorCode.ERR_OmittedTypeArgument, "provider.GetService<>").WithLocation(14, 9), + // (14,18): error CS0308: The non-generic method 'I.GetService()' cannot be used with type arguments + // provider.GetService<>(); + Diagnostic(ErrorCode.ERR_HasNoTypeVars, "GetService<>").WithArguments("I.GetService()", "method").WithLocation(14, 18) + ); + } + + [Fact] + [WorkItem(41779, "https://github.com/dotnet/roslyn/issues/41779")] + public void Bug41779_Instance() + { + var source = +@"interface I +{ + object GetService(); +} + +interface J +{ + object GetService(); +} + +interface K +{ + object GetService(); +} + +static class Program +{ + static void M(I provider) + { + provider.GetService<>(); + provider.GetService<>().ToString(); + } + + static void M(J provider) + { + provider.GetService<>(); + provider.GetService<>().ToString(); + } + + static void M(K provider) + { + provider.GetService<>(); + provider.GetService<>().ToString(); + } +}"; + CreateCompilation(source).VerifyDiagnostics( + // (20,9): error CS8389: Omitting the type argument is not allowed in the current context + // provider.GetService<>(); + Diagnostic(ErrorCode.ERR_OmittedTypeArgument, "provider.GetService<>").WithLocation(20, 9), + // (20,18): error CS0308: The non-generic method 'I.GetService()' cannot be used with type arguments + // provider.GetService<>(); + Diagnostic(ErrorCode.ERR_HasNoTypeVars, "GetService<>").WithArguments("I.GetService()", "method").WithLocation(20, 18), + // (21,9): error CS8389: Omitting the type argument is not allowed in the current context + // provider.GetService<>().ToString(); + Diagnostic(ErrorCode.ERR_OmittedTypeArgument, "provider.GetService<>").WithLocation(21, 9), + // (21,18): error CS0308: The non-generic method 'I.GetService()' cannot be used with type arguments + // provider.GetService<>().ToString(); + Diagnostic(ErrorCode.ERR_HasNoTypeVars, "GetService<>").WithArguments("I.GetService()", "method").WithLocation(21, 18), + // (26,9): error CS0305: Using the generic method group 'GetService' requires 1 type arguments + // provider.GetService<>(); + Diagnostic(ErrorCode.ERR_BadArity, "provider.GetService<>").WithArguments("GetService", "method group", "1").WithLocation(26, 9), + // (27,9): error CS0305: Using the generic method group 'GetService' requires 1 type arguments + // provider.GetService<>().ToString(); + Diagnostic(ErrorCode.ERR_BadArity, "provider.GetService<>").WithArguments("GetService", "method group", "1").WithLocation(27, 9), + // (32,9): error CS8389: Omitting the type argument is not allowed in the current context + // provider.GetService<>(); + Diagnostic(ErrorCode.ERR_OmittedTypeArgument, "provider.GetService<>").WithLocation(32, 9), + // (32,18): error CS0305: Using the generic method 'K.GetService()' requires 2 type arguments + // provider.GetService<>(); + Diagnostic(ErrorCode.ERR_BadArity, "GetService<>").WithArguments("K.GetService()", "method", "2").WithLocation(32, 18), + // (33,9): error CS8389: Omitting the type argument is not allowed in the current context + // provider.GetService<>().ToString(); + Diagnostic(ErrorCode.ERR_OmittedTypeArgument, "provider.GetService<>").WithLocation(33, 9), + // (33,18): error CS0305: Using the generic method 'K.GetService()' requires 2 type arguments + // provider.GetService<>().ToString(); + Diagnostic(ErrorCode.ERR_BadArity, "GetService<>").WithArguments("K.GetService()", "method", "2").WithLocation(33, 18) + ); + } + + + [Fact] + [WorkItem(41779, "https://github.com/dotnet/roslyn/issues/41779")] + public void Bug41779_Extension() + { + var source = +@"interface I{} + +static class Program +{ + static void GetServiceA(this I obj){} + static T GetServiceB(this I obj) => default; + static T1 GetServiceC(this I obj) => default; + + static void M(I provider) + { + provider.GetServiceA<>(); + provider.GetServiceA<>().ToString(); + + provider.GetServiceB<>(); + provider.GetServiceB<>().ToString(); + + provider.GetServiceC<>(); + provider.GetServiceC<>().ToString(); + } +}"; + CreateCompilation(source).VerifyDiagnostics( + // (11,9): error CS8389: Omitting the type argument is not allowed in the current context + // provider.GetServiceA<>(); + Diagnostic(ErrorCode.ERR_OmittedTypeArgument, "provider.GetServiceA<>").WithLocation(11, 9), + // (11,18): error CS1061: 'I' does not contain a definition for 'GetServiceA' and no accessible extension method 'GetServiceA' accepting a first argument of type 'I' could be found (are you missing a using directive or an assembly reference?) + // provider.GetServiceA<>(); + Diagnostic(ErrorCode.ERR_NoSuchMemberOrExtension, "GetServiceA<>").WithArguments("I", "GetServiceA").WithLocation(11, 18), + // (12,9): error CS8389: Omitting the type argument is not allowed in the current context + // provider.GetServiceA<>().ToString(); + Diagnostic(ErrorCode.ERR_OmittedTypeArgument, "provider.GetServiceA<>").WithLocation(12, 9), + // (12,18): error CS1061: 'I' does not contain a definition for 'GetServiceA' and no accessible extension method 'GetServiceA' accepting a first argument of type 'I' could be found (are you missing a using directive or an assembly reference?) + // provider.GetServiceA<>().ToString(); + Diagnostic(ErrorCode.ERR_NoSuchMemberOrExtension, "GetServiceA<>").WithArguments("I", "GetServiceA").WithLocation(12, 18), + // (14,9): error CS8389: Omitting the type argument is not allowed in the current context + // provider.GetServiceB<>(); + Diagnostic(ErrorCode.ERR_OmittedTypeArgument, "provider.GetServiceB<>").WithLocation(14, 9), + // (15,9): error CS8389: Omitting the type argument is not allowed in the current context + // provider.GetServiceB<>().ToString(); + Diagnostic(ErrorCode.ERR_OmittedTypeArgument, "provider.GetServiceB<>").WithLocation(15, 9), + // (17,9): error CS8389: Omitting the type argument is not allowed in the current context + // provider.GetServiceC<>(); + Diagnostic(ErrorCode.ERR_OmittedTypeArgument, "provider.GetServiceC<>").WithLocation(17, 9), + // (17,18): error CS1061: 'I' does not contain a definition for 'GetServiceC' and no accessible extension method 'GetServiceC' accepting a first argument of type 'I' could be found (are you missing a using directive or an assembly reference?) + // provider.GetServiceC<>(); + Diagnostic(ErrorCode.ERR_NoSuchMemberOrExtension, "GetServiceC<>").WithArguments("I", "GetServiceC").WithLocation(17, 18), + // (18,9): error CS8389: Omitting the type argument is not allowed in the current context + // provider.GetServiceC<>().ToString(); + Diagnostic(ErrorCode.ERR_OmittedTypeArgument, "provider.GetServiceC<>").WithLocation(18, 9), + // (18,18): error CS1061: 'I' does not contain a definition for 'GetServiceC' and no accessible extension method 'GetServiceC' accepting a first argument of type 'I' could be found (are you missing a using directive or an assembly reference?) + // provider.GetServiceC<>().ToString(); + Diagnostic(ErrorCode.ERR_NoSuchMemberOrExtension, "GetServiceC<>").WithArguments("I", "GetServiceC").WithLocation(18, 18) + ); + } + + [Fact] + [WorkItem(41779, "https://github.com/dotnet/roslyn/issues/41779")] + public void Bug41779_Static() + { + var source = +@"static class Program +{ + static object GetServiceA(){ return null; } + static T GetServiceB() => default; + static T1 GetServiceC() => default; + + static void M() + { + GetServiceA<>(); + GetServiceA<>().ToString(); + GetServiceB<>(); + GetServiceB<>().ToString(); + GetServiceC<>(); + GetServiceC<>().ToString(); + } +}"; + CreateCompilation(source).VerifyDiagnostics( + // (9,9): error CS0308: The non-generic method 'Program.GetServiceA()' cannot be used with type arguments + // GetServiceA<>(); + Diagnostic(ErrorCode.ERR_HasNoTypeVars, "GetServiceA<>").WithArguments("Program.GetServiceA()", "method").WithLocation(9, 9), + // (10,9): error CS0308: The non-generic method 'Program.GetServiceA()' cannot be used with type arguments + // GetServiceA<>().ToString(); + Diagnostic(ErrorCode.ERR_HasNoTypeVars, "GetServiceA<>").WithArguments("Program.GetServiceA()", "method").WithLocation(10, 9), + // (11,9): error CS0305: Using the generic method group 'GetServiceB' requires 1 type arguments + // GetServiceB<>(); + Diagnostic(ErrorCode.ERR_BadArity, "GetServiceB<>").WithArguments("GetServiceB", "method group", "1").WithLocation(11, 9), + // (12,9): error CS0305: Using the generic method group 'GetServiceB' requires 1 type arguments + // GetServiceB<>().ToString(); + Diagnostic(ErrorCode.ERR_BadArity, "GetServiceB<>").WithArguments("GetServiceB", "method group", "1").WithLocation(12, 9), + // (13,9): error CS0305: Using the generic method 'Program.GetServiceC()' requires 2 type arguments + // GetServiceC<>(); + Diagnostic(ErrorCode.ERR_BadArity, "GetServiceC<>").WithArguments("Program.GetServiceC()", "method", "2").WithLocation(13, 9), + // (14,9): error CS0305: Using the generic method 'Program.GetServiceC()' requires 2 type arguments + // GetServiceC<>().ToString(); + Diagnostic(ErrorCode.ERR_BadArity, "GetServiceC<>").WithArguments("Program.GetServiceC()", "method", "2").WithLocation(14, 9) + ); + } } } diff --git a/src/Compilers/VisualBasic/Test/Symbol/SymbolsTests/UnboundGenericType.vb b/src/Compilers/VisualBasic/Test/Symbol/SymbolsTests/UnboundGenericType.vb index 7e1667093c2db..871a53255c9d3 100644 --- a/src/Compilers/VisualBasic/Test/Symbol/SymbolsTests/UnboundGenericType.vb +++ b/src/Compilers/VisualBasic/Test/Symbol/SymbolsTests/UnboundGenericType.vb @@ -289,6 +289,331 @@ End Class Assert.True(DirectCast(c3c6s, INamedTypeSymbol).IsSerializable) End Sub + + + Public Sub UnboundGenericType_Bug41779_Original() + + Dim compilation = CompilationUtils.CreateCompilation( + + + Private Function GetService(Of T)(ByVal obj As I) As T + Return "default" + End Function + + Private Sub M(ByVal provider As I) + provider.GetService(Of)() + provider.GetService(Of)().ToString() + provider.GetService(Of)() + End Sub +End Module + ]]> +) + + compilation.AssertTheseDiagnostics( +BC30311: Value of type 'String' cannot be converted to 'T'. + Return "default" + ~~~~~~~~~ +BC30182: Type expected. + provider.GetService(Of)() + ~ +BC30182: Type expected. + provider.GetService(Of)().ToString() + ~ +BC30182: Type expected. + provider.GetService(Of)() + ~ + ) + + End Sub + + + + Public Sub UnboundGenericType_Bug41779_DoubleArgs() + + Dim compilation = CompilationUtils.CreateCompilation( + + + Private Function GetService(Of T1, T2)(ByVal obj As I) As T1 + Return "default" + End Function + + Private Sub M(ByVal provider As I) + provider.GetService(Of)() + provider.GetService(Of)().ToString() + provider.GetService(Of)() + End Sub +End Module + ]]> +) + + compilation.AssertTheseDiagnostics( +BC30311: Value of type 'String' cannot be converted to 'T1'. + Return "default" + ~~~~~~~~~ +BC32087: Overload resolution failed because no accessible 'GetService' accepts this number of type arguments. + provider.GetService(Of)() + ~~~~~~~~~~~~~~ +BC30182: Type expected. + provider.GetService(Of)() + ~ +BC32087: Overload resolution failed because no accessible 'GetService' accepts this number of type arguments. + provider.GetService(Of)().ToString() + ~~~~~~~~~~~~~~ +BC30182: Type expected. + provider.GetService(Of)().ToString() + ~ +BC32087: Overload resolution failed because no accessible 'GetService' accepts this number of type arguments. + provider.GetService(Of)() + ~~~~~~~~~~~~~~ +BC30182: Type expected. + provider.GetService(Of)() + ~ + ) + + End Sub + + + + Public Sub UnboundGenericType_Bug41779_Instance() + + Dim compilation = CompilationUtils.CreateCompilation( + + +) + + compilation.AssertTheseDiagnostics( +BC32045: 'Function GetService() As Object' has no type parameters and so cannot have type arguments. + provider.GetService(Of)() + ~~~~ +BC30182: Type expected. + provider.GetService(Of)() + ~ +BC32045: 'Function GetService() As Object' has no type parameters and so cannot have type arguments. + provider.GetService(Of)().ToString() + ~~~~ +BC30182: Type expected. + provider.GetService(Of)().ToString() + ~ +BC30182: Type expected. + provider.GetService(Of)() + ~ +BC30182: Type expected. + provider.GetService(Of)().ToString() + ~ +BC32042: Too few type arguments to 'Function GetService(Of T1, T2)() As Object'. + provider.GetService(Of)() + ~~~~ +BC30182: Type expected. + provider.GetService(Of)() + ~ +BC32042: Too few type arguments to 'Function GetService(Of T1, T2)() As Object'. + provider.GetService(Of)().ToString() + ~~~~ +BC30182: Type expected. + provider.GetService(Of)().ToString() + ~ + ) + + End Sub + + + + Public Sub UnboundGenericType_Bug41779_Extension() + + Dim compilation = CompilationUtils.CreateCompilation( + + + Private Sub GetServiceA(ByVal obj As I) + End Sub + + + Private Function GetServiceB(Of T)(ByVal obj As I) As T + Return "default" + End Function + + + Private Function GetServiceC(Of T1, T2)(ByVal obj As I) As T1 + Return "default" + End Function + + Private Sub M(ByVal provider As I) + provider.GetServiceA(Of)() + provider.GetServiceA(Of)().ToString() + provider.GetServiceB(Of)() + provider.GetServiceB(Of)().ToString() + provider.GetServiceC(Of)() + provider.GetServiceC(Of)().ToString() + End Sub +End Module + ]]> +) + + compilation.AssertTheseDiagnostics( +BC30311: Value of type 'String' cannot be converted to 'T'. + Return "default" + ~~~~~~~~~ +BC30311: Value of type 'String' cannot be converted to 'T1'. + Return "default" + ~~~~~~~~~ +BC36907: Extension method 'Private Sub GetServiceA()' defined in 'Program' is not generic (or has no free type parameters) and so cannot have type arguments. + provider.GetServiceA(Of)() + ~~~~ +BC30182: Type expected. + provider.GetServiceA(Of)() + ~ +BC36907: Extension method 'Private Sub GetServiceA()' defined in 'Program' is not generic (or has no free type parameters) and so cannot have type arguments. + provider.GetServiceA(Of)().ToString() + ~~~~ +BC30182: Type expected. + provider.GetServiceA(Of)().ToString() + ~ +BC30182: Type expected. + provider.GetServiceB(Of)() + ~ +BC30182: Type expected. + provider.GetServiceB(Of)().ToString() + ~ +BC36590: Too few type arguments to extension method 'Private Function GetServiceC(Of T1, T2)() As T1' defined in 'Program'. + provider.GetServiceC(Of)() + ~~~~ +BC30182: Type expected. + provider.GetServiceC(Of)() + ~ +BC36590: Too few type arguments to extension method 'Private Function GetServiceC(Of T1, T2)() As T1' defined in 'Program'. + provider.GetServiceC(Of)().ToString() + ~~~~ +BC30182: Type expected. + provider.GetServiceC(Of)().ToString() + ~ + ) + + End Sub + + + + Public Sub UnboundGenericType_Bug41779_Function() + + Dim compilation = CompilationUtils.CreateCompilation( + + +) + + compilation.AssertTheseDiagnostics( +BC30311: Value of type 'String' cannot be converted to 'T'. + Return "default" + ~~~~~~~~~ +BC30311: Value of type 'String' cannot be converted to 'T1'. + Return "default" + ~~~~~~~~~ +BC32045: 'Private Function GetServiceA() As Object' has no type parameters and so cannot have type arguments. + GetServiceA(Of)() + ~~~~ +BC30182: Type expected. + GetServiceA(Of)() + ~ +BC32045: 'Private Function GetServiceA() As Object' has no type parameters and so cannot have type arguments. + GetServiceA(Of)().ToString() + ~~~~ +BC30182: Type expected. + GetServiceA(Of)().ToString() + ~ +BC30182: Type expected. + GetServiceB(Of)() + ~ +BC30182: Type expected. + GetServiceB(Of)().ToString() + ~ +BC32042: Too few type arguments to 'Private Function GetServiceC(Of T1, T2)() As T1'. + GetServiceC(Of)() + ~~~~ +BC30182: Type expected. + GetServiceC(Of)() + ~ +BC32042: Too few type arguments to 'Private Function GetServiceC(Of T1, T2)() As T1'. + GetServiceC(Of)().ToString() + ~~~~ +BC30182: Type expected. + GetServiceC(Of)().ToString() + ~ + ) + + End Sub + End Class End Namespace