Skip to content
This repository
Browse code

Fix for ceylon/ceylon-compiler#712: find the proper refined decl in o…

…verloading cases
  • Loading branch information...
commit e4ead6064c7dbf7cccbcaae15f366673e297fe2d 1 parent d6b5bf7
Stéphane Épardaud authored October 12, 2012
2  src/com/redhat/ceylon/compiler/typechecker/analyzer/RefinementVisitor.java
@@ -284,7 +284,7 @@ private void validateRefinement(Tree.StatementOrArgument that, TypeDeclaration t
284 284
                     checkMember(that, dec);
285 285
                 }
286 286
                 ClassOrInterface declaringType = (ClassOrInterface) dec.getContainer();
287  
-                Declaration refined = declaringType.getRefinedMember(dec.getName(), null, false);
  287
+                Declaration refined = declaringType.getRefinedMember(dec.getName(), com.redhat.ceylon.compiler.typechecker.model.Util.getSignature(dec), false);
288 288
                 dec.setRefinedDeclaration(refined);
289 289
             }
290 290
 
15  src/com/redhat/ceylon/compiler/typechecker/model/Util.java
@@ -705,4 +705,19 @@ public static boolean isTypeUnknown(ProducedType type) {
705 705
                 type.getDeclaration() instanceof UnknownType;
706 706
     }
707 707
 
  708
+    public static List<ProducedType> getSignature(Declaration dec) {
  709
+        if(dec instanceof Functional == false)
  710
+            return null;
  711
+        List<ParameterList> parameterLists = ((Functional)dec).getParameterLists();
  712
+        if(parameterLists == null || parameterLists.isEmpty())
  713
+            return null;
  714
+        ParameterList parameterList = parameterLists.get(0);
  715
+        if(parameterList == null || parameterList.getParameters() == null)
  716
+            return null;
  717
+        ArrayList<ProducedType> signature = new ArrayList<ProducedType>(parameterList.getParameters().size());
  718
+        for(Parameter param : parameterList.getParameters()){
  719
+            signature.add(param.getType());
  720
+        }
  721
+        return signature;
  722
+    }
708 723
 }

3 notes on commit e4ead60

Gavin King
Owner

@FroMage This change seems to result in NPEs in the tests, due to a declaration (parameter broken in Parameters.ceylon) that does not have a type.

I'm not sure if your change is really to blame for this, perhaps it just exposed a pre-existing bug.

Gavin King
Owner

A quick fix:

9e19885

Stéphane Épardaud
Owner

Damn I was sure I ran the tests though...

Please sign in to comment.
Something went wrong with that request. Please try again.