Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Commit

Permalink
fix bug inferring function ref type args when the type param has default
Browse files Browse the repository at this point in the history
results from an ambiguity as to the interpretation of type with no <>
yet another motivation for what is proposed in #3897
  • Loading branch information
gavinking committed May 12, 2015
1 parent aeeb931 commit bbf18d8
Showing 1 changed file with 25 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1551,13 +1551,15 @@ private ProducedType getRequiredSpecifiedType(

@Override public void visit(Tree.TypeParameterDeclaration that) {
super.visit(that);
TypeParameter tpd = that.getDeclarationModel();
ProducedType dta = tpd.getDefaultTypeArgument();
if (dta!=null) {
for (ProducedType st: tpd.getSatisfiedTypes()) {
checkAssignable(dta, st,
that.getTypeSpecifier().getType(),
"default type argument does not satisfy type constraint");
Tree.TypeSpecifier ts = that.getTypeSpecifier();
if (ts!=null) {
TypeParameter tpd = that.getDeclarationModel();
ProducedType dta = tpd.getDefaultTypeArgument();
if (dta!=null) {
for (ProducedType st: tpd.getSatisfiedTypes()) {
checkAssignable(dta, st, ts.getType(),
"default type argument does not satisfy type constraint");
}
}
}
}
Expand Down Expand Up @@ -2967,8 +2969,20 @@ private ProducedReference getProducedReference(
return ((TypeDeclaration) dec).getType();
}
else {
return dec.getProducedReference(qt,
Collections.<ProducedType>emptyList());
List<ProducedType> list;
if (dec instanceof Generic) {
list = new ArrayList<ProducedType>();
List<TypeParameter> tps =
((Generic) dec).getTypeParameters();
for (TypeParameter tp: tps) {
list.add(tp.getType());
}

}
else {
list = Collections.<ProducedType>emptyList();
}
return dec.getProducedReference(qt,list);
}
}

Expand Down Expand Up @@ -6709,7 +6723,8 @@ void visitExtendedTypePrimary(Tree.ExtendedTypeExpression that) {
Tree.Term p = that.getPrimary();
while (p instanceof Tree.Expression &&
p.getMainToken()==null) { //this hack allows actual parenthesized expressions through
p = ((Tree.Expression) p).getTerm();
Tree.Expression e = (Tree.Expression) p;
p = e.getTerm();
}
if (p instanceof Tree.MemberOrTypeExpression) {
Tree.MemberOrTypeExpression mte =
Expand Down

0 comments on commit bbf18d8

Please sign in to comment.