From a9b8f9c7f4aed1deec605577ba770f74c070aa89 Mon Sep 17 00:00:00 2001 From: Tagir Valeev Date: Wed, 4 Jan 2017 17:35:17 +0600 Subject: [PATCH] StreamApiUtil#getStreamELementType: use PsiUtil.substituteTypeParameter to correctly extract type parameter --- .../src/com/siyeh/ig/psiutils/StreamApiUtil.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/StreamApiUtil.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/StreamApiUtil.java index 4ac268baa255..ad65bf8ff58b 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/StreamApiUtil.java +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/StreamApiUtil.java @@ -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(); }