LCOV - code coverage report
Current view: top level - vala - valatypeparameter.vala (source / functions) Coverage Total Hit
Test: vala 0.57.0.298-a8cae1 Lines: 75.0 % 20 15
Test Date: 2024-04-25 11:34:36 Functions: - 0 0

            Line data    Source code
       1              : /* valatypeparameter.vala
       2              :  *
       3              :  * Copyright (C) 2006-2009  Jürg Billeter
       4              :  *
       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.
       9              : 
      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.
      14              : 
      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
      18              :  *
      19              :  * Author:
      20              :  *      Jürg Billeter <j@bitron.ch>
      21              :  */
      22              : 
      23              : using GLib;
      24              : 
      25              : /**
      26              :  * Represents a generic type parameter in the source code.
      27              :  */
      28         1537 : public class Vala.TypeParameter : TypeSymbol {
      29              :         /**
      30              :          * Creates a new generic type parameter.
      31              :          *
      32              :          * @param name              parameter name
      33              :          * @param source_reference  reference to source code
      34              :          * @return                  newly created generic type parameter
      35              :          */
      36       391554 :         public TypeParameter (string name, SourceReference? source_reference = null) {
      37       130518 :                 base (name, source_reference);
      38       130518 :                 access = SymbolAccessibility.PUBLIC;
      39              :         }
      40              : 
      41       225731 :         public override void accept (CodeVisitor visitor) {
      42       225731 :                 visitor.visit_type_parameter (this);
      43              :         }
      44              : 
      45              :         /**
      46              :          * Checks two type parameters for equality.
      47              :          *
      48              :          * @param param2 a type parameter
      49              :          * @return      true if this type parameter is equal to param2, false
      50              :          *              otherwise
      51              :          */
      52          255 :         public bool equals (TypeParameter param2) {
      53              :                 /* only type parameters with a common scope are comparable */
      54          255 :                 if (!owner.is_subscope_of (param2.owner) && !param2.owner.is_subscope_of (owner)) {
      55            0 :                         Report.error (source_reference, "internal error: comparing type parameters from different scopes");
      56            0 :                         return false;
      57              :                 }
      58              : 
      59          255 :                 return name == param2.name && parent_symbol == param2.parent_symbol;
      60              :         }
      61              : 
      62       120961 :         public override bool check (CodeContext context) {
      63       120961 :                 if (checked) {
      64           19 :                         return !error;
      65              :                 }
      66              : 
      67       120942 :                 checked = true;
      68              : 
      69       120942 :                 if (!(parent_symbol is GenericSymbol)) {
      70            0 :                         Report.error (source_reference, "internal error: Incompatible parent_symbol");
      71            0 :                         error = true;
      72            0 :                         return false;
      73              :                 }
      74              : 
      75       120942 :                 return !error;
      76              :         }
      77              : }
        

Generated by: LCOV version 2.0-1