Fix false warning about check for instance of nullable type

#KT-12269 Fixed
This commit is contained in:
Mikhail Zarechenskiy
2017-04-05 16:37:02 +03:00
parent 0d6b7bb6a1
commit 90a8a164b4
6 changed files with 65 additions and 6 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2015 JetBrains s.r.o.
* Copyright 2010-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.
@@ -433,7 +433,7 @@ class PatternMatchingTypingVisitor internal constructor(facade: ExpressionTyping
context.trace.report(IS_ENUM_ENTRY.on(typeReferenceAfterIs))
}
if (!subjectType.isMarkedNullable && targetType.isMarkedNullable) {
if (!TypeUtils.isNullableType(subjectType) && targetType.isMarkedNullable) {
val element = typeReferenceAfterIs.typeElement
assert(element is KtNullableType) { "element must be instance of " + KtNullableType::class.java.name }
context.trace.report(Errors.USELESS_NULLABLE_CHECK.on(element as KtNullableType))