View | Details | Raw Unified | Return to bug 355313
Collapse All | Expand All

(-)compiler/org/eclipse/objectteams/otdt/internal/core/compiler/control/Dependencies.java (-2 / +15 lines)
Lines 29-34 Link Here
29
import org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration;
29
import org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration;
30
import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration;
30
import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration;
31
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
31
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
32
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
32
import org.eclipse.jdt.internal.compiler.env.AccessRestriction;
33
import org.eclipse.jdt.internal.compiler.env.AccessRestriction;
33
import org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding;
34
import org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding;
34
import org.eclipse.jdt.internal.compiler.lookup.Binding;
35
import org.eclipse.jdt.internal.compiler.lookup.Binding;
Lines 1653-1659 Link Here
1653
			resolver.resolve(false/*doCallout*/); // callins last so all methods incl. callout are already in place
1654
			resolver.resolve(false/*doCallout*/); // callins last so all methods incl. callout are already in place
1654
		
1655
		
1655
		if (subRoleDecl != null)
1656
		if (subRoleDecl != null)
1656
			checkMissingMethods(subRole, subRoleDecl.scope);
1657
			checkMissingMethods(subRole, subRoleDecl);
1657
1658
1658
        clazz.setState(STATE_METHODS_CREATED);
1659
        clazz.setState(STATE_METHODS_CREATED);
1659
        return true;
1660
        return true;
Lines 1777-1787 Link Here
1777
	}
1778
	}
1778
1779
1779
	// detail of STATE_METHODS_CREATED (can only check this after callouts have been transformed):
1780
	// detail of STATE_METHODS_CREATED (can only check this after callouts have been transformed):
1780
	private static void checkMissingMethods(ReferenceBinding roleBinding, ClassScope scope) {
1781
	private static void checkMissingMethods(ReferenceBinding roleBinding, TypeDeclaration roleDecl) {
1781
		if (roleBinding.isClass() && ((roleBinding.tagBits & TagBits.AnnotationInstantiation) != 0)) {
1782
		if (roleBinding.isClass() && ((roleBinding.tagBits & TagBits.AnnotationInstantiation) != 0)) {
1782
			InstantiationPolicy instantiationPolicy = RoleModel.getInstantiationPolicy(roleBinding);
1783
			InstantiationPolicy instantiationPolicy = RoleModel.getInstantiationPolicy(roleBinding);
1783
			if (!instantiationPolicy.isAlways())
1784
			if (!instantiationPolicy.isAlways())
1784
				return;
1785
				return;
1786
			ClassScope scope = roleDecl.scope;
1785
			boolean missing = false;
1787
			boolean missing = false;
1786
			MethodBinding equals = roleBinding.getExactMethod(TypeConstants.EQUALS, 
1788
			MethodBinding equals = roleBinding.getExactMethod(TypeConstants.EQUALS, 
1787
															  new TypeBinding[] {scope.getJavaLangObject()}, scope.compilationUnitScope());
1789
															  new TypeBinding[] {scope.getJavaLangObject()}, scope.compilationUnitScope());
Lines 1797-1802 Link Here
1797
				scope.problemReporter().missingEqualsHashCodeWithInstantation(scope.referenceContext, instantiationPolicy);
1799
				scope.problemReporter().missingEqualsHashCodeWithInstantation(scope.referenceContext, instantiationPolicy);
1798
			}
1800
			}
1799
		}
1801
		}
1802
		// copied abstract methods are not yet checked for callout inference (which is normally triggered from checkMethods()) 
1803
		if (roleBinding.isClass() && roleDecl.methods != null) {
1804
			for (AbstractMethodDeclaration method : roleDecl.methods) {
1805
				if (((method.modifiers & ClassFileConstants.AccAbstract) != 0) && method.isCopied) {
1806
		    		// inheriting abstract method in non-abstract role may require callout inference:
1807
					CalloutImplementor coi = new CalloutImplementor(roleDecl.getRoleModel());
1808
					if (coi.generateInferredCallout(roleDecl, method.binding))
1809
						roleDecl.scope.problemReporter().addingInferredCalloutForInherited(roleDecl, method.binding);
1810
				}
1811
			}
1812
		}
1800
	}
1813
	}
