diff options
author | Stephan Herrmann | 2012-08-14 19:05:54 +0000 |
---|---|---|
committer | Stephan Herrmann | 2012-08-14 19:05:54 +0000 |
commit | 4de020060990f372c8abe9c88bac083a5d485ec6 (patch) | |
tree | 4f0dc631bfe3065a24a5f6f473cd5aeaaa44e627 | |
parent | c98d9e22c784c4fc73d2fbfde2fc51b730c6a9da (diff) | |
download | org.eclipse.objectteams-4de020060990f372c8abe9c88bac083a5d485ec6.tar.gz org.eclipse.objectteams-4de020060990f372c8abe9c88bac083a5d485ec6.tar.xz org.eclipse.objectteams-4de020060990f372c8abe9c88bac083a5d485ec6.zip |
Bug 387236 - [compiler] type mismatch in signature-less c-t-f with arrayreleases/OTDT_2.2M1builds/201208141515
type causes NPE
3 files changed, 38 insertions, 1 deletions
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 b9e9de2c9..9c8c0e976 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 @@ public class CalloutMappingDeclaration extends AbstractMethodMappingDeclaration 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 fd703674f..2b8717697 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 @@ public class CalloutImplementor extends MethodMappingImplementor // 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 6fb98469f..42b446d24 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 @@ public class CalloutToField extends AbstractOTJLDTest { }, "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"); + } } |