Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

UnresolvedTypeVariableReferenceType.java 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /* *******************************************************************
  2. * Copyright (c) 2005-2010 Contributors
  3. * All rights reserved.
  4. * This program and the accompanying materials are made available
  5. * under the terms of the Eclipse Public License v 2.0
  6. * which accompanies this distribution and is available at
  7. * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt
  8. * ******************************************************************/
  9. package org.aspectj.weaver;
  10. /**
  11. * @author Adrian Colyer
  12. * @author Andy Clement
  13. */
  14. public class UnresolvedTypeVariableReferenceType extends UnresolvedType implements TypeVariableReference {
  15. private TypeVariable typeVariable;
  16. // constructor used as place-holder when dealing with circular refs such as Enum
  17. public UnresolvedTypeVariableReferenceType() {
  18. super("Ljava/lang/Object;");
  19. }
  20. public UnresolvedTypeVariableReferenceType(TypeVariable aTypeVariable) {
  21. super("T" + aTypeVariable.getName() + ";", aTypeVariable.getFirstBound().getErasureSignature());//aTypeVariable.getFirstBound().getSignature());
  22. this.typeVariable = aTypeVariable;
  23. }
  24. // only used when resolving circular refs...
  25. public void setTypeVariable(TypeVariable aTypeVariable) {
  26. this.signature = "T" + aTypeVariable.getName() + ";"; // aTypeVariable.getUpperBound().getSignature();
  27. this.signatureErasure = aTypeVariable.getFirstBound().getErasureSignature();
  28. this.typeVariable = aTypeVariable;
  29. this.typeKind = TypeKind.TYPE_VARIABLE;
  30. }
  31. @Override
  32. public ResolvedType resolve(World world) {
  33. TypeVariableDeclaringElement typeVariableScope = world.getTypeVariableLookupScope();
  34. TypeVariable resolvedTypeVariable = null;
  35. TypeVariableReferenceType tvrt = null;
  36. if (typeVariableScope == null) {
  37. // throw new BCException("There is no scope in which to lookup type variables!");
  38. // FIXME asc correct thing to do is go bang, but to limp along, lets cope with the scope missing
  39. resolvedTypeVariable = typeVariable.resolve(world);
  40. tvrt = new TypeVariableReferenceType(resolvedTypeVariable, world);
  41. } else {
  42. boolean foundOK = false;
  43. resolvedTypeVariable = typeVariableScope.getTypeVariableNamed(typeVariable.getName());
  44. // FIXME asc remove this when the shared type var stuff is sorted
  45. if (resolvedTypeVariable == null) {
  46. resolvedTypeVariable = typeVariable.resolve(world);
  47. } else {
  48. foundOK = true;
  49. }
  50. tvrt = new TypeVariableReferenceType(resolvedTypeVariable, world);
  51. }
  52. return tvrt;
  53. }
  54. @Override
  55. public boolean isTypeVariableReference() {
  56. return true;
  57. }
  58. public TypeVariable getTypeVariable() {
  59. return typeVariable;
  60. }
  61. @Override
  62. public String toString() {
  63. if (typeVariable == null) {
  64. return "<type variable not set!>";
  65. } else {
  66. return "T" + typeVariable.getName() + ";";
  67. }
  68. }
  69. @Override
  70. public String toDebugString() {
  71. return typeVariable.getName();
  72. }
  73. @Override
  74. public String getErasureSignature() {
  75. return typeVariable.getFirstBound().getSignature();
  76. }
  77. }