]>
Commit | Line | Data |
---|---|---|
1b2798f6 EK |
1 | /******************************************************************************* |
2 | * Copyright (c) 2000, 2011 IBM Corporation and others. | |
3 | * All rights reserved. This program and the accompanying materials | |
4 | * are made available under the terms of the Eclipse Public License v1.0 | |
5 | * which accompanies this distribution, and is available at | |
6 | * http://www.eclipse.org/legal/epl-v10.html | |
7 | * | |
8 | * Contributors: | |
9 | * IBM Corporation - initial API and implementation | |
10 | *******************************************************************************/ | |
11 | package org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types; | |
12 | ||
13 | public final class UnboundWildcardType extends WildcardType { | |
14 | ||
15 | protected UnboundWildcardType(TypeEnvironment environment) { | |
16 | super(environment); | |
17 | } | |
18 | ||
19 | @Override | |
20 | public int getKind() { | |
21 | return UNBOUND_WILDCARD_TYPE; | |
22 | } | |
23 | ||
24 | @Override | |
25 | public TType getErasure() { | |
26 | return getEnvironment().getJavaLangObject(); | |
27 | } | |
28 | ||
29 | @Override | |
30 | protected boolean doCanAssignTo(TType lhs) { | |
31 | switch(lhs.getKind()) { | |
32 | case STANDARD_TYPE: | |
33 | return ((StandardType)lhs).isJavaLangObject(); | |
34 | case UNBOUND_WILDCARD_TYPE: | |
35 | return true; | |
36 | case SUPER_WILDCARD_TYPE: | |
37 | case EXTENDS_WILDCARD_TYPE: | |
38 | return ((WildcardType)lhs).getBound().isJavaLangObject(); | |
39 | case CAPTURE_TYPE: | |
40 | return ((CaptureType)lhs).checkLowerBound(this); | |
41 | default: | |
42 | return false; | |
43 | } | |
44 | } | |
45 | ||
46 | @Override | |
47 | protected boolean checkTypeArgument(TType rhs) { | |
48 | switch(rhs.getKind()) { | |
49 | case ARRAY_TYPE: | |
50 | case STANDARD_TYPE: | |
51 | case PARAMETERIZED_TYPE: | |
52 | case RAW_TYPE: | |
53 | case UNBOUND_WILDCARD_TYPE: | |
54 | case EXTENDS_WILDCARD_TYPE: | |
55 | case SUPER_WILDCARD_TYPE: | |
56 | case TYPE_VARIABLE: | |
57 | case CAPTURE_TYPE: | |
58 | return true; | |
59 | default: | |
60 | return false; | |
61 | } | |
62 | } | |
63 | ||
64 | @Override | |
65 | protected boolean checkAssignmentBound(TType rhs) { | |
66 | // unbound equals ? extends Object. | |
67 | return rhs.isNullType(); | |
68 | } | |
69 | ||
70 | @Override | |
71 | public String getName() { | |
72 | return "?"; //$NON-NLS-1$ | |
73 | } | |
74 | ||
75 | @Override | |
76 | protected String getPlainPrettySignature() { | |
77 | return getName(); | |
78 | } | |
79 | } |