1 /* valatypeparameter.vala
3 * Copyright (C) 2006-2009 Jürg Billeter
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 * Jürg Billeter <j@bitron.ch>
26 * Represents a generic type parameter in the source code.
28 public class Vala
.TypeParameter
: Symbol
{
30 * Creates a new generic type parameter.
32 * @param name parameter name
33 * @param source_reference reference to source code
34 * @return newly created generic type parameter
36 public TypeParameter (string name
, SourceReference source_reference
) {
37 base (name
, source_reference
);
40 public override void accept (CodeVisitor visitor
) {
41 visitor
.visit_type_parameter (this
);
45 * Checks two type parameters for equality.
47 * @param param2 a type parameter
48 * @return true if this type parameter is equal to param2, false
51 public bool equals (TypeParameter param2
) {
52 /* only type parameters with a common scope are comparable */
53 if (!owner
.is_subscope_of (param2
.owner
) && !param2
.owner
.is_subscope_of (owner
)) {
54 Report
.error (source_reference
, "internal error: comparing type parameters from different scopes");
58 return name
== param2
.name
&& parent_symbol
== param2
.parent_symbol
;