-
Notifications
You must be signed in to change notification settings - Fork 299
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[refactoring] Wrap calls to Types.subst and Types.memberType (#1115)
This is in preparation to attempt to fix #1091. Just a refactoring, no behavior changes.
- Loading branch information
Showing
3 changed files
with
49 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
nullaway/src/main/java/com/uber/nullaway/generics/TypeSubstitutionUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.uber.nullaway.generics; | ||
|
||
import com.sun.tools.javac.code.Symbol; | ||
import com.sun.tools.javac.code.Type; | ||
import com.sun.tools.javac.code.Types; | ||
import com.sun.tools.javac.util.List; | ||
|
||
/** Utility method related to substituting type arguments for type variables. */ | ||
public class TypeSubstitutionUtils { | ||
|
||
/** | ||
* Returns the type of {@code sym} as a member of {@code t}. | ||
* | ||
* @param types the {@link Types} instance | ||
* @param t the enclosing type | ||
* @param sym the symbol | ||
* @return the type of {@code sym} as a member of {@code t} | ||
*/ | ||
public static Type memberType(Types types, Type t, Symbol sym) { | ||
return types.memberType(t, sym); | ||
} | ||
|
||
/** | ||
* Substitutes the types in {@code to} for the types in {@code from} in {@code t}. | ||
* | ||
* @param types the {@link Types} instance | ||
* @param t the type to which to perform the substitution | ||
* @param from the types that will be substituted out | ||
* @param to the types that will be substituted in | ||
* @return the type resulting from the substitution | ||
*/ | ||
public static Type subst(Types types, Type t, List<Type> from, List<Type> to) { | ||
return types.subst(t, from, to); | ||
} | ||
} |