All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sonar.l10n.java.rules.java.S4977.html Maven / Gradle / Ivy

Why is this an issue?

Shadowing makes it impossible to use the type parameter from the outer scope. Also, it can be confusing to distinguish which type parameter is being used.

This rule raises an issue when a type parameter from an inner scope uses the same name as one in an outer scope.

Noncompliant code example

 public class TypeParameterHidesAnotherType<T> {

    public class Inner<T> { // Noncompliant
      //...
    }

    private <T> T method() { // Noncompliant
      return null;
    }

  }

Compliant solution

public class NoTypeParameterHiding<T> {

    public class Inner<S> { // Compliant
      List<S> listOfS;
    }

    private <V> V method() { // Compliant
      return null;
    }

  }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy