Version 2.15.0-232.0.dev

Merge commit '72cfca37aa15a4bbcbcb9dcff26431921182df59' into 'dev'
diff --git a/pkg/analyzer/lib/src/dart/error/ffi_code.g.dart b/pkg/analyzer/lib/src/dart/error/ffi_code.g.dart
index c2b7d56..4264f45 100644
--- a/pkg/analyzer/lib/src/dart/error/ffi_code.g.dart
+++ b/pkg/analyzer/lib/src/dart/error/ffi_code.g.dart
@@ -282,9 +282,9 @@
    */
   static const FfiCode NON_NATIVE_FUNCTION_TYPE_ARGUMENT_TO_POINTER = FfiCode(
     'NON_NATIVE_FUNCTION_TYPE_ARGUMENT_TO_POINTER',
-    "The type argument for the pointer '{0}' must be a 'NativeFunction' in order to use 'asFunction'.",
+    "The type argument for the pointer '{0}' must be a valid 'NativeFunction' in order to use 'asFunction'.",
     correctionMessage:
-        "Try changing the type argument to be a 'NativeFunction'.",
+        "Try changing the function argument in 'NativeFunction' to only use NativeTypes.",
   );
 
   /**
diff --git a/pkg/analyzer/lib/src/dart/resolver/ast_rewrite.dart b/pkg/analyzer/lib/src/dart/resolver/ast_rewrite.dart
index 875fa4b..25dfe1a 100644
--- a/pkg/analyzer/lib/src/dart/resolver/ast_rewrite.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/ast_rewrite.dart
@@ -383,7 +383,7 @@
       _errorReporter.reportErrorForNode(
           CompileTimeErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS_CONSTRUCTOR,
           typeArguments,
-          [classElement.name, constructorElement.name]);
+          [typeNameIdentifier.toString(), constructorIdentifier.name]);
     }
 
     var typeName = astFactory.namedType(
@@ -501,7 +501,7 @@
       _errorReporter.reportErrorForNode(
           CompileTimeErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS_CONSTRUCTOR,
           typeArguments,
-          [classElement.name, constructorElement.name]);
+          [typeIdentifier.name, constructorIdentifier.name]);
     }
     var typeName = astFactory.namedType(name: typeIdentifier);
     var constructorName = astFactory.constructorName(
diff --git a/pkg/analyzer/lib/src/generated/ffi_verifier.dart b/pkg/analyzer/lib/src/generated/ffi_verifier.dart
index df2a706..033f4c4 100644
--- a/pkg/analyzer/lib/src/generated/ffi_verifier.dart
+++ b/pkg/analyzer/lib/src/generated/ffi_verifier.dart
@@ -651,9 +651,16 @@
     var targetType = target.staticType;
     if (targetType is InterfaceType && targetType.isPointer) {
       final DartType T = targetType.typeArguments[0];
-      if (!T.isNativeFunction ||
-          !_isValidFfiNativeFunctionType(
-              (T as InterfaceType).typeArguments.single)) {
+      if (!T.isNativeFunction) {
+        return;
+      }
+      final DartType pointerTypeArg = (T as InterfaceType).typeArguments.single;
+      if (pointerTypeArg is TypeParameterType) {
+        _errorReporter.reportErrorForNode(
+            FfiCode.NON_CONSTANT_TYPE_ARGUMENT, target, ['asFunction']);
+        return;
+      }
+      if (!_isValidFfiNativeFunctionType(pointerTypeArg)) {
         final AstNode errorNode =
             typeArguments != null ? typeArguments[0] : node;
         _errorReporter.reportErrorForNode(
diff --git a/pkg/analyzer/messages.yaml b/pkg/analyzer/messages.yaml
index 079cc69..2f331e2 100644
--- a/pkg/analyzer/messages.yaml
+++ b/pkg/analyzer/messages.yaml
@@ -13887,8 +13887,8 @@
       Parameters:
       0: the name of the function, method, or constructor having type arguments
   NON_NATIVE_FUNCTION_TYPE_ARGUMENT_TO_POINTER:
-    problemMessage: "The type argument for the pointer '{0}' must be a 'NativeFunction' in order to use 'asFunction'."
-    correctionMessage: "Try changing the type argument to be a 'NativeFunction'."
+    problemMessage: "The type argument for the pointer '{0}' must be a valid 'NativeFunction' in order to use 'asFunction'."
+    correctionMessage: "Try changing the function argument in 'NativeFunction' to only use NativeTypes."
     comment: |-
       Parameters:
       0: the type that should be a valid dart:ffi native type.
diff --git a/pkg/analyzer/test/src/dart/resolution/ast_rewrite_test.dart b/pkg/analyzer/test/src/dart/resolution/ast_rewrite_test.dart
index cec815e..800bc3e 100644
--- a/pkg/analyzer/test/src/dart/resolution/ast_rewrite_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/ast_rewrite_test.dart
@@ -190,7 +190,7 @@
 ''', [
       error(CompileTimeErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS_CONSTRUCTOR, 50,
           5,
-          messageContains: "The constructor 'A.named'"),
+          messageContains: "The constructor 'prefix.A.named'"),
     ]);
 
     var importFind = findElement.importFind('package:test/a.dart');
@@ -229,7 +229,7 @@
 ''', [
       error(CompileTimeErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS_CONSTRUCTOR, 48,
           5,
-          messageContains: "The constructor 'A.'"),
+          messageContains: "The constructor 'prefix.A.new'"),
     ]);
 
     var importFind = findElement.importFind('package:test/a.dart');
@@ -382,7 +382,7 @@
 ''', [
       error(CompileTimeErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS_CONSTRUCTOR, 48,
           13,
-          messageContains: "The constructor 'A.'"),
+          messageContains: "The constructor 'A.new'"),
     ]);
 
     var creation = findNode.instanceCreation('new<int, String>(0);');
diff --git a/pkg/analyzer/test/src/diagnostics/non_native_function_type_argument_to_pointer_test.dart b/pkg/analyzer/test/src/diagnostics/non_native_function_type_argument_to_pointer_test.dart
index 323c81b..40cedd5 100644
--- a/pkg/analyzer/test/src/diagnostics/non_native_function_type_argument_to_pointer_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/non_native_function_type_argument_to_pointer_test.dart
@@ -58,7 +58,7 @@
   }
 }
 ''', [
-      error(FfiCode.NON_NATIVE_FUNCTION_TYPE_ARGUMENT_TO_POINTER, 138, 1),
+      error(FfiCode.NON_CONSTANT_TYPE_ARGUMENT, 125, 1),
     ]);
   }
 }
diff --git a/tools/VERSION b/tools/VERSION
index 5ea786d..c4e82d3 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
 MAJOR 2
 MINOR 15
 PATCH 0
-PRERELEASE 231
+PRERELEASE 232
 PRERELEASE_PATCH 0
\ No newline at end of file