From b5d7a7e95188746232d81fa8014bdf835e8e6ebf Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Wed, 15 Aug 2012 17:05:11 +0400 Subject: [PATCH] EA-38210 (fallback to Object for incorrect multi-catches) --- .../src/com/intellij/psi/PsiDisjunctionType.java | 11 +++++++++-- .../advHighlighting7/MultiCatch.java | 5 ++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/java/java-psi-api/src/com/intellij/psi/PsiDisjunctionType.java b/java/java-psi-api/src/com/intellij/psi/PsiDisjunctionType.java index abf0dd940492..eb7a320cd359 100644 --- a/java/java-psi-api/src/com/intellij/psi/PsiDisjunctionType.java +++ b/java/java-psi-api/src/com/intellij/psi/PsiDisjunctionType.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -38,7 +38,7 @@ public class PsiDisjunctionType extends PsiType { private final List myTypes; private final CachedValue myLubCache; - public PsiDisjunctionType(final List types, final PsiManager psiManager) { + public PsiDisjunctionType(@NotNull final List types, @NotNull final PsiManager psiManager) { super(PsiAnnotation.EMPTY_ARRAY); myManager = psiManager; @@ -51,20 +51,27 @@ public class PsiDisjunctionType extends PsiType { PsiType lub = myTypes.get(0); for (int i = 1; i < myTypes.size(); i++) { lub = GenericsUtil.getLeastUpperBound(lub, myTypes.get(i), psiManager); + if (lub == null) { + lub = PsiType.getJavaLangObject(myManager, GlobalSearchScope.allScope(myManager.getProject())); + break; + } } return Result.create(lub, PsiModificationTracker.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT); } }, false); } + @NotNull public PsiType getLeastUpperBound() { return myLubCache.getValue(); } + @NotNull public List getDisjunctions() { return myTypes; } + @NotNull public PsiDisjunctionType newDisjunctionType(final List types) { return new PsiDisjunctionType(types, myManager); } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/MultiCatch.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/MultiCatch.java index 84798f6d3a43..94e944837f80 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/MultiCatch.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/MultiCatch.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -63,6 +63,9 @@ abstract class C { Class clazz2 = e.getClass(); Class clazz3 = e.getClass(); } + + try { f(); } + catch (int | E e) { } } }