1801
1814
1802
	/* **** STATE_TYPES_ADJUSTED (OT/J) ****
1815
	/* **** STATE_TYPES_ADJUSTED (OT/J) ****
(-)otjld/org/eclipse/objectteams/otdt/tests/otjld/calloutbinding/CalloutMethodBinding.java (-8 / +109 lines)
Lines 436-442 Link Here
436
 			    "\n" +
436
 			    "\n" +
437
 			    "public class T311acb8Main {\n" +
437
 			    "public class T311acb8Main {\n" +
438
 			    "    public static void main(String[] args) {\n" +
438
 			    "    public static void main(String[] args) {\n" +
439
 			    "        Team311acb2 t = new Team311acb2();\n" +
439
 			    "        Team311acb8_2 t = new Team311acb8_2();\n" +
440
 			    "        T311acb8_1  o = new T311acb8_1();\n" +
440
 			    "        T311acb8_1  o = new T311acb8_1();\n" +
441
 			    "\n" +
441
 			    "\n" +
442
 			    "        System.out.print(t.getValue(o));\n" +
442
 			    "        System.out.print(t.getValue(o));\n" +
Lines 454-462 Link Here
454
 			    "    }\n" +
454
 			    "    }\n" +
455
 			    "}\n" +
455
 			    "}\n" +
456
 			    "    \n",
456
 			    "    \n",
457
	    "Team311acb2.java",
457
	    "Team311acb8_2.java",
458
 			    "\n" +
458
 			    "\n" +
459
 			    "public team class Team311acb2 extends Team311acb8 {\n" +
459
 			    "public team class Team311acb8_2 extends Team311acb8_1 {\n" +
460
 			    "    @Override\n" +
460
 			    "    @Override\n" +
461
 			    "    public class Role311acb8 playedBy T311acb8_1 {\n" +
461
 			    "    public class Role311acb8 playedBy T311acb8_1 {\n" +
462
 			    "        getValue -> getValue;\n" +
462
 			    "        getValue -> getValue;\n" +
Lines 466-474 Link Here
466
 			    "        return obj.getValueInternal();\n" +
466
 			    "        return obj.getValueInternal();\n" +
467
 			    "    }\n" +
467
 			    "    }\n" +
468
 			    "}\n",
468
 			    "}\n",
469
 		"Team311acb8.java",
469
 		"Team311acb8_1.java",
470
 			    "\n" +
470
 			    "\n" +
471
 			    "public abstract team class Team311acb8 {\n" +
471
 			    "public abstract team class Team311acb8_1 {\n" +
472
 			    "\n" +
472
 			    "\n" +
473
 			    "    public abstract class Role311acb8 {\n" +
473
 			    "    public abstract class Role311acb8 {\n" +
474
 			    "        public abstract String getValue();\n" +
474
 			    "        public abstract String getValue();\n" +
Lines 478-488 Link Here
478
 			    "}\n",
478
 			    "}\n",
479
             },
479
             },
480
            "----------\n" + 
480
            "----------\n" + 
481
			"1. ERROR in Team311acb2.java (at line 1)\n" + 
481
			"1. ERROR in Team311acb8_2.java (at line 4)\n" + 
482
			"	public class Role311acb8 playedBy T311acb8_1 {\n" + 
483
			"	             ^^^^^^^^^^^\n" + 
484
			"Inherited abstract method getValueInternal() is implicitly bound as an inferred callout (OTJLD 3.1(j)).\n" + 
485
			"----------\n");
486
     }
487
    // Bug 355314 - abstract method error may be masked by callout binding
488
    public void test311_abstractCalloutBinding8a() {
489
        
490
        runNegativeTest(
491
             new String[] {
492
 		"T311acb8aMain.java",
493
 			    "\n" +
494
 			    "public class T311acb8aMain {\n" +
495
 			    "    public static void main(String[] args) {\n" +
496
 			    "        Team311acb8a_2 t = new Team311acb8a_2();\n" +
497
 			    "        T311acb8a_1  o = new T311acb8a_1();\n" +
498
 			    "\n" +
499
 			    "        System.out.print(t.getValue(o));\n" +
500
 			    "    }\n" +
501
 			    "}\n" +
502
 			    "    \n",
503
 		"T311acb8a_1.java",
504
 			    "\n" +
505
 			    "public class T311acb8a_1 {\n" +
506
 			    "    public String getValue() {\n" +
507
 			    "        return \"OK\";\n" +
508
 			    "    }\n" +
509
 			    "}\n" +
510
 			    "    \n",
511
	    "Team311acb8a_2.java",
512
 			    "\n" +
513
 			    "public team class Team311acb8a_2 extends Team311acb8a_1 {\n" +
514
 			    "    @Override\n" +
515
 			    "    public class Role311acb8a playedBy T311acb8a_1 {\n" +
516
 			    "        getValue -> getValue;\n" +
517
 			    "    }\n" +
518
 			    "\n" +
519
 			    "    public String getValue(T311acb8a_1 as Role311acb8a obj) {\n" +
520
 			    "        return obj.getValueInternal();\n" +
521
 			    "    }\n" +
522
 			    "}\n",
523
 		"Team311acb8a_1.java",
524
 			    "\n" +
525
 			    "public abstract team class Team311acb8a_1 {\n" +
526
 			    "\n" +
527
 			    "    public abstract class Role311acb8a {\n" +
528
 			    "        public abstract String getValue();\n" +
529
 			    "        public abstract String getValueInternal();\n" +
530
 			    "    }\n" +
531
 			    "\n" +
532
 			    "}\n",
533
             },
534
            "----------\n" + 
535
			"1. ERROR in Team311acb8a_2.java (at line 1)\n" + 
482
			"	\n" + 
536
			"	\n" + 
483
			"public team class Team311acb2 extends Team311acb8 {\n" + 
537
			"public team class Team311acb8a_2 extends Team311acb8a_1 {\n" + 
484
			"	^\n" + 
538
			"	^\n" + 
485
			"The abstract method getValueInternal in type Role311acb8 can only be defined by an abstract class\n" + 
539
			"The abstract method getValueInternal in type Role311acb8a can only be defined by an abstract class\n" + 
486
			"----------\n");
540
			"----------\n");
487
     }
541
     }
488
542
Lines 2820-2825 Link Here
2820
            null/*no custom requestor*/);
