StreamApiUtil#getStreamELementType: use PsiUtil.substituteTypeParameter to correctly extract type parameter

This commit is contained in:
Tagir Valeev
2017-01-10 08:36:38 +06:00
parent db1222cc61
commit a9b8f9c7f4
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
package com.siyeh.ig.psiutils;
import com.intellij.psi.*;
import com.intellij.psi.util.PsiUtil;
import org.jetbrains.annotations.Contract;
/**
@@ -38,9 +39,7 @@ public class StreamApiUtil {
if(!com.intellij.psi.util.InheritanceUtil.isInheritor(aClass, false, CommonClassNames.JAVA_UTIL_STREAM_STREAM)) {
return null;
}
PsiType[] parameters = ((PsiClassType)type).getParameters();
if(parameters.length != 1) return null;
PsiType streamType = parameters[0];
PsiType streamType = PsiUtil.substituteTypeParameter(type, CommonClassNames.JAVA_UTIL_STREAM_STREAM, 0, false);
if(streamType instanceof PsiCapturedWildcardType) {
streamType = ((PsiCapturedWildcardType)streamType).getUpperBound();
}