Bug 387236 - [compiler] type mismatch in signature-less c-t-f with array
type causes NPE
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/ast/CalloutMappingDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/ast/CalloutMappingDeclaration.java
index b9e9de2..9c8c0e9 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/ast/CalloutMappingDeclaration.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/ast/CalloutMappingDeclaration.java
@@ -236,6 +236,11 @@
 					this.roleMethodSpec.returnType.resolvedType = requiredType; // keep going..
 					return; // warned
 				}
+				if (this.roleMethodSpec.returnType.resolvedType == null) {
+					// https://bugs.eclipse.org/387236
+					// if returnType was added late (above) and if type mismatch exists, we still need a resolved type here:
+					this.roleMethodSpec.returnType.resolve(this.scope);
+				}
 			}
 		} else { // 'set'
 			if (this.roleMethodSpec.resolvedMethod.returnType != TypeBinding.VOID) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/mappings/CalloutImplementor.java b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/mappings/CalloutImplementor.java
index fd70367..2b87176 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/mappings/CalloutImplementor.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/mappings/CalloutImplementor.java
@@ -418,7 +418,6 @@
 			// if this one is given, it might be instantiated:
 			returnType = calloutBindingDeclaration.roleMethodSpec.returnType.resolvedType;
 		else
-			// CLOVER: never reached in jacks suite
 			// this one should exist in any case:
 			returnType = calloutBindingDeclaration.roleMethodSpec.resolvedMethod.returnType;
 		MethodDeclaration newMethod = gen.method(
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/calloutbinding/CalloutToField.java b/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/calloutbinding/CalloutToField.java
index 6fb9846..42b446d 100644
--- a/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/calloutbinding/CalloutToField.java
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/calloutbinding/CalloutToField.java
@@ -3670,4 +3670,37 @@
     		},
     		"OK0");
     }
+    
+    // Bug 387236 - [compiler] type mismatch in signature-less c-t-f with array type causes NPE
+    public void testBug387236() {
+    	runNegativeTest(new String[] {
+    		"b/Base.java",
+    			"package b;\n" + 
+    			"\n" + 
+    			"public class Base {\n" + 
+    			"	Object[] values;\n" + 
+    			"}",
+    		"t/Team.java",
+	    		"package t;\n" + 
+	    		"\n" + 
+	    		"import base b.Base;\n" + 
+	    		"\n" + 
+	    		"public team class Team {\n" + 
+	    		"	protected abstract class AR {\n" + 
+	    		"		protected abstract String[] getValues();\n" + 
+	    		"	}\n" + 
+	    		"	protected class CR extends AR playedBy Base {\n" + 
+	    		"		@SuppressWarnings(\"decapsulation\") getValues -> get values;\n" + 
+	    		"		\n" + 
+	    		"	}\n" + 
+	    		"}\n"
+    		},
+    		"----------\n" + 
+			"1. ERROR in t\\Team.java (at line 10)\n" + 
+			"	@SuppressWarnings(\"decapsulation\") getValues -> get values;\n" + 
+			"	                                   ^^^^^^^^^\n" + 
+			"When binding field values via callout to role method getValues():\n" + 
+			"Incompatible types: can\'t convert java.lang.Object[] to java.lang.String[] (OTJLD 3.5(b)).\n" + 
+			"----------\n");
+    }
 }