2874
            null/*no custom requestor*/);
2821
    }
2875
    }
2822
2876
2877
    // Bug 355313 - inferred callout not working for implicitly inherited method
2878
    public void test3117_inferredCallout12() {
2879
       Map customOptions = getCompilerOptions();
2880
       customOptions.put(CompilerOptions.OPTION_ReportInferredCallout, CompilerOptions.WARNING);
2881
       
2882
       runConformTest(
2883
            new String[] {
2884
		"Team3117ic11_2.java",
2885
			    "\n" +
2886
			    "public team class Team3117ic11_2 extends Team3117ic11_1 {\n" +
2887
			    "    @Override\n" +
2888
			    "    @SuppressWarnings(\"inferredcallout\")\n" +
2889
			    "    protected class R playedBy T3117ic11 {\n" +
2890
			    "    }\n" +
2891
			    "    Team3117ic11_2() {\n" +
2892
			    "        new R(new T3117ic11()).test();\n" +
2893
			    "    }\n" +
2894
			    "    public static void main(String[] args) {\n" +
2895
			    "        new Team3117ic11_2();\n" +
2896
			    "    }\n" +
2897
			    "}\n" +
2898
			    "    \n",
2899
		"Team3117ic11_1.java",
2900
			    "\n" +
2901
			    "public abstract team class Team3117ic11_1 {\n" +
2902
			    "    protected abstract class R {\n" +
2903
			    "        abstract protected void test();\n" +
2904
			    "    }\n" +
2905
			    "}\n" +
2906
			    "    \n",
2907
		"T3117ic11.java",
2908
			    "\n" +
2909
			    "public class T3117ic11 {\n" +
2910
			    "    public void test() {\n" +
2911
			    "        System.out.print(\"OK\");\n" +
2912
			    "    }\n" +
2913
			    "}\n" +
2914
			    "    \n"
2915
            },
2916
            "OK",
2917
            null/*classLibraries*/,
2918
            true/*shouldFlushOutputDirectory*/,
2919
            null/*vmArguments*/,
2920
            customOptions,
2921
            null/*no custom requestor*/);
2922
    }
2923
2823
    // a short callout binding lacks a rhs
2924
    // a short callout binding lacks a rhs
2824
    // 3.1.18-otjld-incomplete-callout-binding-1
2925
    // 3.1.18-otjld-incomplete-callout-binding-1
2825
    public void test3118_incompleteCalloutBinding1() {
2926
    public void test3118_incompleteCalloutBinding1() {

Return to bug 355313