67 import com.sun.tools.javac.code.Type.ArrayType; |
67 import com.sun.tools.javac.code.Type.ArrayType; |
68 import com.sun.tools.javac.code.Type.ClassType; |
68 import com.sun.tools.javac.code.Type.ClassType; |
69 import com.sun.tools.javac.code.Type.ErrorType; |
69 import com.sun.tools.javac.code.Type.ErrorType; |
70 import com.sun.tools.javac.code.Type.UnionClassType; |
70 import com.sun.tools.javac.code.Type.UnionClassType; |
71 import com.sun.tools.javac.code.Types; |
71 import com.sun.tools.javac.code.Types; |
72 import com.sun.tools.javac.code.TypeTag; |
|
73 import com.sun.tools.javac.code.Types.TypeRelation; |
72 import com.sun.tools.javac.code.Types.TypeRelation; |
74 import com.sun.tools.javac.comp.Attr; |
73 import com.sun.tools.javac.comp.Attr; |
75 import com.sun.tools.javac.comp.AttrContext; |
74 import com.sun.tools.javac.comp.AttrContext; |
76 import com.sun.tools.javac.comp.Enter; |
75 import com.sun.tools.javac.comp.Enter; |
77 import com.sun.tools.javac.comp.Env; |
76 import com.sun.tools.javac.comp.Env; |
356 Env<AttrContext> env = getAttrContext(path); |
355 Env<AttrContext> env = getAttrContext(path); |
357 |
356 |
358 Log.DeferredDiagnosticHandler deferredDiagnosticHandler = |
357 Log.DeferredDiagnosticHandler deferredDiagnosticHandler = |
359 new Log.DeferredDiagnosticHandler(log); |
358 new Log.DeferredDiagnosticHandler(log); |
360 try { |
359 try { |
361 final ClassSymbol tsym; |
360 final TypeSymbol tsym; |
362 final Name memberName; |
361 final Name memberName; |
363 if (ref.qualifierExpression == null) { |
362 if (ref.qualifierExpression == null) { |
364 tsym = env.enclClass.sym; |
363 tsym = env.enclClass.sym; |
365 memberName = ref.memberName; |
364 memberName = ref.memberName; |
366 } else { |
365 } else { |
406 lb.add(t); |
405 lb.add(t); |
407 } |
406 } |
408 paramTypes = lb.toList(); |
407 paramTypes = lb.toList(); |
409 } |
408 } |
410 |
409 |
411 Symbol msym = (memberName == tsym.name) |
410 ClassSymbol sym = (ClassSymbol) types.upperBound(tsym.type).tsym; |
412 ? findConstructor(tsym, paramTypes) |
411 |
413 : findMethod(tsym, memberName, paramTypes); |
412 Symbol msym = (memberName == sym.name) |
|
413 ? findConstructor(sym, paramTypes) |
|
414 : findMethod(sym, memberName, paramTypes); |
414 if (paramTypes != null) { |
415 if (paramTypes != null) { |
415 // explicit (possibly empty) arg list given, so cannot be a field |
416 // explicit (possibly empty) arg list given, so cannot be a field |
416 return msym; |
417 return msym; |
417 } |
418 } |
418 |
419 |
419 VarSymbol vsym = (ref.paramTypes != null) ? null : findField(tsym, memberName); |
420 VarSymbol vsym = (ref.paramTypes != null) ? null : findField(sym, memberName); |
420 // prefer a field over a method with no parameters |
421 // prefer a field over a method with no parameters |
421 if (vsym != null && |
422 if (vsym != null && |
422 (msym == null || |
423 (msym == null || |
423 types.isSubtypeUnchecked(vsym.enclClass().asType(), msym.enclClass().asType()))) { |
424 types.isSubtypeUnchecked(vsym.enclClass().asType(), msym.enclClass().asType()))) { |
424 return vsym; |
425 return vsym; |
787 env = enter.getClassEnv(((JCClassDecl)tree).sym); |
788 env = enter.getClassEnv(((JCClassDecl)tree).sym); |
788 break; |
789 break; |
789 case METHOD: |
790 case METHOD: |
790 // System.err.println("METHOD: " + ((JCMethodDecl)tree).sym.getSimpleName()); |
791 // System.err.println("METHOD: " + ((JCMethodDecl)tree).sym.getSimpleName()); |
791 method = (JCMethodDecl)tree; |
792 method = (JCMethodDecl)tree; |
|
793 env = memberEnter.getMethodEnv(method, env); |
792 break; |
794 break; |
793 case VARIABLE: |
795 case VARIABLE: |
794 // System.err.println("FIELD: " + ((JCVariableDecl)tree).sym.getSimpleName()); |
796 // System.err.println("FIELD: " + ((JCVariableDecl)tree).sym.getSimpleName()); |
795 field = (JCVariableDecl)tree; |
797 field = (JCVariableDecl)tree; |
796 break; |
798 break; |
798 // System.err.println("BLOCK: "); |
800 // System.err.println("BLOCK: "); |
799 if (method != null) { |
801 if (method != null) { |
800 try { |
802 try { |
801 Assert.check(method.body == tree); |
803 Assert.check(method.body == tree); |
802 method.body = copier.copy((JCBlock)tree, (JCTree) path.getLeaf()); |
804 method.body = copier.copy((JCBlock)tree, (JCTree) path.getLeaf()); |
803 env = memberEnter.getMethodEnv(method, env); |
|
804 env = attribStatToTree(method.body, env, copier.leafCopy); |
805 env = attribStatToTree(method.body, env, copier.leafCopy); |
805 } finally { |
806 } finally { |
806 method.body = (JCBlock) tree; |
807 method.body = (JCBlock) tree; |
807 } |
808 } |
808 } else { |
809 } else { |